/// <summary>A GET request that returns a bitmap image for XVWeb.</summary> public static Bitmap GetBitmap(ApteryxImage img, IProgressHandler progressWindow) { string token = GetAuthorizationToken(); //reuse old token or get a new one. UriBuilder uriBuilder = GetApiUri(); uriBuilder.Path += "bitmap/" + img.Id; Stream responseStream = GetRequestHelperStream(token, uriBuilder, accept: GetMimeTypeForImageQuality()); int bytesRead; Bitmap image; long totalBytesRead = 0; byte[] buffer = new byte[10 * 1024]; using (MemoryStream ms = new MemoryStream()) { try { while ((bytesRead = responseStream.Read(buffer, 0, buffer.Length)) > 0) { totalBytesRead += bytesRead; if (totalBytesRead != img.FileSize) { progressWindow.UpdateBytesRead(totalBytesRead); } ms.Write(buffer, 0, bytesRead); } progressWindow.CloseProgress(); } catch (Exception ex) { progressWindow.DisplayError(ex.Message); } image = new Bitmap(ms); } responseStream.Close(); return(image); }
/// <summary>A GET request that returns a bitmap image for XVWeb.</summary> public static Bitmap GetThumbnail(ApteryxImage img) { string token = GetAuthorizationToken(); UriBuilder uriBuilder = GetApiUri(); uriBuilder.Path += "bitmap/thumbnail/" + img.Id; using (Stream responseStream = GetRequestHelperStream(token, uriBuilder, accept: GetMimeTypeForImageQuality())) { return(new Bitmap(responseStream)); } }
/// <summary>A GET request that returns a bitmap image for XVWeb.</summary> public static Bitmap GetThumbnail(ApteryxImage img) { string token = GetAuthorizationToken(); UriBuilder uriBuilder = GetApiUri(); uriBuilder.Path += "bitmap/thumbnail/" + img.Id; using (Stream responseStream = GetRequestHelperStream(token, uriBuilder, contentType: "image/jpeg")) { return(new Bitmap(responseStream)); } }
///<summary>Saves the image to A to Z in a new document if the program property to save images is set. Returns null if images are not set to be ///saved or if the image already exists.</summary> public static Document SaveApteryxImageToDoc(ApteryxImage img, Bitmap saveImage, Patient patCur) { if (ProgramProperties.GetPropVal(Programs.GetProgramNum(ProgramName.XVWeb), ProgramProps.SaveImages).Trim().ToLower() != "yes" || Documents.DocExternalExists(img.Id.ToString(), ExternalSourceType.XVWeb)) //if they want to save and it doesn't already exist in DB { return(null); } //store the image in the database string imageCat = ProgramProperties.GetPropVal(Programs.GetProgramNum(ProgramName.XVWeb), ProgramProps.ImageCategory); Document doc = ImageStore.Import(saveImage, (Defs.GetDef(DefCat.ImageCats, PIn.Long(imageCat)).DefNum), ImageType.Photo, patCur); doc.ToothNumbers = img.FormattedTeeth; doc.DateCreated = img.AcquisitionDate; doc.Description = doc.ToothNumbers; doc.ExternalGUID = img.Id.ToString(); doc.ExternalSource = ExternalSourceType.XVWeb; Documents.Update(doc); return(doc); }