2using AForge.Imaging.Filters;
7using OpenTK.Mathematics;
8using OpenTK.Windowing.Common;
9using OpenTK.Windowing.Desktop;
10using OpenTK.Windowing.GraphicsLibraryFramework;
12using System.ComponentModel;
13using System.Runtime.InteropServices;
15using Bitmap = AForge.Bitmap;
16using Image = System.Drawing.Image;
17using Keys = System.Windows.Forms.Keys;
18using PointF = AForge.PointF;
30 public partial class ImageView : UserControl, IDisposable
33 SlideGLArea gl =
new SlideGLArea();
34 SlideRenderer slideRenderer;
38 string file = im.ID.Replace(
"\\",
"/");
39 InitializeComponent();
40 bool useGpuTiles = im.Resolutions.Count > 1;
41 BioLib.SlideSourceBase.UseGPU = useGpuTiles;
42 OpenSlideGTK.SlideSourceBase.useGPU = useGpuTiles;
43 viewpanel.Paint += Viewpanel_Paint;
44 AttachViewerInput(viewpanel);
48 gl.Size =
new System.Drawing.Size(800, 600);
49 if (im.openSlideImage !=
null && OpenWithOpenSlide)
51 Initialize(im.file, im);
54 Initialize(im.file, im);
55 hScrollBar.Visible =
true;
56 vScrollBar.Visible =
true;
60 hScrollBar.Visible =
false;
61 vScrollBar.Visible =
false;
62 Tools.selectBoxSize = GetSelectBoxSize();
66 gl.Dock = DockStyle.Fill;
67 viewpanel.Controls.Add(gl);
68 AttachViewerInput(gl);
70 Dock = DockStyle.Fill;
72 UpdateRenderSurfaceMode();
74 if (file ==
"" || file ==
null)
77 MouseWheel +=
new System.Windows.Forms.MouseEventHandler(ImageView_MouseWheel);
78 zBar.MouseWheel +=
new System.Windows.Forms.MouseEventHandler(ZTrackBar_MouseWheel);
79 cBar.MouseWheel +=
new System.Windows.Forms.MouseEventHandler(CTrackBar_MouseWheel);
80 tBar.MouseWheel +=
new System.Windows.Forms.MouseEventHandler(TimeTrackBar_MouseWheel);
82 zBar.MouseWheel += (sender, e) => ((HandledMouseEventArgs)e).Handled =
true;
83 tBar.MouseWheel += (sender, e) => ((HandledMouseEventArgs)e).Handled =
true;
84 cBar.MouseWheel += (sender, e) => ((HandledMouseEventArgs)e).Handled =
true;
85 this.SizeChanged += ImageView_SizeChanged;
87 this.KeyPress += ImageView_KeyPress;
88 this.KeyUp += ImageView_KeyUp;
92 resolutions = im.Resolutions;
96 if (im.OpenSlideBase !=
null)
98 if (slideRenderer ==
null)
100 if (!slideRenderer.IsSource(im.OpenSlideBase))
101 slideRenderer.SetSource(im.OpenSlideBase);
103 else if (im.SlideBase !=
null)
105 if (slideRenderer ==
null)
107 if (!slideRenderer.IsSource(im.SlideBase))
108 slideRenderer.SetSource(im.SlideBase);
123 InitializeComponent();
124 viewpanel.Paint += Viewpanel_Paint;
125 AttachViewerInput(viewpanel);
127 AttachViewerInput(gl);
128 InitializeOverview();
129 Dock = DockStyle.Fill;
133 MouseWheel +=
new System.Windows.Forms.MouseEventHandler(ImageView_MouseWheel);
134 zBar.MouseWheel +=
new System.Windows.Forms.MouseEventHandler(ZTrackBar_MouseWheel);
135 cBar.MouseWheel +=
new System.Windows.Forms.MouseEventHandler(CTrackBar_MouseWheel);
136 tBar.MouseWheel +=
new System.Windows.Forms.MouseEventHandler(TimeTrackBar_MouseWheel);
137 this.SizeChanged += ImageView_SizeChanged;
139 zBar.MouseWheel += (sender, e) => ((HandledMouseEventArgs)e).Handled =
true;
140 tBar.MouseWheel += (sender, e) => ((HandledMouseEventArgs)e).Handled =
true;
141 cBar.MouseWheel += (sender, e) => ((HandledMouseEventArgs)e).Handled =
true;
152 const int WM_KEYDOWN = 0x0100;
153 const int WM_KEYUP = 0x0101;
154 const int WM_CHAR = 0x0102;
163 ImageView_KeyUp(
this,
new KeyEventArgs(keyData));
167 char ch = (char)msg.WParam;
168 ImageView_KeyPress(
this,
new System.Windows.Forms.KeyPressEventArgs(ch));
172 return base.ProcessCmdKey(ref msg, keyData);
175 private void ImageView_SizeChanged(
object? sender, EventArgs e)
179 SelectedImage.PyramidalSize =
new AForge.Size(gl.Width, gl.Height);
182 centerOnNextResize =
false;
185 UpdateOverviewVisibility();
188 private void InitGL()
190 var gameWindowSettings =
new GameWindowSettings()
192 UpdateFrequency = 60,
194 NativeWindowSettings nativeSettings;
196 nativeSettings =
new NativeWindowSettings()
198 ClientSize =
new Vector2i(600, 400),
199 Location =
new Vector2i(0, 0),
200 Title =
"OpenGL Context",
201 StartVisible =
false,
202 API = ContextAPI.OpenGL,
203 Profile = ContextProfile.Core,
204 APIVersion =
new Version(3, 3)
206 window =
new GLWindow(gameWindowSettings, nativeSettings);
207 GLFWProvider.SetErrorCallback((error, description) =>
209 Console.WriteLine($
"BioImager GLFW Error {error}: {description}");
213 private void BringRenderSurfacesToFront()
215 if (gl.Parent == viewpanel)
217 if (overviewPanel !=
null && overviewPanel.Parent == viewpanel)
218 overviewPanel.BringToFront();
221 private void AttachViewerInput(Control surface)
223 surface.MouseDown += pictureBox_MouseDown;
224 surface.MouseMove += rgbPictureBox_MouseMove;
225 surface.MouseUp += pictureBox_MouseUp;
226 surface.MouseDoubleClick += pictureBox_MouseDoubleClick;
227 surface.MouseWheel += ImageView_MouseWheel;
228 surface.MouseEnter += (sender, e) => surface.Focus();
247 public Layer(
double d,
bool enabled)
254 public List<Layer>
Layers =
new List<Layer>();
256 private bool IsLayerEnabled(
double d)
265 List<System.Drawing.Bitmap> Bitmaps =
new List<System.Drawing.Bitmap>();
266 List<Resolution> resolutions =
new List<Resolution>();
268 private static int selectedIndex = 0;
305 public static bool up;
313 private bool x1State =
false;
314 private bool x2State =
false;
322 private bool update =
false;
323 public List<BioImage>
Images =
new List<BioImage>();
324 private bool centerOnNextResize;
329 private void Render(System.Drawing.Graphics canvas)
334 System.Drawing.Rectangle rf =
new System.Drawing.Rectangle((
int)canvas.Clip.GetBounds(canvas).X, (
int)canvas.Clip.GetBounds(canvas).Y,
335 (
int)canvas.Clip.GetBounds(canvas).Width, (
int)canvas.Clip.GetBounds(canvas).Height);
341 Console.WriteLine($
"Annotation render error: {ex.Message}");
345 private void RefreshPyramidalOverlayTexture()
349 if (gl.Width <= 0 || gl.Height <= 0)
352 using System.Drawing.Bitmap overlay =
new System.Drawing.Bitmap(gl.Width, gl.Height, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
353 using (System.Drawing.Graphics g = System.Drawing.Graphics.FromImage(overlay))
355 g.Clear(System.Drawing.Color.Transparent);
359 gl.SetOverlayBitmap(overlay);
362 private void BindSlideRendererSource(
BioImage image)
364 if (image ==
null || !UsesSlideRenderer(image))
367 if (slideRenderer ==
null)
368 slideRenderer =
new SlideRenderer(gl);
370 if (image.OpenSlideBase !=
null)
372 if (!slideRenderer.IsSource(image.OpenSlideBase))
373 slideRenderer.SetSource(image.OpenSlideBase);
375 else if (image.SlideBase !=
null)
377 if (!slideRenderer.IsSource(image.SlideBase))
378 slideRenderer.SetSource(image.SlideBase);
382 private static bool UsesSlideRenderer(
BioImage image)
384 return image !=
null && (image.isPyramidal || image.SlideBase !=
null || image.OpenSlideBase !=
null);
388 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
394 if (value >= 0 && value <
Images.Count)
398 selectedIndex = field;
400 if (UsesSlideRenderer(
Images[field]))
401 BindSlideRendererSource(
Images[field]);
413 private AForge.Rectangle overview;
416 get {
return overview; }
418 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
420 private double pxWmicron = 0.004;
421 private double pxHmicron = 0.004;
422 AForge.SizeF scale =
new AForge.SizeF(1, 1);
430 private bool initializingCoordinates;
438 BeginInvoke(
new MethodInvoker(() =>
SetCoordinate(z, c, t)));
445 int targetZ = Math.Clamp(z, zBar.Minimum, zBar.Maximum);
446 int targetC = Math.Clamp(c, cBar.Minimum, cBar.Maximum);
447 int targetT = Math.Clamp(t, tBar.Minimum, tBar.Maximum);
449 initializingCoordinates =
true;
450 if (zBar.Value != targetZ)
451 zBar.Value = targetZ;
452 if (cBar.Value != targetC)
453 cBar.Value = targetC;
454 if (tBar.Value != targetT)
455 tBar.Value = targetT;
456 initializingCoordinates =
false;
457 SelectedImage.Coordinate =
new ZCT(targetZ, targetC, targetT);
477 ZCT initialCoordinate =
new ZCT(im.Coordinate.Z, im.Coordinate.C, im.Coordinate.T);
480 centerOnNextResize =
true;
482 foreach (var item
in Layers)
484 if (item.Resolution == im.PhysicalSizeX)
491 hScrollBar.Visible =
true;
492 vScrollBar.Visible =
true;
496 hScrollBar.Visible =
false;
497 vScrollBar.Visible =
false;
498 Tools.selectBoxSize = GetSelectBoxSize();
501 SetCoordinate(initialCoordinate.Z, initialCoordinate.C, initialCoordinate.T);
505 QueueInitialCenterAfterLayout(
Images.Count - 1);
508 private void QueueInitialCenterAfterLayout(
int imageIndex)
510 if (!IsHandleCreated)
512 BeginInvoke(
new System.Action(() =>
514 if (IsDisposed || !centerOnNextResize || imageIndex >= Images.Count)
516 centerOnNextResize = false;
517 GoToImage(imageIndex);
524 private static int GetPreviewLevel(
BioImage image)
526 if (image ==
null || image.Resolutions.Count == 0)
529 int nativeLevelCount = image.PyramidNativeLevelCount > 0
530 ? Math.Min(image.PyramidNativeLevelCount, image.Resolutions.Count)
531 : image.Resolutions.Count;
532 return Math.Max(0, nativeLevelCount - 1);
535 private bool showControls =
true;
537 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
543 showControls = value;
544 trackBarPanel.Visible = value;
545 hideControlsToolStripMenuItem1.Text = value ?
"Hide Controls" :
"Show Controls";
546 showControlsToolStripMenuItem.Text = value ?
"Hide Controls" :
"Show Controls";
552 private bool showStatus =
true;
554 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
561 statusPanel.Visible = value;
562 hideControlsToolStripMenuItem.Text = value ?
"Hide Status" :
"Show Status";
571 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
586 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
607 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
626 rgbBoxsPanel.BringToFront();
629 BringRenderSurfacesToFront();
634 rgbBoxsPanel.SendToBack();
636 cLabel.BringToFront();
637 BringRenderSurfacesToFront();
642 rgbBoxsPanel.SendToBack();
644 cLabel.BringToFront();
645 BringRenderSurfacesToFront();
650 rgbBoxsPanel.BringToFront();
653 BringRenderSurfacesToFront();
690 bool hardwareAcceleration =
true;
693 get {
if (
SelectedImage.SlideBase ==
null)
return true;
else return false; }
702 return viewpanel.ClientSize.Width;
711 return viewpanel.ClientSize.Height;
716 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
719 get {
return origin; }
728 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
740 SelectedImage.PyramidalOrigin = value;
744 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
755 SelectedImage.Resolution = value;
757 SelectedImage.Level = (int)value;
777 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
789 Tools.selectBoxSize = GetSelectBoxSize();
797 return contextMenuStrip;
804 private readonly
bool[] rgbEnabled = {
true,
true,
true };
805 private bool initializingRgbSelectors;
808 private int[] SelectedRgbChannels(
BioImage image) => Enumerable.Range(0, 3)
809 .Select(i => rgbEnabled[i] ? image.rgbChannels[i] : -1).ToArray();
814 System.Windows.Forms.ComboBox[] boxes = { channelBoxR, channelBoxG, channelBoxB };
815 for (
int i = 0; i < boxes.Length; i++)
817 rgbEnabled[i] = boxes[i].SelectedIndex > 0;
818 if (rgbEnabled[i])
SelectedImage.rgbChannels[i] = boxes[i].SelectedIndex - 1;
822 private bool timeEnabled =
false;
825 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
836 zTimer.Interval = (int)Math.Floor(1000 / f);
841 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
852 timelineTimer.Interval = (int)Math.Floor(1000 / f);
857 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
868 cTimer.Interval = (int)Math.Floor(1000 / f);
879 initializingCoordinates =
true;
894 tBar.Enabled =
false;
900 bool sameImage = ReferenceEquals(rgbSelectorImage,
SelectedImage);
902 bool[] previousEnabled = (
bool[])rgbEnabled.Clone();
903 int[] previousChannels = (
int[])
SelectedImage.rgbChannels.Clone();
904 initializingRgbSelectors =
true;
905 channelBoxR.Items.Clear();
906 channelBoxG.Items.Clear();
907 channelBoxB.Items.Clear();
909 channelBoxR.Items.Add(
"");
910 channelBoxG.Items.Add(
"");
911 channelBoxB.Items.Add(
"");
914 channelBoxR.Items.Add(ch);
915 channelBoxG.Items.Add(ch);
916 channelBoxB.Items.Add(ch);
918 System.Windows.Forms.ComboBox[] rgbBoxes = { channelBoxR, channelBoxG, channelBoxB };
920 for (
int i = 0; i < rgbBoxes.Length; i++)
921 rgbBoxes[i].
SelectedIndex = count == 0 || (sameImage && !previousEnabled[i]) ? 0 :
922 (sameImage ? Math.Clamp(previousChannels[i], 0, count - 1) : (i < count ? i : 0)) + 1;
923 initializingRgbSelectors =
false;
924 zBar.Value = Math.Clamp(coordinate.Z, zBar.Minimum, zBar.Maximum);
925 cBar.Value = Math.Clamp(coordinate.C, cBar.Minimum, cBar.Maximum);
926 tBar.Value = Math.Clamp(coordinate.T, tBar.Minimum, tBar.Maximum);
927 SelectedImage.Coordinate =
new ZCT(zBar.Value, cBar.Value, tBar.Value);
928 initializingCoordinates =
false;
939 ROI.selectBoxSize = size;
940 UpdateToolSelectBoxSize();
943 private const float MinSelectBoxScreenSize = 8f;
944 private const float MinSelectionHitScreenSize = 8f;
946 private float GetSelectBoxSize()
948 return GetSelectBoxSizeForScreenPixels(MinSelectBoxScreenSize);
951 private float GetSelectBoxSizeForScreenPixels(
float minScreenSize)
955 float logicalSize = Math.Max(ROI.selectBoxSize, minScreenSize);
957 if (resolution <= 0 ||
double.IsNaN(resolution) ||
double.IsInfinity(resolution))
959 return (
float)(logicalSize * resolution);
962 float zoom = Math.Abs(
Scale.Width);
963 if (zoom <= 0 ||
float.IsNaN(zoom) ||
float.IsInfinity(zoom))
967 if (pixelSize <= 0 ||
double.IsNaN(pixelSize) ||
double.IsInfinity(pixelSize))
970 float screenSize = Math.Max(ROI.selectBoxSize, minScreenSize);
971 return (
float)(screenSize / (zoom * pixelSize));
974 private void UpdateToolSelectBoxSize()
976 Tools.selectBoxSize = GetSelectBoxSize();
984 UpdateToolSelectBoxSize();
987 RefreshPyramidalOverlayTexture();
989 overviewPanel.Invalidate();
992 viewpanel.Invalidate();
999 BioImage image = OverviewSelectedImage;
1002 string res = image.Type == BioImage.ImageType.well
1003 ? $
"Well:{image.Level}"
1004 : image.isPyramidal ? $
"Res.:{image.Resolution:G4} Level:{image.Level}" :
"";
1005 string pixelFormat = image.Buffers.Count > 0
1006 ? image.Buffers[0].PixelFormat.ToString()
1007 : image.Resolutions.Count > 0
1008 ? image.Resolutions[Math.Clamp(image.Level, 0, image.Resolutions.Count - 1)].PixelFormat.ToString()
1010 string position = image.isPyramidal
1011 ? $
"({image.PyramidalOrigin.X:0.##}, {image.PyramidalOrigin.Y:0.##})"
1012 : $
"({-Origin.X:0.##}, {-Origin.Y:0.##})";
1013 string location = $
"({image.Volume.Location.X:0.##}, {image.Volume.Location.Y:0.##})";
1014 string plane = $
"{zBar.Value + 1}/{zBar.Maximum + 1}";
1016 plane += $
", {cBar.Value + 1}/{cBar.Maximum + 1}";
1018 plane += $
", {tBar.Value + 1}/{tBar.Maximum + 1}";
1019 statusLabel.Text = $
"{plane}, {mousePoint}{mouseColor}, {pixelFormat}, Origin: {position}, {location} {res}";
1029 UpdateToolSelectBoxSize();
1032 UpdateRenderSurfaceMode();
1034 overviewPanel.Invalidate();
1037 RefreshPyramidalOverlayTexture();
1039 overviewPanel.Invalidate();
1042 viewpanel.Invalidate();
1368 overviewPanel.Invalidate();
1371 bool updating =
false;
1376 private int zarrRgbRequest;
1382 UpdateRenderSurfaceMode();
1386 if (!updatePyramidal || gl.Width <= 1 || gl.Height <= 1)
1389 SelectedImage.PyramidalSize =
new AForge.Size(gl.Width, gl.Height);
1396 int[]? directZarrChannels =
null;
1413 directZarrChannels =
new[] { channel, channel, channel };
1417 await slideRenderer.UpdateViewAsync(
1427 catch (Exception ex)
1429 System.Diagnostics.Trace.WriteLine($
"Could not update slide view: {ex}");
1431 RefreshPyramidalOverlayTexture();
1442 var requestedMode =
Mode;
1443 int request = ++zarrRgbRequest;
1444 int width = image.Buffers[0].SizeX, height = image.Buffers[0].SizeY;
1448 if (requestedMode ==
ViewMode.RGBImage)
1450 channels = SelectedRgbChannels(image);
1455 Math.Max(0, image.SizeC - 1));
1456 channels =
new[] { channel, channel, channel };
1459 byte[] rgba = await ZarrChannelView.ReadRgbTileAsync(image, 0, 0, 0, width, height,
1461 if (request != zarrRgbRequest ||
SelectedImage != image ||
Mode != requestedMode)
1463 var frame =
new System.Drawing.Bitmap(width, height, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
1464 var data = frame.LockBits(
new System.Drawing.Rectangle(0, 0, width, height),
1465 System.Drawing.Imaging.ImageLockMode.WriteOnly, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
1468 for (
int i = 0; i < rgba.Length; i += 4)
1469 (rgba[i], rgba[i + 2]) = (rgba[i + 2], rgba[i]);
1470 for (
int row = 0; row < height; row++)
1471 Marshal.Copy(rgba, row * width * 4, IntPtr.Add(data.Scan0, row * data.Stride), width * 4);
1473 finally { frame.UnlockBits(data); }
1474 foreach (var old
in Bitmaps) old?.Dispose();
1478 UpdateRegularOverview();
1481 catch (Exception ex)
1483 System.Diagnostics.Trace.WriteLine($
"Could not render Zarr RGB channels: {ex.Message}");
1492 int index = image.GetFrameIndex(zBar.Value, cBar.Value, tBar.Value);
1493 bool unavailable = index < 0 || index >= image.Buffers.Count;
1496 var buffers =
Mode == ViewMode.Filtered ||
Mode == ViewMode.Raw
1497 ?
new[] { image.Buffers[index] }
1498 : image.Buffers.AsEnumerable();
1499 unavailable = buffers.Any(buffer =>
1500 buffer ==
null || buffer.Bytes ==
null || buffer.Bytes.Length == 0);
1504 System.Diagnostics.Trace.WriteLine($
"Image pixels are unavailable: {image.ID}");
1508 for (
int i = 0; i < Bitmaps.Count; i++)
1510 Bitmaps[i].Dispose();
1524 b.PyramidalSize =
new AForge.Size(gl.Width, gl.Height);
1525 ZCT coords =
new ZCT(zBar.Value, cBar.Value, tBar.Value);
1528 int index = b.Coords[zBar.Value, cBar.Value, tBar.Value];
1531 bitmap = b.GetFiltered(coords, b.RChannel.RangeR, b.GChannel.RangeG, b.BChannel.RangeB);
1535 if (b.Buffers[0].RGBChannelsCount == 1)
1537 var planes =
new Bitmap[3];
1538 for (
int color = 0; color < 3; color++)
1540 int channel = Math.Clamp(b.rgbChannels[color], 0, b.SizeC - 1);
1541 planes[2 - color] = b.Buffers[b.GetFrameIndex(coords.Z, channel, coords.T)];
1543 bitmap =
Bitmap.GetRGBBitmap(planes, b.RChannel.RangeR, b.GChannel.RangeG, b.BChannel.RangeB);
1546 bitmap = b.GetRGBBitmap(coords, b.RChannel.RangeR, b.GChannel.RangeG, b.BChannel.RangeB);
1550 bitmap = (
Bitmap)b.Buffers[index].GetImageRGBA();
1554 bitmap = b.GetEmission(coords, b.RChannel.RangeR, b.GChannel.RangeG, b.BChannel.RangeB);
1556 var display = ToSysBitmap(bitmap);
1558 MaskRgbComponents(display, rgbEnabled);
1559 Bitmaps.Add(display);
1562 UpdateRegularOverview();
1567 private void UpdateRenderSurfaceMode()
1571 hScrollBar.Visible =
false;
1572 vScrollBar.Visible =
false;
1574 if (overviewPanel !=
null)
1575 overviewPanel.Visible =
false;
1581 if (gl.Parent != viewpanel)
1582 viewpanel.Controls.Add(gl);
1585 BringRenderSurfacesToFront();
1591 if (gl.Parent == viewpanel)
1592 viewpanel.Controls.Remove(gl);
1593 gl.ClearOverlayBitmap();
1598 UpdateOverviewVisibility();
1600 bool drawing =
false;
1605 System.Threading.Thread.Sleep(50);
1607 }
while (drawing || updating);
1618 }
while (drawing || updating);
1619 for (
int i = 0; i <
Images.Count; i++)
1641 private void channelBoxR_SelectedIndexChanged(
object sender, EventArgs e)
1643 if (initializingRgbSelectors ||
SelectedImage ==
null || channelBoxR.SelectedIndex == -1)
1645 rgbEnabled[0] = channelBoxR.SelectedIndex > 0;
1646 if (rgbEnabled[0])
SelectedImage.rgbChannels[0] = channelBoxR.SelectedIndex - 1;
1657 private void channelBoxG_SelectedIndexChanged(
object sender, EventArgs e)
1659 if (initializingRgbSelectors ||
SelectedImage ==
null || channelBoxG.SelectedIndex == -1)
1661 rgbEnabled[1] = channelBoxG.SelectedIndex > 0;
1662 if (rgbEnabled[1])
SelectedImage.rgbChannels[1] = channelBoxG.SelectedIndex - 1;
1673 private void channelBoxB_SelectedIndexChanged(
object sender, EventArgs e)
1675 if (initializingRgbSelectors ||
SelectedImage ==
null || channelBoxB.SelectedIndex == -1)
1677 rgbEnabled[2] = channelBoxB.SelectedIndex > 0;
1678 if (rgbEnabled[2])
SelectedImage.rgbChannels[2] = channelBoxB.SelectedIndex - 1;
1689 private void showControlsToolStripMenuItem_Click(
object sender, EventArgs e)
1697 private void playZToolStripMenuItem_Click(
object sender, EventArgs e)
1699 if (playZToolStripMenuItem.Checked)
1702 playZToolStripMenuItem.Checked =
false;
1703 stopZToolStripMenuItem.Checked =
true;
1709 playZToolStripMenuItem.Checked =
true;
1710 stopZToolStripMenuItem.Checked =
false;
1718 private void stopZToolStripMenuItem_Click(
object sender, EventArgs e)
1720 if (stopZToolStripMenuItem.Checked)
1723 playZToolStripMenuItem.Checked =
true;
1724 stopZToolStripMenuItem.Checked =
false;
1731 playZToolStripMenuItem.Checked =
false;
1732 stopZToolStripMenuItem.Checked =
true;
1740 private void playTimeToolStripMenu_Click(
object sender, EventArgs e)
1742 if (playTimeToolStripMenu.Checked)
1745 playTimeToolStripMenu.Checked =
false;
1746 stopTimeToolStripMenu.Checked =
true;
1747 timelineTimer.Stop();
1752 playTimeToolStripMenu.Checked =
true;
1753 stopTimeToolStripMenu.Checked =
false;
1754 timelineTimer.Start();
1762 private void stopTimeToolStripMenu_Click(
object sender, EventArgs e)
1764 playTimeToolStripMenu.Checked =
false;
1765 stopTimeToolStripMenu.Checked =
true;
1766 timelineTimer.Stop();
1772 private void playCToolStripMenuItem_Click(
object sender, EventArgs e)
1774 if (playCToolStripMenuItem.Checked)
1777 playCToolStripMenuItem.Checked =
false;
1778 stopCToolStripMenuItem.Checked =
true;
1784 playCToolStripMenuItem.Checked =
true;
1785 stopCToolStripMenuItem.Checked =
false;
1794 private void stopCToolStripMenuItem_Click(
object sender, EventArgs e)
1796 stopCToolStripMenuItem.Checked =
false;
1797 playCToolStripMenuItem.Checked =
true;
1800 private string mousePoint =
"";
1801 private string mouseColor =
"";
1808 private void playSpeedToolStripMenuItem_Click(
object sender, EventArgs e)
1810 PlaySpeed sp =
null;
1815 if (sp.ShowDialog() != DialogResult.OK)
1817 zTimer.Interval = sp.TimePlayspeed;
1818 cTimer.Interval = sp.CPlayspeed;
1819 timelineTimer.Interval = sp.TimePlayspeed;
1827 private void playSpeedToolStripMenuItem1_Click(
object sender, EventArgs e)
1829 PlaySpeed sp =
null;
1834 if (sp.ShowDialog() != DialogResult.OK)
1836 zTimer.Interval = sp.TimePlayspeed;
1837 cTimer.Interval = sp.CPlayspeed;
1838 timelineTimer.Interval = sp.TimePlayspeed;
1847 private void CPlaySpeedToolStripMenuItem_Click(
object sender, EventArgs e)
1849 PlaySpeed sp =
null;
1854 if (sp.ShowDialog() != DialogResult.OK)
1856 zTimer.Interval = sp.TimePlayspeed;
1857 cTimer.Interval = sp.CPlayspeed;
1858 timelineTimer.Interval = sp.TimePlayspeed;
1883 t =
new RangeTool(timeEnabled,
true, zBar.Minimum, zBar.Maximum, tBar.Minimum, tBar.Maximum, cBar.Minimum, cBar.Maximum);
1885 t =
new RangeTool(timeEnabled,
false, zBar.Minimum, zBar.Maximum, tBar.Minimum, tBar.Maximum, cBar.Minimum, cBar.Maximum);
1886 if (t.ShowDialog() != DialogResult.OK)
1888 zBar.Minimum = t.
ZMin;
1889 zBar.Maximum = t.
ZMax;
1892 cBar.Minimum = t.
CMin;
1893 cBar.Maximum = t.
CMax;
1895 private void setValueRangeToolStripMenuItem_Click(
object sender, EventArgs e)
1899 private void setValueRangeToolStripMenuItem1_Click(
object sender, EventArgs e)
1903 private void setCValueRangeToolStripMenuItem_Click(
object sender, EventArgs e)
1911 private void ImageView_MouseWheel(
object sender, System.Windows.Forms.MouseEventArgs e)
1913 if (e is HandledMouseEventArgs handled && handled.Handled)
1915 var source = sender as System.Windows.Forms.Control ??
this;
1916 System.Drawing.Point cursor = source.Parent == viewpanel
1917 ?
new System.Drawing.Point(source.Left + e.X, source.Top + e.Y)
1918 : viewpanel.PointToClient(source.PointToScreen(e.Location));
1919 if (e.Delta == 0 || !viewpanel.ClientRectangle.Contains(cursor) ||
Images.Count == 0)
1923 Plugins.ScrollEvent(sender, e);
1924 if (e is HandledMouseEventArgs wheel)
1929 wheel.Handled =
true;
1932 const double minZoom = 0.000001;
1933 const double maxZoom = 1000000;
1934 double factor = Math.Pow(1.2, e.Delta / 120.0);
1942 Tools.selectBoxSize = (float)(ROI.selectBoxSize *
Resolution);
1948 factor = Math.Clamp(factor,
1949 minZoom / Math.Min(
Scale.Width,
Scale.Height),
1950 maxZoom / Math.Max(
Scale.Width,
Scale.Height));
1958 private void ZoomPyramidalAt(System.Drawing.Point mouseLocation,
double zoomFactor)
1966 double newResolution = oldResolution * zoomFactor;
1967 if (newResolution <= 0 || Math.Abs(newResolution - oldResolution) <
double.Epsilon)
1972 double worldX = oldOriginX + (mouseLocation.X * oldResolution);
1973 double worldY = oldOriginY + (mouseLocation.Y * oldResolution);
1975 SelectedImage.Resolution = newResolution;
1977 var schema = SelectedImage.OpenSlideBase !=
null
1981 double newOriginX = worldX - (mouseLocation.X *
Resolution);
1982 double newOriginY = worldY - (mouseLocation.Y *
Resolution);
1984 double maxX = schema !=
null ? schema.Extent.MaxX : newOriginX;
1985 double maxY = schema !=
null ? -schema.Extent.MinY : newOriginY;
1988 Math.Max(0, Math.Min(newOriginX, maxX)),
1989 Math.Max(0, Math.Min(newOriginY, maxY)));
1999 private void ZTrackBar_MouseWheel(
object sender, System.Windows.Forms.MouseEventArgs e)
2003 if (zBar.Value + 1 <= zBar.Maximum)
2008 if (zBar.Value - 1 >= zBar.Minimum)
2020 private void TimeTrackBar_MouseWheel(
object sender, System.Windows.Forms.MouseEventArgs e)
2026 if (tBar.Value + 1 <= tBar.Maximum)
2031 if (tBar.Value - 1 >= tBar.Minimum)
2040 private void CTrackBar_MouseWheel(
object sender, System.Windows.Forms.MouseEventArgs e)
2044 if (cBar.Value + 1 <= cBar.Maximum)
2049 if (cBar.Value - 1 >= cBar.Minimum)
2060 private void cTimer_Tick(
object sender, EventArgs e)
2062 if (playCToolStripMenuItem.Checked)
2064 if (cBar.Maximum >= cBar.Value + 1)
2069 cBar.Value = cBar.Minimum;
2079 private void zTimer_Tick(
object sender, EventArgs e)
2081 if (playZToolStripMenuItem.Checked)
2083 if (zBar.Maximum >= zBar.Value + 1)
2088 zBar.Value = zBar.Minimum;
2099 private void timer_Tick(
object sender, EventArgs e)
2101 if (playTimeToolStripMenu.Checked)
2103 if (tBar.Maximum >= tBar.Value + 1)
2108 tBar.Value = tBar.Minimum;
2119 private void zBar_ValueChanged(
object sender, EventArgs e)
2133 private void timeBar_ValueChanged(
object sender, EventArgs e)
2148 private void cBar_ValueChanged(
object sender, EventArgs e)
2157 private void loopTimeToolStripMenuItem_Click(
object sender, EventArgs e)
2159 loopT = loopTimeToolStripMenuItem.Checked;
2161 private void loopZToolStripMenuItem_Click(
object sender, EventArgs e)
2163 loopZ = loopZToolStripMenuItem.Checked;
2165 private void loopCToolStripMenuItem_Click(
object sender, EventArgs e)
2167 loopC = loopCToolStripMenuItem.Checked;
2174 private List<ROI> annotationsR =
new List<ROI>();
2180 return new List<ROI>();
2185 (an.type == ROI.Type.Polygon || an.type == ROI.Type.Freeform || an.type == ROI.Type.Polyline || an.coord.C ==
RChannel.Index)).ToList();
2188 private List<ROI> annotationsG =
new List<ROI>();
2194 return new List<ROI>();
2199 (an.type == ROI.Type.Polygon || an.type == ROI.Type.Freeform || an.type == ROI.Type.Polyline || an.coord.C ==
GChannel.Index)).ToList();
2202 private List<ROI> annotationsB =
new List<ROI>();
2208 return new List<ROI>();
2213 (an.type == ROI.Type.Polygon || an.type == ROI.Type.Freeform || an.type == ROI.Type.Polyline || an.coord.C ==
BChannel.Index)).ToList();
2222 List<ROI> ans =
new List<ROI>();
2238 (an.type == ROI.Type.Polygon || an.type == ROI.Type.Freeform || an.type == ROI.Type.Polyline || an.coord.C ==
SelectedImage.Coordinate.C)));
2243 private System.Drawing.Point ToPoint(AForge.Point p)
2245 return new System.Drawing.Point((
int)p.X, (
int)p.Y);
2247 private System.Drawing.PointF ToPointF(
PointD p)
2249 return new System.Drawing.PointF((
float)p.X, (
float)p.Y);
2256 private void DrawOverlay(System.Drawing.Graphics g)
2260 System.Drawing.Pen pen =
null;
2261 System.Drawing.Pen red =
null;
2262 System.Drawing.Pen green =
null;
2263 System.Drawing.Pen mag =
null;
2264 System.Drawing.Pen blue =
null;
2271 if (!IsLayerEnabled(bi.PhysicalSizeX) && !bi.isPyramidal)
2273 foreach (ROI an
in bi.Annotations)
2275 if (an.type == ROI.Type.Polygon || an.type == ROI.Type.Freeform || an.type == ROI.Type.Polyline)
2277 if (zBar.Value != an.coord.Z || tBar.Value != an.coord.T)
2289 else if (zBar.Value != an.coord.Z || cBar.Value != an.coord.C || tBar.Value != an.coord.T)
2291 float w = Math.Abs(
Scale.Width);
2292 pen =
new System.Drawing.Pen(
new SolidBrush(System.Drawing.Color.FromArgb(an.strokeColor.R, an.strokeColor.G, an.strokeColor.B)), (
float)an.strokeWidth / w);
2293 red =
new System.Drawing.Pen(Brushes.Red, (
float)an.strokeWidth / w);
2294 mag =
new System.Drawing.Pen(Brushes.Magenta, (
float)an.strokeWidth / w);
2295 green =
new System.Drawing.Pen(Brushes.Green, (
float)an.strokeWidth / w);
2296 blue =
new System.Drawing.Pen(Brushes.Blue, (
float)an.strokeWidth / w);
2297 Font fo =
new Font(an.family, (
float)(an.strokeWidth / w) * an.fontSize);
2300 b =
new SolidBrush(System.Drawing.Color.Magenta);
2303 b =
new SolidBrush(System.Drawing.Color.FromArgb(an.strokeColor.R, an.strokeColor.G, an.strokeColor.B));
2304 PointF pc =
new PointF((
float)(an.BoundingBox.X + (an.BoundingBox.W / 2)), (
float)(an.BoundingBox.Y + (an.BoundingBox.H / 2)));
2305 float width = (float)ToViewSizeW(ROI.selectBoxSize / w);
2308 width = (float)(ROI.selectBoxSize *
Resolution);
2310 if (an.type == ROI.Type.Point)
2313 g.FillEllipse(b, (
float)pt.X - 2f, (
float)pt.Y - 2f, 4f, 4f);
2314 foreach (var item
in ToScreenSpace(an.GetSelectBoxes(Tools.selectBoxSize)))
2316 g.DrawRectangle(red,
new System.Drawing.RectangleF((
float)item.X, (
float)item.Y, (
float)item.W, (
float)item.H));
2320 if (an.type == ROI.Type.Line)
2323 foreach (var item
in ToScreenSpace(an.GetSelectBoxes(Tools.selectBoxSize)))
2325 g.DrawRectangle(red,
new System.Drawing.RectangleF((
float)item.X, (
float)item.Y, (
float)item.W, (
float)item.H));
2329 if (an.type == ROI.Type.Rectangle && an.BoundingBox.W > 0 && an.BoundingBox.H > 0)
2332 g.DrawRectangle(pen,
new System.Drawing.RectangleF((
float)rec.X, (
float)rec.Y, (
float)rec.W, (
float)rec.H));
2333 foreach (var item
in ToScreenSpace(an.GetSelectBoxes(Tools.selectBoxSize)))
2335 g.DrawRectangle(red,
new System.Drawing.RectangleF((
float)item.X, (
float)item.Y, (
float)item.W, (
float)item.H));
2339 if (an.type == ROI.Type.Ellipse)
2342 g.DrawEllipse(pen, (
float)rec.X, (
float)rec.Y, (
float)rec.W, (
float)rec.H);
2343 foreach (var item
in ToScreenSpace(an.GetSelectBoxes(Tools.selectBoxSize)))
2345 g.DrawRectangle(red,
new System.Drawing.RectangleF((
float)item.X, (
float)item.Y, (
float)item.W, (
float)item.H));
2349 if (an.type == ROI.Type.Polygon && an.closed)
2351 if (an.Points.Count > 1)
2353 System.Drawing.PointF[] pts =
new System.Drawing.PointF[an.Points.Count];
2354 for (
int i = 0; i < an.Points.Count; i++)
2357 pts[i] =
new System.Drawing.PointF((
float)p.X, (
float)p.Y);
2359 g.DrawLines(pen, pts);
2360 g.DrawLine(pen, pts[pts.Length - 1], pts[0]);
2362 foreach (var item
in ToScreenSpace(an.GetSelectBoxes(Tools.selectBoxSize)))
2364 g.DrawRectangle(red,
new System.Drawing.RectangleF((
float)item.X, (
float)item.Y, (
float)item.W, (
float)item.H));
2368 if (an.type == ROI.Type.Polygon && !an.closed)
2370 if (an.Points.Count > 1)
2372 System.Drawing.PointF[] pts =
new System.Drawing.PointF[an.Points.Count];
2373 for (
int i = 0; i < an.Points.Count; i++)
2376 pts[i] =
new System.Drawing.PointF((
float)p.X, (
float)p.Y);
2378 g.DrawLines(pen, pts);
2380 foreach (var item
in ToScreenSpace(an.GetSelectBoxes(Tools.selectBoxSize)))
2382 g.DrawRectangle(red,
new System.Drawing.RectangleF((
float)item.X, (
float)item.Y, (
float)item.W, (
float)item.H));
2386 if (an.type == ROI.Type.Polyline)
2388 if (an.Points.Count > 1)
2390 System.Drawing.PointF[] pts =
new System.Drawing.PointF[an.Points.Count];
2391 for (
int i = 0; i < an.Points.Count; i++)
2394 pts[i] =
new System.Drawing.PointF((
float)p.X, (
float)p.Y);
2396 g.DrawLines(pen, pts);
2398 foreach (var item
in ToScreenSpace(an.GetSelectBoxes(Tools.selectBoxSize)))
2400 g.DrawRectangle(red,
new System.Drawing.RectangleF((
float)item.X, (
float)item.Y, (
float)item.W, (
float)item.H));
2405 if (an.type == ROI.Type.Freeform && an.closed)
2407 if (an.Points.Count > 1)
2409 System.Drawing.PointF[] pts =
new System.Drawing.PointF[an.Points.Count];
2410 for (
int i = 0; i < an.Points.Count; i++)
2413 pts[i] =
new System.Drawing.PointF((
float)p.X, (
float)p.Y);
2415 g.DrawLines(pen, pts);
2416 g.DrawLine(pen, pts[pts.Length - 1], pts[0]);
2420 foreach (var item
in ToScreenSpace(an.GetSelectBoxes(Tools.selectBoxSize)))
2422 g.DrawRectangle(red,
new System.Drawing.RectangleF((
float)item.X, (
float)item.Y, (
float)item.W, (
float)item.H));
2427 if (an.type == ROI.Type.Freeform && !an.closed)
2429 if (an.Points.Count > 1)
2431 System.Drawing.PointF[] pts =
new System.Drawing.PointF[an.Points.Count];
2432 for (
int i = 0; i < an.Points.Count; i++)
2435 pts[i] =
new System.Drawing.PointF((
float)p.X, (
float)p.Y);
2437 g.DrawLines(pen, pts);
2441 foreach (var item
in ToScreenSpace(an.GetSelectBoxes(Tools.selectBoxSize)))
2443 g.DrawRectangle(red,
new System.Drawing.RectangleF((
float)item.X, (
float)item.Y, (
float)item.W, (
float)item.H));
2447 if (an.type == ROI.Type.Label)
2449 System.Drawing.RectangleF rec = GetLabelScreenRect(an);
2450 using Font labelFont = GetScaledLabelFont(an, w);
2451 System.Drawing.Size textSize = System.Windows.Forms.TextRenderer.MeasureText(an.Text ??
string.Empty, labelFont);
2452 float tx = rec.X + ((rec.Width - textSize.Width) / 2f);
2453 float ty = rec.Y + ((rec.Height - textSize.Height) / 2f);
2454 g.DrawString(an.Text ??
string.Empty, labelFont, b, tx, ty);
2455 g.DrawRectangle(red, rec.X, rec.Y, rec.Width, rec.Height);
2459 if (an.type == ROI.Type.Label)
2461 System.Drawing.SizeF s = System.Windows.Forms.TextRenderer.MeasureText(an.Text,
new Font(an.family, an.fontSize));
2463 float fw = ((float)an.BoundingBox.X + ((float)an.BoundingBox.W / 2)) - ((
float)s.Width / 2);
2464 float fh = ((float)an.BoundingBox.Y + ((float)an.BoundingBox.H / 2)) - ((
float)s.Height / 2);
2466 g.DrawString(an.Text, fo, b, v.X, v.Y);
2470 if (an.type == ROI.Type.Point)
2473 g.FillEllipse(Brushes.Green, (
float)pv.X - 2f, (
float)pv.Y - 2f, 4f, 4f);
2475 else if (an.type == ROI.Type.Label)
2477 System.Drawing.RectangleF rec = GetLabelScreenRect(an);
2478 g.DrawRectangle(green, rec.X, rec.Y, rec.Width, rec.Height);
2483 g.DrawRectangles(green,
new System.Drawing.RectangleF[1] { new System.Drawing.RectangleF((float)rb.X, (float)rb.Y, (float)rb.W, (float)rb.H) });
2488 if (an.type == ROI.Type.Point)
2491 g.FillEllipse(Brushes.Magenta, (
float)pv.X - 2f, (
float)pv.Y - 2f, 4f, 4f);
2494 else if (an.type == ROI.Type.Label)
2496 System.Drawing.RectangleF rec = GetLabelScreenRect(an);
2497 g.DrawRectangle(mag, rec.X, rec.Y, rec.Width, rec.Height);
2503 g.DrawRectangles(mag,
new System.Drawing.RectangleF[1] { new System.Drawing.RectangleF((float)rb.X, (float)rb.Y, (float)rb.W, (float)rb.H) });
2505 List<RectangleD> rects =
new List<RectangleD>();
2506 RectangleD[] sels = an.GetSelectBoxes(Tools.selectBoxSize);
2507 for (
int i = 0; i < an.selectedPoints.Count; i++)
2509 if (an.selectedPoints[i] < an.GetPointCount())
2511 rects.Add(sels[an.selectedPoints[i]]);
2514 for (
int i = 0; i < rects.Count; i++)
2517 g.DrawRectangle(blue,
new System.Drawing.RectangleF((
float)va[0].X, (
float)va[0].Y, (
float)va[0].W, (
float)va[0].H));
2522 if (an.type == ROI.Type.Label)
2524 System.Drawing.Size s = System.Windows.Forms.TextRenderer.MeasureText(an.Text,
new Font(an.family, an.fontSize));
2525 float fw = ((float)an.BoundingBox.X + ((float)an.BoundingBox.W / 2)) - ((
float)s.Width / 2);
2526 float fh = ((float)an.BoundingBox.Y + ((float)an.BoundingBox.H / 2)) - ((
float)s.Height / 2);
2528 g.DrawString(an.Text, fo, b, vv.X, vv.Y);
2530 if (Tools.currentTool !=
null && Tools.currentTool.type == Tools.Tool.Type.rectSel)
2532 RectangleD sel = Tools.currentTool.Rectangle;
2533 if (sel.W != 0 || sel.H != 0)
2535 double x = Math.Min(sel.X, sel.X + sel.W);
2536 double y = Math.Min(sel.Y, sel.Y + sel.H);
2537 double selW = Math.Abs(sel.W);
2538 double selH = Math.Abs(sel.H);
2541 g.DrawRectangle(blue,
new System.Drawing.RectangleF((
float)rec.X, (
float)rec.Y, (
float)rec.W, (
float)rec.H));
2557 AForge.SizeF dSize =
new AForge.SizeF(1, 1);
2575 if (
Scale.Width == 0 ||
float.IsInfinity(
Scale.Width))
2578 if (Bitmaps.Count == 0)
2580 System.Drawing.RectangleF[] rf =
new System.Drawing.RectangleF[1];
2581 System.Drawing.Pen blue =
new System.Drawing.Pen(Brushes.Blue, 1 /
Scale.Width);
2585 if (!IsLayerEnabled(im.PhysicalSizeX) && !im.isPyramidal)
2587 RectangleD r =
ToScreenRect(im.Volume.Location.X, im.Volume.Location.Y, im.Volume.Width, im.Volume.Height);
2591 RectangleF rec =
new RectangleF((
float)im.Volume.Location.X, (
float)im.Volume.Location.Y, (
float)im.Volume.Width, (
float)im.Volume.Height);
2594 var tr = g.Transform;
2596 g.DrawImage(Bitmaps[i], 0, 0);
2600 if (rg.IntersectsWith(rec))
2602 g.DrawImage(Bitmaps[i], (
float)r.X, (
float)r.Y, (
float)r.W, (
float)r.H);
2606 rf[0] =
new System.Drawing.RectangleF((
float)r.X, (
float)r.Y, (
float)r.W, (
float)r.H);
2607 g.DrawRectangles(blue, rf);
2616 System.Drawing.Pen red =
new System.Drawing.Pen(Brushes.Red, 1 /
Scale.Width);
2617 g.DrawRectangle(red, v[0].X, v[0].Y, v[0].Width, v[0].Height);
2625 Console.WriteLine(e.Message);
2632 private void pictureBox_Paint(
object sender, PaintEventArgs e)
2636 BringRenderSurfacesToFront();
2642 private void Viewpanel_Paint(
object sender, PaintEventArgs e)
2651 DrawOverlay(e.Graphics);
2665 return GetSelectBoxSizeForScreenPixels(MinSelectionHitScreenSize);
2667 private System.Drawing.Bitmap ToSysBitmap(
Bitmap bm)
2671 if (bm.PixelFormat == AForge.PixelFormat.Format16bppGrayScale)
2673 var grayResult =
new System.Drawing.Bitmap(
2676 System.Drawing.Imaging.PixelFormat.Format24bppRgb);
2677 int min =
int.MaxValue;
2678 int max =
int.MinValue;
2679 for (
int y = 0; y < bm.Height; y++)
2681 for (
int x = 0; x < bm.Width; x++)
2683 int value = (int)bm.GetValue(x, y, 0);
2693 var grayRect =
new System.Drawing.Rectangle(0, 0, bm.Width, bm.Height);
2694 var grayData = grayResult.LockBits(grayRect, System.Drawing.Imaging.ImageLockMode.WriteOnly, System.Drawing.Imaging.PixelFormat.Format24bppRgb);
2697 int dstStride = Math.Abs(grayData.Stride);
2700 for (
int y = 0; y < bm.Height; y++)
2702 byte* dstRow = (
byte*)grayData.Scan0 + (y * dstStride);
2703 for (
int x = 0; x < bm.Width; x++)
2705 byte value = (byte)(((
int)bm.GetValue(x, y, 0) - min) * 255 / (max - min));
2707 dstRow[offset] = value;
2708 dstRow[offset + 1] = value;
2709 dstRow[offset + 2] = value;
2716 grayResult.UnlockBits(grayData);
2722 var rgba = bm.GetImageRGBA();
2723 var result =
new System.Drawing.Bitmap(
2726 System.Drawing.Imaging.PixelFormat.Format32bppArgb);
2728 var rect =
new System.Drawing.Rectangle(0, 0, bm.Width, bm.Height);
2729 var data = result.LockBits(rect, System.Drawing.Imaging.ImageLockMode.WriteOnly, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
2732 int bytes = bm.Width * bm.Height * 4;
2733 byte[] buffer =
new byte[bytes];
2734 Marshal.Copy(rgba.Data, buffer, 0, bytes);
2735 Marshal.Copy(buffer, 0, data.Scan0, bytes);
2739 result.UnlockBits(data);
2753 private void UpdateMouseStatus(
PointD p)
2758 PointD displayPoint = GetStatusPoint(p);
2759 PointD samplePoint = SelectedImage.isPyramidal
2763 mousePoint =
"(" + (int)displayPoint.X +
", " + (
int)displayPoint.Y +
")";
2766 AForge.Point s = SelectedImage.isPyramidal
2771 if (samplePoint.X < 0 || samplePoint.Y < 0 || samplePoint.X >= s.X || samplePoint.Y >= s.Y)
2785 int sx = (int)Math.Floor(samplePoint.X);
2786 int sy = (int)Math.Floor(samplePoint.Y);
2790 if (raw !=
null && raw.Length >= 2)
2792 ushort value = (ushort)(raw[0] | (raw[1] << 8));
2793 mouseColor =
", " + value;
2808 int sx = (int)Math.Floor(samplePoint.X);
2809 int sy = (int)Math.Floor(samplePoint.Y);
2813 if (rawTile !=
null)
2815 switch (rawTile.PixelFormat)
2817 case AForge.PixelFormat.Format8bppIndexed:
2818 mouseColor =
", " + (int)rawTile.GetValue(0, 0, 0);
2820 case AForge.PixelFormat.Format16bppGrayScale:
2821 mouseColor =
", " + (int)rawTile.GetValue(0, 0, 0);
2823 case AForge.PixelFormat.Format24bppRgb:
2824 case AForge.PixelFormat.Format32bppArgb:
2825 case AForge.PixelFormat.Format32bppRgb:
2826 case AForge.PixelFormat.Format32bppPArgb:
2828 int b = (int)rawTile.GetValue(0, 0, 0);
2829 int g = (int)rawTile.GetValue(0, 0, 1);
2830 int r = (int)rawTile.GetValue(0, 0, 2);
2831 mouseColor =
", " + r +
"," + g +
"," + b;
2834 case AForge.PixelFormat.Format48bppRgb:
2836 int b = (int)rawTile.GetValue(0, 0, 0);
2837 int g = (int)rawTile.GetValue(0, 0, 1);
2838 int r = (int)rawTile.GetValue(0, 0, 2);
2839 mouseColor =
", " + r +
"," + g +
"," + b;
2852 int r = (int)
SelectedImage.GetValueRGB(zc,
RChannel.Index, tc, (
int)samplePoint.X, (
int)samplePoint.Y, 0);
2853 int g = (int)
SelectedImage.GetValueRGB(zc,
GChannel.Index, tc, (
int)samplePoint.X, (
int)samplePoint.Y, 1);
2854 int b = (int)
SelectedImage.GetValueRGB(zc,
BChannel.Index, tc, (
int)samplePoint.X, (
int)samplePoint.Y, 2);
2855 mouseColor =
", " + r +
"," + g +
"," + b;
2859 int r = (int)
SelectedImage.GetValueRGB(zc, 0, tc, (
int)samplePoint.X, (
int)samplePoint.Y, 0);
2860 mouseColor =
", " + r;
2870 private void rgbPictureBox_MouseMove(
object sender, MouseEventArgs e)
2879 UpdateMouseStatus(p);
2880 if (e.Button == MouseButtons.XButton1 && !x1State && !
Ctrl &&
Mode !=
ViewMode.RGBImage)
2882 if (cBar.Value < cBar.Maximum)
2886 else if (e.Button == MouseButtons.XButton1 && !x1State &&
Ctrl)
2888 if (tBar.Value < tBar.Maximum)
2892 if (e.Button != MouseButtons.XButton1)
2895 if (e.Button == MouseButtons.XButton2 && !x2State && !
Ctrl &&
Mode !=
ViewMode.RGBImage)
2897 if (cBar.Value > cBar.Minimum)
2901 else if (e.Button == MouseButtons.XButton2 && !x2State &&
Ctrl)
2903 if (tBar.Value > tBar.Minimum)
2907 if (e.Button != MouseButtons.XButton2)
2910 if (Tools.currentTool.type == Tools.Tool.Type.move && e.Button == MouseButtons.Left)
2914 if (an.selectedPoints.Count > 0 && an.selectedPoints.Count < an.GetPointCount())
2916 if (an.type == ROI.Type.Rectangle || an.type == ROI.Type.Ellipse)
2919 if (an.selectedPoints[0] == 0)
2921 double dw = d.X - p.X;
2922 double dh = d.Y - p.Y;
2929 if (an.selectedPoints[0] == 1)
2931 double dw = p.X - (d.W + d.X);
2932 double dh = d.Y - p.Y;
2938 if (an.selectedPoints[0] == 2)
2940 double dw = d.X - p.X;
2941 double dh = p.Y - (d.Y + d.H);
2947 if (an.selectedPoints[0] == 3)
2949 double dw = d.X - p.X;
2950 double dh = d.Y - p.Y;
2960 for (
int i = 0; i < an.selectedPoints.Count; i++)
2962 PointD poid = an.GetPoint(an.selectedPoints[i]);
2963 an.UpdatePoint(
new PointD(poid.X + pod.X, poid.Y + pod.Y), an.selectedPoints[i]);
2965 an.UpdateBoundingBox();
2971 for (
int i = 0; i < an.GetPointCount(); i++)
2973 PointD poid = an.Points[i];
2974 an.UpdatePoint(
new PointD(poid.X + pod.X, poid.Y + pod.Y), i);
2976 an.UpdateBoundingBox();
2982 if (Tools.currentTool !=
null)
2983 if (Tools.currentTool.type == Tools.Tool.Type.pencil && e.Button == MouseButtons.Left)
2986 Tools.Tool tool = Tools.currentTool;
2988 Graphics.Pen pen =
new Graphics.Pen(Tools.DrawColor, (
int)Tools.StrokeWidth,
ImageView.SelectedImage.bitsPerPixel);
2989 g.FillEllipse(
new Rectangle((
int)pencilIp.X, (
int)pencilIp.Y, (
int)Tools.StrokeWidth, (
int)Tools.StrokeWidth), pen.color);
3003 private void pictureBox_MouseUp(
object sender, MouseEventArgs e)
3023 private void pictureBox_MouseDown(
object sender, MouseEventArgs e)
3030 pd =
new PointD(p.X, p.Y);
3032 mouseD =
new PointD(e.Location.X, e.Location.Y);
3037 tools.BringToFront();
3041 RectangleD r =
new RectangleD(b.Volume.Location.X, b.Volume.Location.Y, b.Volume.Width, b.Volume.Height);
3042 if (r.IntersectsWith(p))
3051 if (!
Ctrl && e.Button == MouseButtons.Left && Tools.currentTool.type != Tools.Tool.Type.rectSel)
3056 item.selectedPoints.Clear();
3061 if (Tools.currentTool.type == Tools.Tool.Type.move && e.Button == MouseButtons.Left)
3067 foreach (ROI an
in bi.Annotations)
3069 if (an.GetSelectBound(width, height).IntersectsWith(
new RectangleD(p.X, p.Y, 1, 1)))
3073 RectangleD[] sels = an.GetSelectBoxes(Tools.selectBoxSize);
3076 for (
int i = 0; i < sels.Length; i++)
3078 if (sels[i].IntersectsWith(r))
3080 an.selectedPoints.Add(i);
3086 an.Selected =
false;
3092 if (e.Button == MouseButtons.Left)
3094 UpdateMouseStatus(p);
3106 private void pictureBox_MouseDoubleClick(
object sender, MouseEventArgs e)
3113 if (e.Button != MouseButtons.XButton1 && e.Button != MouseButtons.XButton2)
3122 private void deleteROIToolStripMenuItem_Click(
object sender, EventArgs e)
3128 if (item.Selected && (item.selectedPoints.Count == 0 || item.selectedPoints.Count == item.GetPointCount() || item.type == ROI.Type.Ellipse || item.type == ROI.Type.Rectangle))
3134 if ((item.type == ROI.Type.Polygon || item.type == ROI.Type.Freeform || item.type == ROI.Type.Polyline) && item.selectedPoints.Count > 0)
3136 item.RemovePoints(item.selectedPoints.ToArray());
3139 item.selectedPoints.Clear();
3150 private void setTextSelectionToolStripMenuItem_Click(
object sender, EventArgs e)
3158 TextInput input =
new TextInput(item.Text);
3159 if (input.ShowDialog() != DialogResult.OK)
3161 item.Text = input.TextValue;
3162 item.family = input.font.FontFamily.Name;
3163 item.fontSize = input.font.Size;
3164 item.strokeColor = AForge.Color.FromArgb(input.color.R, input.color.G, input.color.B);
3174 private void copyViewToClipboardToolStripMenuItem_Click(
object sender, EventArgs e)
3177 using (System.Drawing.Graphics g = System.Drawing.Graphics.FromImage(bmp))
3182 System.Windows.Forms.Clipboard.SetImage(bmp);
3184 List<ROI> copys =
new List<ROI>();
3199 System.Windows.Forms.Clipboard.SetText(s);
3205 string[] sts = System.Windows.Forms.Clipboard.GetText().Split(
BioImage.NewLine);
3206 foreach (
string line
in sts)
3208 if (line.Length > 8)
3210 ROI an =
BioImage.StringToROI(line);
3222 private void copyROIToolStripMenuItem_Click(
object sender, EventArgs e)
3232 private void pasteROIToolStripMenuItem_Click(
object sender, EventArgs e)
3241 private void hideControlsToolStripMenuItem_Click(
object sender, EventArgs e)
3253 private void showControlToolStripMenuItem_Click(
object sender, EventArgs e)
3265 private void HideStatusMenuItem_Click(
object sender, EventArgs e)
3273 private void rGBToolStripMenuItem_Click(
object sender, EventArgs e)
3282 private void filteredToolStripMenuItem_Click(
object sender, EventArgs e)
3291 private void rawToolStripMenuItem_Click(
object sender, EventArgs e)
3320 return new PointF((
float)d.X, (
float)d.Y);
3347 return new PointD(dx, dy);
3354 private double ToViewSizeW(
double d)
3386 double x = (double)(d /
PxWmicron) / scale.Width;
3396 double y = (double)(d /
PxHmicron) / scale.Height;
3413 return new PointD(fx, fy);
3432 return new PointF((
float)pd.X, (
float)pd.Y);
3442 for (
int i = 0; i < p.Length; i++)
3448 private Font GetLabelFont(ROI an)
3450 string family =
string.IsNullOrWhiteSpace(an?.family) ? SystemFonts.DefaultFont.FontFamily.Name : an.family;
3451 float size = an !=
null && an.fontSize > 0 ? an.fontSize : SystemFonts.DefaultFont.Size;
3454 return new Font(family, size);
3458 return new Font(SystemFonts.DefaultFont.FontFamily, SystemFonts.DefaultFont.Size);
3461 private Font GetScaledLabelFont(ROI an,
float zoomScale)
3463 string family =
string.IsNullOrWhiteSpace(an?.family) ? SystemFonts.DefaultFont.FontFamily.Name : an.family;
3464 float baseSize = an !=
null && an.fontSize > 0 ? an.fontSize : SystemFonts.DefaultFont.Size;
3465 float scale = Math.Max(0.0001f, zoomScale);
3468 return new Font(family, baseSize / scale);
3472 return new Font(SystemFonts.DefaultFont.FontFamily, SystemFonts.DefaultFont.Size / scale);
3475 private System.Drawing.RectangleF GetLabelScreenRect(ROI an)
3478 return System.Drawing.RectangleF.Empty;
3480 return new System.Drawing.RectangleF((
float)rect.X, (
float)rect.Y, (
float)rect.W, (
float)rect.H);
3490 return new PointF((
float)pd.X, (
float)pd.Y);
3540 double dw = ToViewSizeW(w);
3559 public SKRect
ToSKRect(
double x,
double y,
double w,
double h)
3561 double xd = gl.Width / 2;
3562 double yd = gl.Height / 2;
3563 return new SKRect((
float)(xd - x), (
float)(yd - y), (
float)(xd - (x + w)), (
float)(yd - (y + h)));
3591 for (
int i = 0; i < p.Length; i++)
3605 for (
int i = 0; i < p.Length; i++)
3619 for (
int i = 0; i < p.Length; i++)
3622 rs[i] =
new PointF((
float)pd.X, (
float)pd.Y);
3653 double moveAmount = 5 *
Scale.Width;
3655 if (e.KeyCode ==
Keys.C && e.Control)
3660 if (e.KeyCode ==
Keys.V && e.Control)
3665 if (e.KeyCode ==
Keys.Subtract || e.KeyCode ==
Keys.NumPad7)
3674 if (e.KeyCode ==
Keys.Add || e.KeyCode ==
Keys.NumPad9)
3683 if (e.KeyCode ==
Keys.W || e.KeyCode ==
Keys.NumPad8)
3691 if (e.KeyCode ==
Keys.S || e.KeyCode ==
Keys.NumPad2)
3699 if (e.KeyCode ==
Keys.A || e.KeyCode ==
Keys.NumPad4)
3707 if (e.KeyCode ==
Keys.D || e.KeyCode ==
Keys.NumPad6)
3716 private void ImageView_KeyUp(
object sender, KeyEventArgs e)
3720 private void ImageView_KeyPress(
object sender, System.Windows.Forms.KeyPressEventArgs e)
3722 Plugins.KeyPressEvent(sender, e);
3732 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
3743 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
3746 get {
return mouseDownInt; }
3747 set { mouseDownInt = value; }
3749 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
3752 get {
return mouseUpInt; }
3753 set { mouseUpInt = value; }
3755 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
3758 get {
return mouseMoveInt; }
3759 set { mouseMoveInt = value; }
3762 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
3772 if (i < 0 ||
Images.Count <= i)
3778 int viewportWidth = GetEffectiveViewWidth();
3779 int viewportHeight = GetEffectiveViewHeight();
3780 if (UsesSlideRenderer(image))
3782 CenterPyramidalImage(image, viewportWidth, viewportHeight);
3787 double dx = image.Volume.Width / 2;
3788 double dy = image.Volume.Height / 2;
3789 origin =
new PointD(-(image.Volume.Location.X + dx), -(image.Volume.Location.Y + dy));
3790 double screenWidth = Math.Abs(
ToScreenScaleW(image.Volume.Width));
3791 double screenHeight = Math.Abs(
ToScreenScaleH(image.Volume.Height));
3792 double wx = screenWidth > 0 ? viewportWidth / screenWidth : 1;
3793 double wy = screenHeight > 0 ? viewportHeight / screenHeight : 1;
3794 double fitScale = Math.Min(wx, wy);
3795 if (fitScale <= 0 ||
double.IsNaN(fitScale) ||
double.IsInfinity(fitScale))
3797 scale =
new SizeF((
float)fitScale, (
float)fitScale);
3802 private int GetEffectiveViewWidth()
3806 width = viewpanel?.ClientSize.Width ?? Width;
3809 return Math.Max(1, width);
3812 private int GetEffectiveViewHeight()
3816 height = viewpanel?.ClientSize.Height ?? Height;
3819 return Math.Max(1, height);
3822 private void CenterPyramidalImage(
BioImage image,
int viewportWidth,
int viewportHeight)
3824 if (!TryGetPyramidalWorldBounds(image, out
double minX, out
double minY, out
double maxX, out
double maxY))
3827 double worldWidth = maxX - minX;
3828 double worldHeight = maxY - minY;
3829 if (worldWidth <= 0 || worldHeight <= 0)
3832 double fitResolution = Math.Max(worldWidth / viewportWidth, worldHeight / viewportHeight) * 1.02;
3833 if (fitResolution <= 0 ||
double.IsNaN(fitResolution) ||
double.IsInfinity(fitResolution))
3834 fitResolution = image.Resolution > 0 ? image.Resolution : 1;
3836 image.Resolution = fitResolution;
3837 double viewportWorldWidth = viewportWidth * fitResolution;
3838 double viewportWorldHeight = viewportHeight * fitResolution;
3839 double centerX = minX + (worldWidth / 2);
3840 double centerY = minY + (worldHeight / 2);
3842 image.PyramidalOrigin =
new PointD(
3843 centerX - (viewportWorldWidth / 2),
3844 -(centerY + (viewportWorldHeight / 2)));
3847 private void CenterPyramidalOrigin(
BioImage image,
int viewportWidth,
int viewportHeight)
3849 if (viewportWidth <= 1 || viewportHeight <= 1)
3851 if (!TryGetPyramidalWorldBounds(image, out
double minX, out
double minY, out
double maxX, out
double maxY))
3854 double worldWidth = maxX - minX;
3855 double worldHeight = maxY - minY;
3856 if (worldWidth <= 0 || worldHeight <= 0)
3859 double visibleWidth = viewportWidth * Math.Max(image.Resolution, 1e-9);
3860 double visibleHeight = viewportHeight * Math.Max(image.Resolution, 1e-9);
3861 double centerX = minX + (worldWidth / 2.0);
3862 double centerY = minY + (worldHeight / 2.0);
3864 image.PyramidalOrigin =
new PointD(
3865 centerX - (visibleWidth / 2.0),
3866 -(centerY + (visibleHeight / 2.0)));
3869 private bool TryGetPyramidalWorldBounds(
BioImage image, out
double minX, out
double minY, out
double maxX, out
double maxY)
3871 minX = minY = maxX = maxY = 0;
3872 BruTile.ITileSchema schema =
null;
3873 if (image.OpenSlideBase !=
null)
3874 schema = image.OpenSlideBase.Schema;
3875 else if (image.SlideBase !=
null)
3876 schema = image.SlideBase.Schema;
3880 minX = schema.Extent.MinX;
3881 minY = schema.Extent.MinY;
3882 maxX = schema.Extent.MaxX;
3883 maxY = schema.Extent.MaxY;
3884 return maxX > minX && maxY > minY;
3887 if (image.Resolutions.Count == 0)
3890 double unitsPerPixel = image.GetUnitPerPixel(0);
3891 if (unitsPerPixel <= 0 ||
double.IsNaN(unitsPerPixel) ||
double.IsInfinity(unitsPerPixel))
3895 maxX = image.Resolutions[0].SizeX * unitsPerPixel;
3897 minY = -(image.Resolutions[0].SizeY * unitsPerPixel);
3898 return maxX > minX && maxY > minY;
3905 private void goToImageToolStripMenuItem_Click(
object sender, EventArgs e)
3914 private void goToToolStripMenuItem1_Click(
object sender, EventArgs e)
3923 private void goToImageToolStripMenuItem_DropDownOpening(
object sender, EventArgs e)
3925 ToolStripMenuItem item = (ToolStripMenuItem)sender;
3926 item.DropDownItems.Clear();
3927 for (
int i = 0; i <
Images.Count; i++)
3930 ToolStripMenuItem it =
new ToolStripMenuItem();
3931 it.Text = $
"{i}: {im.filename}";
3933 item.DropDownItems.Add(it);
3943 private void goToImageToolStripMenuItem_DropDownItemClicked(
object sender, ToolStripItemClickedEventArgs e)
3945 if (e.ClickedItem.Tag is
int index && index >= 0 && index <
Images.Count)
3953 foreach (var bitmap
in Bitmaps)
3964 private void goToToolStripMenuItem_Click_1(
object sender, EventArgs e)
3973 private void drawToolStripMenuItem_Click(
object sender, EventArgs e)
3982 if (item.type == ROI.Type.Point)
3985 g.FillEllipse(
new RectangleF((
float)pt.X - 2f, (
float)pt.Y - 2f, 4f, 4f), p.color);
3988 if (item.type == ROI.Type.Line)
3993 if (item.type == ROI.Type.Rectangle)
3995 g.DrawRectangle(
SelectedImage.ToImageSpace(item.BoundingBox));
3998 if (item.type == ROI.Type.Ellipse)
4000 g.DrawEllipse(
SelectedImage.ToImageSpace(item.BoundingBox));
4003 if (item.type == ROI.Type.Freeform || item.type == ROI.Type.Polygon || item.type == ROI.Type.Polyline)
4007 for (
int i = 0; i < item.GetPointCount() - 1; i++)
4016 for (
int i = 0; i < item.GetPointCount() - 1; i++)
4032 private void fillToolStripMenuItem_Click(
object sender, EventArgs e)
4040 if (item.type == ROI.Type.Point)
4043 g.FillEllipse(
new RectangleF((
float)pt.X - 2f, (
float)pt.Y - 2f, 4f, 4f), p.color);
4046 if (item.type == ROI.Type.Line)
4051 if (item.type == ROI.Type.Rectangle)
4053 g.FillRectangle(
SelectedImage.ToImageSpace(item.BoundingBox), p.color);
4056 if (item.type == ROI.Type.Ellipse)
4058 g.FillEllipse(
SelectedImage.ToImageSpace(item.BoundingBox), p.color);
4061 if (item.type == ROI.Type.Freeform || item.type == ROI.Type.Polygon || item.type == ROI.Type.Polyline)
4074 double dx = d.W / 2;
4075 double dy = d.H / 2;
4080 scale.Width = (float)wy;
4081 scale.Height = (float)wy;
4110 private void goToStageToolStripMenuItem_Click(
object sender, EventArgs e)
4121 private void moveStageToImageToolStripMenuItem_DropDownItemClicked(
object sender, ToolStripItemClickedEventArgs e)
4124 foreach (var item
in Images)
4126 if (item.ID.Contains(e.ClickedItem.Text))
4139 private void moveStageToImageToolStripMenuItem_Click(
object sender, EventArgs e)
4143 private void layersToolStripMenuItem_Click(
object sender, EventArgs e)
4145 if (layersTool ==
null)
4146 layersTool =
new Layers();
4153 private void pictureBox_SizeChanged(
object sender, EventArgs e)
4162 private void contextMenuStrip_Opening(
object sender, CancelEventArgs e)
4165 if (App.tabsView !=
null)
4166 Function.Initialize();
4168 private void hideOverviewToolStripMenuItem_Click(
object sender, EventArgs e)
4170 if (hideOverViewToolStripMenuItem.Text ==
"Hide Overview")
4173 hideOverViewToolStripMenuItem.Text =
"Show Overview";
4178 hideOverViewToolStripMenuItem.Text =
"Hide Overview";
4180 UpdateOverviewVisibility();
4182 private void removeImageToolStripMenuItem_Click(
object sender, EventArgs e)
4187 private void removeImagesToolStripMenuItem_Click(
object sender, EventArgs e)
4192 private OpenSlideBase _openSlideBase;
4193 private SlideBase _slideBase;
4198 private void Initialize(
string file,
BioImage bm)
4200 if (bm.Type !=
BioImage.ImageType.pyramidal)
4202 if (bm.OpenSlideBase ==
null)
4204 _slideBase = bm.SlideBase;
4205 slideRenderer =
new SlideRenderer(gl);
4206 slideRenderer.SetSource(_slideBase);
4210 _openSlideBase = bm.OpenSlideBase;
4211 slideRenderer =
new SlideRenderer(gl);
4212 slideRenderer.SetSource(_openSlideBase);
4218 private sealed class BufferedViewPanel : Panel
4220 public BufferedViewPanel()
4222 SetStyle(ControlStyles.UserPaint |
4223 ControlStyles.AllPaintingInWmPaint |
4224 ControlStyles.OptimizedDoubleBuffer |
4225 ControlStyles.ResizeRedraw,
true);
AForge.RectangleD RectangleD
AForge.RectangleF RectangleF
AForge.Rectangle Rectangle
System.Drawing.SizeF SizeF
System.Drawing.Image Image
System.Windows.Forms.Keys Keys
System.Windows.Forms.Application Application
System.Drawing.Graphics Graphics
static ChannelsTool channelsTool
PointD PyramidalOriginTransformed
float ToScreenScaleH(double y)
new AForge.SizeF Scale
Scale when opening image stacks.
List< ROI > AnnotationsRGB
PointD ImageToViewSpace(double x, double y)
bool ShowControls
Setting the visibility of the trackBarPanel. */.
Channel RChannel
A property that returns the R channel of the selected image. */.
float ToScreenH(double y)
PointD Origin
A property of the class PointD. */.
void DrawView(System.Drawing.Graphics g)
Draws the viewport when Hardware Acceleration is off.
PointF[] ToScreenSpace(PointD[] p)
PointF ToScreenScale(PointD p)
PointD PyramidalOrigin
Setting the value of the pyramidalOrigin variable. */.
void SetCoordinate(int z, int c, int t)
void UpdateView(bool refreshImages=true)
PointD ToScreenSpace(double x, double y)
float ToScreenW(double x)
PointD ToViewSpace(PointD p)
RectangleD[] ToScreenSpace(RectangleD[] p)
ImageView(BioImage im, bool OpenWithOpenSlide=true)
Initializing the image viewer. */.
SKRect ToSKRect(double x, double y, double w, double h)
ViewMode Mode
Setting the view mode of the application. */.
double PxHmicron
Only used when opening stacks.
PointF[] ToScreenSpace(PointF[] p)
int TimeFps
Setting the interval of the timer to the value of the timefps variable. */.
int CFps
Setting the interval of the timer to the inverse of the fps. */.
PointF ToViewSpace(PointF p)
PointF ToScreenSpace(PointF p)
RectangleD ToScreenSpace(RectangleD p)
void UpdateSelectBoxSize(float size)
void CopySelection()
It takes the selected ROIs and copies them to the clipboard.
Channel GChannel
A property that returns the G channel of the image. */.
bool ShowStatus
Setting the value of the property ShowStatus. */.
static List< ROI > selectedAnnotations
ImageView()
Initializing the ImageView class. */.
override bool ProcessCmdKey(ref Message msg, Keys keyData)
Channel BChannel
Getting the B channel of the image. */.
string Path
A property that returns the filepath. */.
int ZFps
Setting the interval of the timer to the value of the fps. */.
double PxWmicron
Only used when opening stacks.
void ImageView_KeyDown(object sender, KeyEventArgs e)
void UpdateViewLegacy(bool refresh)
RectangleF[] ToScreenSpace(RectangleF[] p)
float ToScreenScaleW(double x)
RectangleD ToScreenRect(double x, double y, double w, double h)
int SelectedIndex
A property that is used to set the selected index of the image. */.
static BioImage SelectedImage
RectangleD ToScreenSpace(RectangleF p)
static Bitmap SelectedBuffer
int Level
Current level when viewing whole-slide and pyramidal images.
PointD ToViewSpace(double x, double y)
void AddImage(BioImage im)
static MouseButtons mouseUpButtons
double GetSelectionBoxHitSize()
PointF ToScreenSpace(Point3D p)
static MouseButtons mouseDownButtons
void MoveStageToImage(int i)
PointD ToScreenSpace(PointD p)
async void UpdateImages(bool updatePyramidal=true)
ContextMenuStrip ViewContextMenu
A property that returns a ContextMenuStrip object. */.
double Resolution
A property of the class ImageViewer. It is a getter and setter for the resolution of the image.
double ToViewSizeH(double d)
static RectangleD GetViewRectangle(bool update)
static void KeyDownEvent(object o, KeyEventArgs e)
static void Paint(object o, PaintEventArgs e)
static void KeyUpEvent(object o, KeyEventArgs e)
static void Render(object o, PaintEventArgs e)
void SetPosition(double px, double py)
void UpdateViewMode(ImageView.ViewMode v)
static bool GetKeyState(System.Windows.Forms.Keys vKey)
Layer(double d, bool enabled)