private void _mnuOverlaysShowOverlayAttributes_Click(object sender, EventArgs e) { string strAttributes = string.Empty; int selected = _rasterImageList.Items.IndexOf(_rasterImageList.Items.GetSelected()[0]); RasterGetSetOverlayAttributesFlags flags = RasterGetSetOverlayAttributesFlags.Color | RasterGetSetOverlayAttributesFlags.BitIndex | RasterGetSetOverlayAttributesFlags.Dicom | RasterGetSetOverlayAttributesFlags.Origin | RasterGetSetOverlayAttributesFlags.Flags; RasterOverlayAttributes attributes = _rasterImageViewer.Image.GetOverlayAttributes(selected, flags); strAttributes = "Overlay Origin\t\tX: " + attributes.Origin.X.ToString() + " Y: " + attributes.Origin.Y.ToString() + "\n"; strAttributes += "Overlay Color\t\t" + attributes.Color.ToRgb() + "\n"; strAttributes += "Overlay Index\t\t" + selected.ToString() + "\n"; strAttributes += "AutoPaint Flag\t\t" + (attributes.AutoPaint ? "On" : "Off") + "\n"; strAttributes += "AutoProcess Flag\t\t" + (attributes.AutoProcess ? "On" : "Off") + "\n"; strAttributes += "UseBitPlane Flag\t\t" + (attributes.UseBitPlane ? "On" : "Off") + "\n"; strAttributes += "Num. Of Overlay Rows\t" + attributes.Rows.ToString() + "\n"; strAttributes += "Num. Of Overlay Columns\t" + attributes.Columns.ToString() + "\n"; strAttributes += "Overlay Type:\t\t" + attributes.Type + "\n"; strAttributes += "Num. Of Allocated Bits\t" + attributes.BitsAllocated.ToString() + "\n"; strAttributes += "Overlay Subtype\t" + attributes.Subtype + "\n"; strAttributes += "Overlay Label\t" + attributes.Label + "\n"; strAttributes += "ROI Area\t\t\t" + attributes.RoiArea.ToString() + "\n"; strAttributes += "ROI Mean\t\t\t" + attributes.RoiMean.ToString() + "\n"; strAttributes += "ROI Standard Deviation\t" + attributes.RoiStandardDeviation.ToString() + "\n"; strAttributes += "Num. Of Overlay Frames\t" + attributes.FramesInOverlay.ToString() + "\n"; strAttributes += "Image Frame Origin\t\t" + attributes.ImageFrameOrigin.ToString() + "\n"; strAttributes += "Overlay Activation Layer\t\t" + attributes.ActivationLayer + "\n"; strAttributes += "Overlay Description\t\t" + attributes.Description + "\n"; MessageBox.Show(strAttributes, "Overlay " + selected + " Attributes"); }
private void _mnuOverlaysChangeOverlayColor_Click(object sender, EventArgs e) { ColorDialog clrDlg = new ColorDialog(); clrDlg.Color = _overlayColor; int selected = _rasterImageList.Items.IndexOf(_rasterImageList.Items.GetSelected()[0]); if (clrDlg.ShowDialog() == DialogResult.OK) { _overlayColor = clrDlg.Color; // Update all overlays with new color RasterOverlayAttributes attributes = _rasterImageViewer.Image.GetOverlayAttributes(selected, RasterGetSetOverlayAttributesFlags.Color); attributes.Color = new RasterColor(_overlayColor.R, _overlayColor.G, _overlayColor.B); _rasterImageViewer.Image.UpdateOverlayAttributes(selected, attributes, RasterGetSetOverlayAttributesFlags.Color); RasterImage img = _rasterImageViewer.Image.GetOverlayImage(selected, RasterGetSetOverlayImageMode.Copy); img.MakeRegionEmpty(); RasterColor[] aPalette = { new RasterColor(0, 0, 0), new RasterColor(clrDlg.Color.R, clrDlg.Color.G, clrDlg.Color.B) }; img.SetPalette(aPalette, 0, 2); if (_rasterImageList != null) { if (_rasterImageList.Items.Count > 0) { _rasterImageList.Items[selected].Image.Dispose(); _rasterImageList.Items[selected].Image = img; _rasterImageList.Invalidate(); } } } }
void _rasterImageList_SelectedItemsChanged(object sender, EventArgs e) { if (_rasterImageList.Items.GetSelected().Length > 0) { int selected = _rasterImageList.Items.IndexOf(_rasterImageList.Items.GetSelected()[0]); RasterOverlayAttributes attributes = _rasterImageViewer.Image.GetOverlayAttributes(selected, RasterGetSetOverlayAttributesFlags.Flags); _mnuOverlaysShowOverlay.Checked = attributes.AutoPaint; } }
private void _mnuOverlaysShowOverlay_CheckedChanged(object sender, EventArgs e) { if (_rasterImageList.Items.GetSelected().Length > 0) { int selected = _rasterImageList.Items.IndexOf(_rasterImageList.Items.GetSelected()[0]); RasterOverlayAttributes attributes = _rasterImageViewer.Image.GetOverlayAttributes(selected, RasterGetSetOverlayAttributesFlags.Flags); attributes.AutoPaint = _mnuOverlaysShowOverlay.Checked; _rasterImageViewer.Image.UpdateOverlayAttributes(selected, attributes, RasterGetSetOverlayAttributesFlags.Flags); } }
private void _mnuOverlaysInsertOverlay_Click(object sender, EventArgs e) { try { OpenFileDialog dlg = new OpenFileDialog(); dlg.Filter = "All Files (*.*)|*.*"; dlg.FilterIndex = 0; if (dlg.ShowDialog() == DialogResult.OK) { RasterImage overlay; RasterCodecs codecs = new RasterCodecs(); overlay = codecs.Load(dlg.FileName, 1, CodecsLoadByteOrder.Bgr, 1, 1); ImageViewerItem item = new ImageViewerItem(); int overlayIndex; // Add to image list item.Image = overlay; _rasterImageList.Items.Add(item); overlayIndex = _rasterImageList.Items.Count - 1; _rasterImageList.Items.Select(null);// .SelectAll(false); // Add to Viewer _rasterImageViewer.Image.SetOverlayImage(overlayIndex, item.Image, RasterGetSetOverlayImageMode.Copy); // Update Attributes RasterOverlayAttributes attributes = _rasterImageViewer.Image.GetOverlayAttributes(overlayIndex, RasterGetSetOverlayAttributesFlags.Flags); attributes.AutoPaint = _mnuOverlaysShowOverlay.Checked; attributes.Origin = new LeadPoint(0, 0); attributes.Color = new RasterColor(0xFF, 0xFF, 0xFF); attributes.Columns = item.Image.ImageWidth; attributes.Rows = item.Image.ImageHeight; attributes.BitsAllocated = 1; attributes.FramesInOverlay = item.Image.PageCount; attributes.ImageFrameOrigin = 1; attributes.Type = "G"; _rasterImageViewer.Image.UpdateOverlayAttributes(overlayIndex, attributes, RasterGetSetOverlayAttributesFlags.Flags | RasterGetSetOverlayAttributesFlags.Origin | RasterGetSetOverlayAttributesFlags.Color | RasterGetSetOverlayAttributesFlags.Dicom); _rasterImageList.Items[overlayIndex].IsSelected = true; EnableOverlayOptions(); } } catch (Exception ex) { Messager.ShowError(this, ex); } }
private void LoadOverlays() { if (_DataSet.OverlayCount > 0) { for (int i = 0; i < _DataSet.OverlayCount; i++) { ImageViewerItem item = new ImageViewerItem(); item.Size = new LeadSize(100, 100); item.Zoom(ControlSizeMode.FitAlways, 1, _rasterImageList.DefaultZoomOrigin.ToLeadPointD()); RasterOverlayAttributes attribte = _DataSet.GetOverlayAttributes(0); if (attribte.FramesInOverlay > 1) { item.Image = _DataSet.GetOverlayImages(0, 0, attribte.FramesInOverlay); } else { // Add to image list item.Image = _rasterImageViewer.Image.GetOverlayImage(i, RasterGetSetOverlayImageMode.Copy); _rasterImageList.Items.Add(item); _rasterImageList.Items.Select(null); _rasterImageList.Items[i].IsSelected = true; // Add to Viewer _rasterImageViewer.Image.SetOverlayImage(i, item.Image, RasterGetSetOverlayImageMode.Copy); // Update Attributes RasterOverlayAttributes attributes = _rasterImageViewer.Image.GetOverlayAttributes(i, RasterGetSetOverlayAttributesFlags.Flags); attributes.AutoPaint = _mnuOverlaysShowOverlay.Checked; attributes.AutoProcess = true; attributes.Origin = new LeadPoint(0, 0); attributes.Color = new RasterColor(_overlayColor.R, _overlayColor.G, _overlayColor.B); attributes.Columns = item.Image.ImageWidth; attributes.Rows = item.Image.ImageHeight; attributes.BitsAllocated = 1; attributes.FramesInOverlay = item.Image.PageCount; attributes.ImageFrameOrigin = 1; attributes.Type = "G"; _rasterImageViewer.Image.UpdateOverlayAttributes(i, attributes, RasterGetSetOverlayAttributesFlags.Flags | RasterGetSetOverlayAttributesFlags.Origin | RasterGetSetOverlayAttributesFlags.Color | RasterGetSetOverlayAttributesFlags.Dicom); } } } else { MessageBox.Show("This dataset has no overlays.\nTo insert a new overlay, please select \"Overlays\\ Insert Overlay\" from the menu."); } }