/// <summary> /// Gets the annotation text. /// </summary> /// <param name="presentationImage">the input presentation image.</param> /// <returns>the annotation text.</returns> public override string GetAnnotationText(IPresentationImage presentationImage) { string markerText = ""; if (presentationImage != null) { ISpatialTransformProvider associatedTransform = presentationImage as ISpatialTransformProvider; IImageSopProvider associatedDicom = presentationImage as IImageSopProvider; if (associatedDicom != null && associatedTransform != null) { var spatialTransform = associatedTransform.SpatialTransform as SpatialTransform; if (spatialTransform != null) { var imageOrientationPatient = associatedDicom.Frame.ImageOrientationPatient; var patientOrientation = associatedDicom.Frame.PatientOrientation; if (imageOrientationPatient != null && !imageOrientationPatient.IsNull) { markerText = GetAnnotationTextInternal(spatialTransform, imageOrientationPatient); } else if (patientOrientation != null && patientOrientation.IsValid) { markerText = GetAnnotationTextInternal(spatialTransform, patientOrientation); } } } } return(markerText); }
public override string GetAnnotationText(IPresentationImage presentationImage) { if (presentationImage == null) { return(string.Empty); } ISpatialTransformProvider image = presentationImage as ISpatialTransformProvider; if (image == null) { return(string.Empty); } return(String.Format(SR.FormatZoomFactor, image.SpatialTransform.Scale.ToString("F2"))); }
public static Bitmap CreatePresentationImageIcon(IPresentationImage image, double tileRatio) { ISpatialTransformProvider provider = image as ISpatialTransformProvider; if (provider == null) { throw new Exception(SR.ConvertTransformProviderFailed); } ImageSpatialTransform spatialTransform = provider.SpatialTransform as ImageSpatialTransform; object memento = spatialTransform.CreateMemento(); Size size = CalculateSize(image.ClientRectangle.Size, tileRatio); Bitmap bitmap = new Bitmap(image.DrawToBitmap(size.Width, size.Height), _iconWidth, Convert.ToInt32((float)(_iconWidth * Convert.ToSingle(tileRatio)))); spatialTransform.SetMemento(memento); return(bitmap); }
public static Bitmap CreatePresentationImagePrintData(IPresentationImage image, RectangleF destRange, double tileRatio, float scale, bool withAnnotation) { ISpatialTransformProvider provider = image as ISpatialTransformProvider; if (provider == null) { Platform.Log(LogLevel.Error, "RectangleF 转换失败"); throw new Exception("转换失败"); } ImageSpatialTransform spatialTransform = provider.SpatialTransform as ImageSpatialTransform; object memento = spatialTransform.CreateMemento(); float num = scale / spatialTransform.Scale; spatialTransform.MoveTo(destRange, scale); Size destSize = new Size(Convert.ToInt32((float)(destRange.Width * num)), Convert.ToInt32((float)(destRange.Height * num))); Bitmap bitmap = DrawToFilmSizeBitmap(destSize, image, tileRatio, withAnnotation); spatialTransform.SetMemento(memento); return(bitmap); }
public static Bitmap CreatePresentationImageIcon(IPresentationImage image, RectangleF destRange, double tileRatio) { if (destRange == RectangleF.Empty) { return(null); } ISpatialTransformProvider provider = image as ISpatialTransformProvider; if (provider == null) { throw new Exception(SR.ConvertTransformProviderFailed); } ImageSpatialTransform spatialTransform = provider.SpatialTransform as ImageSpatialTransform; object memento = spatialTransform.CreateMemento(); spatialTransform.MoveTo(destRange); Size destSize = new Size(Convert.ToInt32(destRange.Width), Convert.ToInt32(destRange.Height)); Bitmap original = DrawToFilmSizeBitmap(destSize, image, tileRatio, true); Bitmap bitmap2 = new Bitmap(original, _iconWidth, (int)(_iconWidth * tileRatio)); original.Dispose(); spatialTransform.SetMemento(memento); return(bitmap2); }
public override string GetAnnotationText(IPresentationImage presentationImage) { if (presentationImage == null) { return(String.Empty); } IImageSopProvider imageSopProvider = presentationImage as IImageSopProvider; if (imageSopProvider == null) { return(String.Empty); } ISpatialTransformProvider spatialTransformProvider = presentationImage as ISpatialTransformProvider; if (spatialTransformProvider == null) { return(String.Empty); } ImageSpatialTransform transform = spatialTransformProvider.SpatialTransform as ImageSpatialTransform; if (transform == null) { return(String.Empty); } if (transform.RotationXY % 90 != 0) { return(SR.ValueNotApplicable); } Frame frame = imageSopProvider.Frame; PixelSpacing normalizedPixelSpacing = frame.NormalizedPixelSpacing; if (normalizedPixelSpacing.IsNull) { return(String.Empty); } RectangleF sourceRectangle = new RectangleF(0, 0, frame.Columns, frame.Rows); RectangleF destinationRectangle = transform.ConvertToDestination(sourceRectangle); destinationRectangle = RectangleUtilities.Intersect(destinationRectangle, presentationImage.ClientRectangle); //Convert the displayed width and height to source dimensions SizeF widthInSource = transform.ConvertToSource(new SizeF(destinationRectangle.Width, 0)); SizeF heightInSource = transform.ConvertToSource(new SizeF(0, destinationRectangle.Height)); //The displayed FOV is given by the magnitude of each line in source coordinates, but //for each of the 2 lines, one of x or y will be zero, so we can optimize. float x1 = Math.Abs(widthInSource.Width); float y1 = Math.Abs(widthInSource.Height); float x2 = Math.Abs(heightInSource.Width); float y2 = Math.Abs(heightInSource.Height); double displayedFieldOfViewX, displayedFieldOfViewY; if (x1 > y1) //the image is not rotated { displayedFieldOfViewX = x1 * normalizedPixelSpacing.Column / 10; displayedFieldOfViewY = y2 * normalizedPixelSpacing.Row / 10; } else //the image is rotated by 90 or 270 degrees { displayedFieldOfViewX = x2 * normalizedPixelSpacing.Column / 10; displayedFieldOfViewY = y1 * normalizedPixelSpacing.Row / 10; } return(String.Format(SR.FormatCentimeters, String.Format(SR.Format2Dimensions, displayedFieldOfViewX.ToString("F1"), displayedFieldOfViewY.ToString("F1")))); }
public static Bitmap CreatePresentationImagePrintData(IPresentationImage image, double tileRatio, bool withAnnotation) { Size size; ISpatialTransformProvider provider = image as ISpatialTransformProvider; if (provider == null) { Platform.Log(LogLevel.Error, " 转换失败"); throw new Exception("转换失败"); } ImageSpatialTransform spatialTransform = provider.SpatialTransform as ImageSpatialTransform; object memento = spatialTransform.CreateMemento(); if (!spatialTransform.ScaleToFit) { //Platform.Log(LogLevel.Error, "!spatialTransform.ScaleToFit"); float num = 1f / spatialTransform.Scale; int width = Convert.ToInt32((float)(image.ClientRectangle.Width * num)); int height = Convert.ToInt32((float)(image.ClientRectangle.Height * num)); //if ((width > spatialTransform.SourceWidth) || (height > spatialTransform.SourceHeight)) //{ // float num4 = ((float)image.ClientRectangle.Width) / ((float)image.ClientRectangle.Height); // float num5 = ((float)spatialTransform.SourceWidth) / ((float)spatialTransform.SourceHeight); // if (num4 > num5) // { // size = new Size(spatialTransform.SourceWidth, Convert.ToInt32((float)(((float)spatialTransform.SourceWidth) / num4))); // spatialTransform.Scale = (spatialTransform.Scale * spatialTransform.SourceWidth) / ((float)image.ClientRectangle.Width); // } // else // { // size = new Size(Convert.ToInt32((float)(spatialTransform.SourceHeight * num4)), spatialTransform.SourceHeight); // spatialTransform.Scale = (spatialTransform.Scale * spatialTransform.SourceHeight) / ((float)image.ClientRectangle.Height); // } //} //else { if (width >= 3000 || height >= 3000) { width = (int)(width * 0.3); height = (int)(height * 0.3); } size = new Size(width, height); spatialTransform.Scale = (spatialTransform.Scale * width) / ((float)image.ClientRectangle.Width); } } else { if (spatialTransform.SourceWidth > 3000 || spatialTransform.SourceHeight > 3000) { size = new Size((int)(spatialTransform.SourceWidth * 0.3), (int)(spatialTransform.SourceHeight * 0.3)); } else { size = new Size(spatialTransform.SourceWidth, spatialTransform.SourceHeight); } } Size size2 = CalculateSize(size, tileRatio); if (!withAnnotation) { HideAnnotation(image); } Bitmap bitmap = image.DrawToBitmap(size2.Width, size2.Height); if (!withAnnotation) { ShowAnnotation(image); } spatialTransform.SetMemento(memento); return(bitmap); }