BioImager  4.9.0
A .NET microscopy imaging application based on Bio library. Supports various microscopes by using imported libraries & GUI automation. Supports XInput game controllers to move stage, take images, run ImageJ macros on images or Bio C# scripts.
Loading...
Searching...
No Matches
BioImager.ImageView Class Reference

ImageView control for image stacks, pyramidal and whole-slide-images. More...

Inheritance diagram for BioImager.ImageView:

Classes

struct  Layer
 

Public Types

enum  ViewMode { Raw , Filtered , RGBImage , Emission }
 

Public Member Functions

 ImageView (BioImage im, bool OpenWithOpenSlide=true)
 Initializing the image viewer. *‍/.
 
 ImageView ()
 Initializing the ImageView class. *‍/.
 
void SetCoordinate (int z, int c, int t)
 
ZCT GetCoordinate ()
 
void AddImage (BioImage im)
 
void UpdateRGBChannels ()
 
void InitGUI ()
 
void UpdateSelectBoxSize (float size)
 
void UpdateOverlay ()
 
void UpdateStatus ()
 
void UpdateView ()
 
void UpdateView (bool refresh)
 
async void UpdateImages (bool updatePyramidal=false)
 
void RemoveImage (int i)
 
void RemoveImages ()
 
void UpdateImage ()
 
void GetRange ()
 
void DrawView (System.Drawing.Graphics g)
 Draws the viewport when Hardware Acceleration is off.
 
double GetScale ()
 
void CopySelection ()
 It takes the selected ROIs and copies them to the clipboard.
 
void PasteSelection ()
 
PointD ImageToViewSpace (double x, double y)
 
PointF ToViewSpace (PointF p)
 
PointD ToViewSpace (PointD p)
 
PointD ToViewSpace (double x, double y)
 
double ToViewSizeH (double d)
 
double ToViewW (double d)
 
double ToViewH (double d)
 
PointD ToScreenSpace (double x, double y)
 
PointD ToScreenSpace (PointD p)
 
PointF ToScreenSpace (PointF p)
 
PointF[] ToScreenSpace (PointF[] p)
 
PointF ToScreenSpace (Point3D p)
 
float ToScreenScaleW (double x)
 
float ToScreenScaleH (double y)
 
PointF ToScreenScale (PointD p)
 
RectangleD ToScreenRect (double x, double y, double w, double h)
 
SKRect ToSKRect (double x, double y, double w, double h)
 
RectangleD ToScreenSpace (RectangleD p)
 
RectangleD ToScreenSpace (RectangleF p)
 
RectangleD[] ToScreenSpace (RectangleD[] p)
 
RectangleF[] ToScreenSpace (RectangleF[] p)
 
PointF[] ToScreenSpace (PointD[] p)
 
float ToScreenW (double x)
 
float ToScreenH (double y)
 
void ImageView_KeyDown (object sender, KeyEventArgs e)
 
void GoToImage ()
 
void GoToImage (int i)
 
new void Dispose ()
 
void GoToStage ()
 
void MoveStageToImage ()
 
void MoveStageToImage (int i)
 

Public Attributes

List< LayerLayers = new List<Layer>()
 
Image Buf = null
 
bool init = false
 
List< BioImage > Images = new List<BioImage>()
 
string filepath = ""
 
int serie = 0
 
int minSizeX = 50
 
int minSizeY = 20
 
bool loopZ = true
 
bool loopT = true
 
bool loopC = true
 
bool showRROIs = true
 
bool showGROIs = true
 
bool showBROIs = true
 

Static Public Attributes

static List< ROI > selectedAnnotations = new List<ROI>()
 
static PointD mouseDown
 
static bool down
 
static PointD mouseUp
 
static bool up
 
static MouseButtons mouseUpButtons
 
static MouseButtons mouseDownButtons
 
static bool showBounds = true
 
static bool showText = true
 

Protected Member Functions

override bool ProcessCmdKey (ref Message msg, Keys keyData)
 
override void Dispose (bool disposing)
 Clean up any resources being used.
 

Properties

static BioImage SelectedImage [get, set]
 
static Bitmap SelectedBuffer [get]
 
static bool Ctrl [get]
 
int SelectedIndex = 0 [get, set]
 A property that is used to set the selected index of the image. *‍/.
 
Tools tools [get]
 
Rectangle OverView [get]
 
bool ShowStage [get, set]
 
bool ShowOverview [get, set]
 
bool ShowControls [get, set]
 Setting the visibility of the trackBarPanel. *‍/.
 
bool ShowStatus [get, set]
 Setting the value of the property ShowStatus. *‍/.
 
double PxWmicron [get, set]
 Only used when opening stacks.
 
double PxHmicron [get, set]
 Only used when opening stacks.
 
ViewMode Mode [get, set]
 Setting the view mode of the application. *‍/.
 
string Path [get]
 A property that returns the filepath. *‍/.
 
Channel RChannel [get]
 A property that returns the R channel of the selected image. *‍/.
 
Channel GChannel [get]
 A property that returns the G channel of the image. *‍/.
 
Channel BChannel [get]
 Getting the B channel of the image. *‍/.
 
bool OpenSlide [get]
 
int? MacroResolution [get]
 
int? LabelResolution [get]
 
int ViewWidth [get]
 
int ViewHeight [get]
 
PointD Origin [get, set]
 A property of the class PointD. *‍/.
 
PointD PyramidalOrigin [get, set]
 Setting the value of the pyramidalOrigin variable. *‍/.
 
double Resolution [get, set]
 A property of the class ImageViewer. It is a getter and setter for the resolution of the image.
 
int Level [get]
 Current level when viewing whole-slide and pyramidal images.
 
new AForge.SizeF Scale [get, set]
 Scale when opening image stacks.
 
ContextMenuStrip ViewContextMenu [get]
 A property that returns a ContextMenuStrip object. *‍/.
 
int ZFps [get, set]
 Setting the interval of the timer to the value of the fps. *‍/.
 
int TimeFps [get, set]
 Setting the interval of the timer to the value of the timefps variable. *‍/.
 
int CFps [get, set]
 Setting the interval of the timer to the inverse of the fps. *‍/.
 
List< ROI > AnnotationsR [get]
 
List< ROI > AnnotationsG [get]
 
List< ROI > AnnotationsB [get]
 
List< ROI > AnnotationsRGB [get]
 
PointD PyramidalOriginTransformed [get, set]
 
PointD MouseDownInt [get, set]
 
PointD MouseUpInt [get, set]
 
PointD MouseMoveInt [get, set]
 
bool ShowMasks = true [get, set]
 

Detailed Description

ImageView control for image stacks, pyramidal and whole-slide-images.

Definition at line 4 of file ImageView.designer.cs.

Member Enumeration Documentation

◆ ViewMode

enum BioImager.ImageView.ViewMode

Definition at line 610 of file ImageView.cs.

611 {
612 Raw,
613 Filtered,
614 RGBImage,
615 Emission,
616 }

Constructor & Destructor Documentation

◆ ImageView() [1/2]

BioImager.ImageView.ImageView ( BioImage im,
bool OpenWithOpenSlide = true )

Initializing the image viewer. *‍/.

Definition at line 38 of file ImageView.cs.

39 {
40 string file = im.ID.Replace("\\", "/");
41 InitializeComponent();
42
43 if (im.isPyramidal)
44 {
45 gl.Size = new System.Drawing.Size(800, 600);
46 if (im.openSlideImage != null && OpenWithOpenSlide)
47 {
48 openSlide = true;
49 Initialize(im.file, im);
50 }
51 else
52 Initialize(im.file, im);
53 hScrollBar.Maximum = im.Resolutions[Level].SizeX;
54 vScrollBar.Maximum = im.Resolutions[Level].SizeY;
55 hScrollBar.Visible = true;
56 vScrollBar.Visible = true;
57 }
58 else
59 {
60 hScrollBar.Visible = false;
61 vScrollBar.Visible = false;
62 gl.Width += 18;
63 gl.Height += 18;
64 Tools.selectBoxSize = ROI.selectBoxSize;
65 }
66 App.viewer = this;
67 if (im.SlideBase != null && im.isPyramidal && OpenSlide)
68 openSlide = true;
69 serie = im.series;
70 gl.Dock = DockStyle.Fill;
71 viewpanel.Controls.Add(gl);
72 Dock = DockStyle.Fill;
73 AddImage(im);
74 App.viewer = this;
75 if (file == "" || file == null)
76 return;
77 SetCoordinate(0, 0, 0);
78 InitGUI();
79 gl.Paint += Gl_Paint;
80 MouseWheel += new System.Windows.Forms.MouseEventHandler(ImageView_MouseWheel);
81 zBar.MouseWheel += new System.Windows.Forms.MouseEventHandler(ZTrackBar_MouseWheel);
82 cBar.MouseWheel += new System.Windows.Forms.MouseEventHandler(CTrackBar_MouseWheel);
83 tBar.MouseWheel += new System.Windows.Forms.MouseEventHandler(TimeTrackBar_MouseWheel);
84 //We set the trackbar event to handled so that it only scrolls one tick not the default multiple.
85 zBar.MouseWheel += (sender, e) => ((HandledMouseEventArgs)e).Handled = true;
86 tBar.MouseWheel += (sender, e) => ((HandledMouseEventArgs)e).Handled = true;
87 cBar.MouseWheel += (sender, e) => ((HandledMouseEventArgs)e).Handled = true;
88 this.SizeChanged += ImageView_SizeChanged;
89 this.KeyDown += ImageView_KeyDown;
90 this.KeyPress += ImageView_KeyPress;
91 this.KeyUp += ImageView_KeyUp;
92 TimeFps = 60;
93 ZFps = 60;
94 CFps = 1;
95 resolutions = im.Resolutions;
96 if (im.isPyramidal)
97 {
98 // Set the source based on image type
99 if (im.OpenSlideBase != null)
100 {
101 slideRenderer.SetSource(im.OpenSlideBase);
102 }
103 else if (im.SlideBase != null)
104 {
105 slideRenderer.SetSource(im.SlideBase);
106 }
107 }
108 InitGL();
109 update = true;
110 InitPreview();
111 GoToImage();
112 UpdateImages();
113 Mode = ViewMode.Filtered;
114 UpdateView();
115
116 }
void SetCoordinate(int z, int c, int t)
Definition ImageView.cs:389
async void UpdateImages(bool updatePyramidal=false)
ViewMode Mode
Setting the view mode of the application. *‍/.
Definition ImageView.cs:621
int TimeFps
Setting the interval of the timer to the value of the timefps variable. *‍/.
Definition ImageView.cs:879
int CFps
Setting the interval of the timer to the inverse of the fps. *‍/.
Definition ImageView.cs:895
int ZFps
Setting the interval of the timer to the value of the fps. *‍/.
Definition ImageView.cs:863
void ImageView_KeyDown(object sender, KeyEventArgs e)
int Level
Current level when viewing whole-slide and pyramidal images.
Definition ImageView.cs:796
void AddImage(BioImage im)
Definition ImageView.cs:429

◆ ImageView() [2/2]

BioImager.ImageView.ImageView ( )

Initializing the ImageView class. *‍/.

Definition at line 118 of file ImageView.cs.

119 {
120 InitializeComponent();
121 InitGL();
122 Dock = DockStyle.Fill;
123 App.viewer = this;
124 SetCoordinate(0, 0, 0);
125 InitGUI();
126 gl.Paint += Gl_Paint;
127 //Buf = image.GetBufByCoord(GetCoordinate());
128 MouseWheel += new System.Windows.Forms.MouseEventHandler(ImageView_MouseWheel);
129 zBar.MouseWheel += new System.Windows.Forms.MouseEventHandler(ZTrackBar_MouseWheel);
130 cBar.MouseWheel += new System.Windows.Forms.MouseEventHandler(CTrackBar_MouseWheel);
131 tBar.MouseWheel += new System.Windows.Forms.MouseEventHandler(TimeTrackBar_MouseWheel);
132 this.SizeChanged += ImageView_SizeChanged;
133 //We set the trackbar event to handled so that it only scrolls one tick not the default multiple.
134 zBar.MouseWheel += (sender, e) => ((HandledMouseEventArgs)e).Handled = true;
135 tBar.MouseWheel += (sender, e) => ((HandledMouseEventArgs)e).Handled = true;
136 cBar.MouseWheel += (sender, e) => ((HandledMouseEventArgs)e).Handled = true;
137 TimeFps = 60;
138 ZFps = 60;
139 CFps = 1;
140 update = true;
141 UpdateImages();
142 GoToImage();
143 UpdateView();
144 }

Member Function Documentation

◆ AddImage()

void BioImager.ImageView.AddImage ( BioImage im)

This function adds an image to the list of images, and then updates the GUI to reflect the new image

Parameters
BioImageThis is a class that contains the image data, and some other information about the image.

Definition at line 429 of file ImageView.cs.

430 {
431 Images.Add(im);
432 SelectedIndex = Images.Count - 1;
433 bool c = false;
434 foreach (var item in Layers)
435 {
436 if (item.Resolution == im.PhysicalSizeX)
437 c = true;
438 }
439 if (!c)
440 Layers.Add(new Layer(im.PhysicalSizeX));
441 if (im.isPyramidal)
442 {
443 hScrollBar.Maximum = im.Resolutions[Level].SizeX;
444 vScrollBar.Maximum = im.Resolutions[Level].SizeY;
445 hScrollBar.Visible = true;
446 vScrollBar.Visible = true;
447 }
448 else
449 {
450 hScrollBar.Visible = false;
451 vScrollBar.Visible = false;
452 gl.Width += 18;
453 gl.Height += 18;
454 Tools.selectBoxSize = ROI.selectBoxSize;
455 }
456 InitGUI();
457 UpdateImages();
458
459 GoToImage(Images.Count - 1);
460 }
int SelectedIndex
A property that is used to set the selected index of the image. *‍/.
Definition ImageView.cs:351

◆ CopySelection()

void BioImager.ImageView.CopySelection ( )

It takes the selected ROIs and copies them to the clipboard.

Definition at line 2749 of file ImageView.cs.

2750 {
2751 copys.Clear();
2752 string s = "";
2753 foreach (ROI item in AnnotationsRGB)
2754 {
2755 if (item.Selected)
2756 {
2757 copys.Add(item);
2758 s += BioImage.ROIToString(item);
2759 }
2760 }
2761 System.Windows.Forms.Clipboard.SetText(s);
2762 }

◆ Dispose() [1/2]

new void BioImager.ImageView.Dispose ( )

Definition at line 3390 of file ImageView.cs.

3391 {
3392 for (int i = 0; i < Bitmaps.Count; i++)
3393 {
3394 if (Bitmaps[i] != null)
3395 Bitmaps[i].Dispose();
3396 }
3397 for (int i = 0; i < Bitmaps.Count; i++)
3398 {
3399 if (Bitmaps[i] != null)
3400 Bitmaps[i].Dispose();
3401 }
3402 }

◆ Dispose() [2/2]

override void BioImager.ImageView.Dispose ( bool disposing)
protected

Clean up any resources being used.

Parameters
disposingtrue if managed resources should be disposed; otherwise, false.

Definition at line 15 of file ImageView.designer.cs.

16 {
17 if (disposing && (components != null))
18 {
19 components.Dispose();
20 }
21 base.Dispose(disposing);
22 }

◆ DrawView()

void BioImager.ImageView.DrawView ( System.Drawing.Graphics g)

Draws the viewport when Hardware Acceleration is off.

Parameters
g

Definition at line 2214 of file ImageView.cs.

2215 {
2216 try
2217 {
2218 drawing = true;
2219 if (SelectedImage == null)
2220 return;
2221 if (SelectedImage.isPyramidal)
2222 {
2223 UpdateImages(true);
2224 updatePyr = false;
2225 return;
2226 }
2227 g.TranslateTransform(ViewWidth / 2, ViewHeight / 2);
2228 if (Scale.Width == 0 || float.IsInfinity(Scale.Width))
2229 Scale = new SizeF(1, 1);
2230 g.ScaleTransform(Scale.Width, Scale.Height);
2231 if (Bitmaps.Count == 0)
2232 return;
2233 System.Drawing.RectangleF[] rf = new System.Drawing.RectangleF[1];
2234 System.Drawing.Pen blue = new System.Drawing.Pen(Brushes.Blue, 1 / Scale.Width);
2235 int i = 0;
2236 foreach (BioImage im in Images)
2237 {
2238 if (!IsLayerEnabled(im.PhysicalSizeX) && !im.isPyramidal)
2239 continue;
2240 RectangleD r = ToScreenRect(im.Volume.Location.X, im.Volume.Location.Y, im.Volume.Width, im.Volume.Height);
2241 double w = ToViewW(ViewWidth);
2242 double h = ToViewH(ViewHeight);
2243 RectangleF rg = new RectangleF((float)((-Origin.X) - (w / 2)), (float)((-Origin.Y) - (h / 2)), (float)(w), (float)(h));
2244 RectangleF rec = new RectangleF((float)im.Volume.Location.X, (float)im.Volume.Location.Y, (float)im.Volume.Width, (float)im.Volume.Height);
2245 if (SelectedImage.isPyramidal)
2246 {
2247 var tr = g.Transform;
2248 g.ResetTransform();
2249 g.DrawImage(Bitmaps[i], 0, 0);
2250 g.Transform = tr;
2251 }
2252 else
2253 if (rg.IntersectsWith(rec))
2254 {
2255 g.DrawImage(Bitmaps[i], (float)r.X, (float)r.Y, (float)r.W, (float)r.H);
2256 }
2257 if (i == SelectedIndex && !SelectedImage.isPyramidal)
2258 {
2259 rf[0] = new System.Drawing.RectangleF((float)r.X, (float)r.Y, (float)r.W, (float)r.H);
2260 g.DrawRectangles(blue, rf);
2261 }
2262 i++;
2263 }
2264 if (ShowOverview)
2265 {
2266 g.ResetTransform();
2267 g.DrawImage(ToSysBitmap(overviewBitmap), new System.Drawing.Point(0, 0));
2268 g.DrawRectangle(Pens.Gray, overview.X, overview.Y, overview.Width, overview.Height);
2269 if (!openSlide)
2270 {
2271 double dsx = _slideBase.Schema.Resolutions[Level].UnitsPerPixel / Resolution;
2272 Resolution rs = SelectedImage.Resolutions[Level];
2273 double dx = ((double)PyramidalOrigin.X / (rs.SizeX * dsx)) * overview.Width;
2274 double dy = ((double)PyramidalOrigin.Y / (rs.SizeY * dsx)) * overview.Height;
2275 double dw = ((double)ViewWidth / (rs.SizeX)) * overview.Width * dsx;
2276 double dh = ((double)ViewHeight / (rs.SizeY)) * overview.Height * dsx;
2277 g.DrawRectangle(Pens.Red, (int)dx, (int)dy, (int)dw, (int)dh);
2278 }
2279 else
2280 {
2281 double dsx = _openSlideBase.Schema.Resolutions[Level].UnitsPerPixel / Resolution;
2282 var rs = _openSlideBase.Schema.Resolutions.Last();
2283 Resolution rss = SelectedImage.Resolutions[Level];
2284 double dx = ((double)PyramidalOrigin.X / (rss.SizeX * dsx)) * overview.Width;
2285 double dy = ((double)PyramidalOrigin.Y / (rss.SizeY * dsx)) * overview.Height;
2286 double dw = ((double)ViewWidth / (rss.SizeX * dsx)) * overview.Width;
2287 double dh = ((double)ViewHeight / (rss.SizeY * dsx)) * overview.Height;
2288 g.DrawRectangle(Pens.Red, (int)dx, (int)dy, (int)dw, (int)dh);
2289 }
2290 }
2291 if (ShowStage)
2292 {
2293 RectangleD d = Microscope.GetViewRectangle(false);
2294 RectangleF[] rfs = new RectangleF[1] { new RectangleF((float)d.X, (float)d.Y, (float)d.W, (float)d.H) };
2295 var v = ToScreenSpace(rfs);
2296 System.Drawing.Pen red = new System.Drawing.Pen(Brushes.Red, 1 / Scale.Width);
2297 g.DrawRectangle(red, v[0].X, v[0].Y, v[0].Width, v[0].Height);
2298 }
2299 blue.Dispose();
2300 update = false;
2301 drawing = false;
2302 }
2303 catch (Exception e)
2304 {
2305 Console.WriteLine(e.Message);
2306 }
2307 }
new AForge.SizeF Scale
Scale when opening image stacks.
Definition ImageView.cs:810
PointD Origin
A property of the class PointD. *‍/.
Definition ImageView.cs:727
PointD ToScreenSpace(double x, double y)
double ToViewW(double d)
RectangleD ToScreenRect(double x, double y, double w, double h)
double ToViewH(double d)
double Resolution
A property of the class ImageViewer. It is a getter and setter for the resolution of the image.
Definition ImageView.cs:752

◆ GetCoordinate()

ZCT BioImager.ImageView.GetCoordinate ( )

It returns the coordinate of the selected image

Returns
The Coordinate property of the SelectedImage object.

Definition at line 420 of file ImageView.cs.

421 {
422 return SelectedImage.Coordinate;
423 }

◆ GetRange()

void BioImager.ImageView.GetRange ( )

It creates a new RangeTool object, which is a form that allows the user to set the range of the data to be displayed.

The RangeTool object is created with the following parameters:

  • timeEnabled: a boolean that indicates whether the data has a time component.
  • Mode: a ViewMode enum that indicates whether the data is filtered or not.
  • zBar.Minimum: the minimum value of the zBar.
  • zBar.Maximum: the maximum value of the zBar.
  • tBar.Minimum: the minimum value of the tBar.
  • tBar.Maximum: the maximum value of the tBar.
  • cBar.Minimum: the minimum value of the cBar.
  • cBar.Maximum: the maximum value of the cBar.

The RangeTool object is then shown to the user.

If the user clicks the

Returns
A RangeTool object.

Definition at line 1648 of file ImageView.cs.

1649 {
1650 RangeTool t;
1651 if (Mode == ViewMode.Filtered)
1652 t = new RangeTool(timeEnabled, true, zBar.Minimum, zBar.Maximum, tBar.Minimum, tBar.Maximum, cBar.Minimum, cBar.Maximum);
1653 else
1654 t = new RangeTool(timeEnabled, false, zBar.Minimum, zBar.Maximum, tBar.Minimum, tBar.Maximum, cBar.Minimum, cBar.Maximum);
1655 if (t.ShowDialog() != DialogResult.OK)
1656 return;
1657 zBar.Minimum = t.ZMin;
1658 zBar.Maximum = t.ZMax;
1659 tBar.Minimum = t.TimeMin;
1660 tBar.Maximum = t.TimeMax;
1661 cBar.Minimum = t.CMin;
1662 cBar.Maximum = t.CMax;
1663 }

◆ GetScale()

double BioImager.ImageView.GetScale ( )

GetScale() returns the scale of the image in the viewport.

Returns
The scale of the image.

Definition at line 2325 of file ImageView.cs.

2326 {
2327 return ToViewSizeW(ROI.selectBoxSize / Scale.Width);
2328 }

◆ GoToImage() [1/2]

void BioImager.ImageView.GoToImage ( )

If the selected image is not null, set the origin to the center of the image, and set the scale to the height of the image.

Returns
The method is returning the value of the variable "Scale"

Definition at line 3252 of file ImageView.cs.

3253 {
3254 GoToImage(0);
3255 }

◆ GoToImage() [2/2]

void BioImager.ImageView.GoToImage ( int i)

It takes an image index and centers the image in the viewport

Parameters
ithe index of the image to go to
Returns
The method is returning the value of the variable "i"

Definition at line 3294 of file ImageView.cs.

3295 {
3296 if (Images.Count <= i)
3297 return;
3298 if (SelectedImage.Type == BioImage.ImageType.pyramidal)
3299 {
3300 if (SelectedImage.OpenSlideBase != null)
3301 {
3302 if (MacroResolution.HasValue)
3303 {
3304 int lev = MacroResolution.Value - 2;
3305 Resolution = _openSlideBase.Schema.Resolutions[lev].UnitsPerPixel * 0.98;
3306 }
3307 else
3308 {
3309 int lev = 0;
3310 Resolution = _openSlideBase.Schema.Resolutions[lev].UnitsPerPixel * 0.98;
3311 }
3312 }
3313 else
3314 {
3315 if (MacroResolution.HasValue)
3316 {
3317 int lev = MacroResolution.Value - 1;
3318 Resolution = SelectedImage.SlideBase.Schema.Resolutions[lev].UnitsPerPixel * 0.98;
3319 PyramidalOrigin = new PointD(0, 0);
3320 }
3321 else
3322 {
3323 Resolution = SelectedImage.GetUnitPerPixel(SelectedImage.Resolutions.Count - 1) * 0.98;
3324 }
3325 }
3326 }
3327 double dx = Images[i].Volume.Width / 2;
3328 double dy = Images[i].Volume.Height / 2;
3329 Origin = new PointD(-(Images[i].Volume.Location.X + dx), -(Images[i].Volume.Location.Y + dy));
3330 double wx, wy;
3331 wx = ViewWidth / ToScreenScaleW(SelectedImage.Volume.Width);
3332 wy = ViewHeight / ToScreenScaleH(SelectedImage.Volume.Height);
3333 Scale = new SizeF((float)wy, (float)wy);
3334 UpdateView();
3335 }
float ToScreenScaleH(double y)
PointD PyramidalOrigin
Setting the value of the pyramidalOrigin variable. *‍/.
Definition ImageView.cs:739
float ToScreenScaleW(double x)

◆ GoToStage()

void BioImager.ImageView.GoToStage ( )

Definition at line 3504 of file ImageView.cs.

3505 {
3506 RectangleD d = Microscope.GetViewRectangle(false);
3507 double dx = d.W / 2;
3508 double dy = d.H / 2;
3509 Origin = new PointD(-(d.X + dx), -(d.Y + dy));
3510 double wx, wy;
3511 wx = Math.Abs(ViewWidth / ToScreenScaleW(d.W));
3512 wy = Math.Abs(ViewHeight / ToScreenScaleH(d.H));
3513 scale.Width = (float)wy;
3514 scale.Height = (float)wy;
3515 update = true;
3516 UpdateView();
3517 }

◆ ImageToViewSpace()

PointD BioImager.ImageView.ImageToViewSpace ( double x,
double y )

It takes a point in the image space and returns the point in the view space

Parameters
xthe x coordinate of the point in the image
ythe y coordinate of the point in the image
Returns
The point in the image space that corresponds to the point in the view space.

Definition at line 2863 of file ImageView.cs.

2864 {
2865 if (SelectedImage == null)
2866 return ToViewSpace(x, y);
2867 if (SelectedImage.isPyramidal)
2868 {
2869 return new PointD((PyramidalOrigin.X + x) * Resolution, (PyramidalOrigin.Y + y) * Resolution);
2870 }
2871 else
2872 return ToViewSpace(x, y);
2873 }
PointF ToViewSpace(PointF p)

◆ ImageView_KeyDown()

void BioImager.ImageView.ImageView_KeyDown ( object sender,
KeyEventArgs e )

If the user presses the "C" key while holding down the "Control" key, then the function "CopySelection" is called

Parameters
senderThe object that raised the event.
KeyEventArgsThe event arguments for the key press.
Returns
The return value is a PointD object.

Definition at line 3177 of file ImageView.cs.

3178 {
3179 double moveAmount = 5 * Scale.Width;
3180 Plugins.KeyDownEvent(sender, e);
3181 if (e.KeyCode == Keys.C && e.Control)
3182 {
3183 CopySelection();
3184 return;
3185 }
3186 if (e.KeyCode == Keys.V && e.Control)
3187 {
3189 return;
3190 }
3191 if (e.KeyCode == Keys.Subtract || e.KeyCode == Keys.NumPad7)
3192 {
3193 if (SelectedImage.isPyramidal)
3194 Resolution *= 0.9f;
3195 else
3196 Scale = new SizeF(Scale.Width - 0.1f, Scale.Height - 0.1f);
3197 UpdateView();
3198 }
3199 if (e.KeyCode == Keys.Add || e.KeyCode == Keys.NumPad9)
3200 {
3201 if (SelectedImage.isPyramidal)
3202 Resolution *= 1.1f;
3203 else
3204 Scale = new SizeF(Scale.Width + 0.1f, Scale.Height + 0.1f);
3205 UpdateView();
3206 }
3207 if (e.KeyCode == Keys.W || e.KeyCode == Keys.NumPad8)
3208 {
3209 if (SelectedImage.isPyramidal)
3210 PyramidalOrigin = new PointD(PyramidalOrigin.X, PyramidalOrigin.Y - moveAmount);
3211 else
3212 Origin = new PointD(Origin.X, Origin.Y + moveAmount);
3213 UpdateView();
3214 }
3215 if (e.KeyCode == Keys.S || e.KeyCode == Keys.NumPad2)
3216 {
3217 if (SelectedImage.isPyramidal)
3218 PyramidalOrigin = new PointD(PyramidalOrigin.X, PyramidalOrigin.Y + moveAmount);
3219 else
3220 Origin = new PointD(Origin.X, Origin.Y - moveAmount);
3221 UpdateView();
3222 }
3223 if (e.KeyCode == Keys.A || e.KeyCode == Keys.NumPad4)
3224 {
3225 if (SelectedImage.isPyramidal)
3226 PyramidalOrigin = new PointD(PyramidalOrigin.X - moveAmount, PyramidalOrigin.Y);
3227 else
3228 Origin = new PointD(Origin.X + moveAmount, Origin.Y);
3229 UpdateView();
3230 }
3231 if (e.KeyCode == Keys.D || e.KeyCode == Keys.NumPad6)
3232 {
3233 if (SelectedImage.isPyramidal)
3234 PyramidalOrigin = new PointD(PyramidalOrigin.X + moveAmount, PyramidalOrigin.Y);
3235 else
3236 Origin = new PointD(Origin.X - moveAmount, Origin.Y);
3237 UpdateView();
3238 }
3239 }
void CopySelection()
It takes the selected ROIs and copies them to the clipboard.

◆ InitGUI()

void BioImager.ImageView.InitGUI ( )

It initializes the GUI

Returns
The image is being returned.

Definition at line 910 of file ImageView.cs.

911 {
912 if (SelectedImage == null)
913 return;
914 zBar.Maximum = SelectedImage.SizeZ - 1;
915 if (SelectedImage.Buffers[0].RGBChannelsCount == 3)
916 cBar.Maximum = 0;
917 else
918 cBar.Maximum = SelectedImage.SizeC - 1;
919 if (SelectedImage.SizeT > 1)
920 {
921 tBar.Maximum = SelectedImage.SizeT - 1;
922 timeEnabled = true;
923 }
924 else
925 {
926 tBar.Enabled = false;
927 timeEnabled = false;
928 tBar.Maximum = SelectedImage.SizeT - 1;
929 }
930 //rgbPictureBox.Image = image.plane.GetBitmap();
931 //we clear the channel comboboxes incase we have channels from previous loaded image.
932 channelBoxR.Items.Clear();
933 channelBoxG.Items.Clear();
934 channelBoxB.Items.Clear();
935
936 foreach (Channel ch in SelectedImage.Channels)
937 {
938 channelBoxR.Items.Add(ch);
939 channelBoxG.Items.Add(ch);
940 channelBoxB.Items.Add(ch);
941 }
942 if (SelectedImage.Channels.Count > 2)
943 {
944 channelBoxR.SelectedIndex = 0;
945 channelBoxG.SelectedIndex = 1;
946 channelBoxB.SelectedIndex = 2;
947 }
948 else
949 if (SelectedImage.Channels.Count == 2)
950 {
951 channelBoxR.SelectedIndex = 0;
952 channelBoxG.SelectedIndex = 1;
953 }
955
956 init = true;
957 }

◆ MoveStageToImage() [1/2]

void BioImager.ImageView.MoveStageToImage ( )

Move the stage to the location of the selected image

Returns
The method is returning the value of the SelectedImage property.

Definition at line 3521 of file ImageView.cs.

3522 {
3523 if (SelectedImage == null)
3524 return;
3525 Microscope.Stage.SetPosition(SelectedImage.Volume.Location.X, SelectedImage.Volume.Location.Y);
3526 update = true;
3527 UpdateView();
3528 }

◆ MoveStageToImage() [2/2]

void BioImager.ImageView.MoveStageToImage ( int i)

Move the stage to the location of the image at index i

Parameters
ithe index of the image in the list of images

Definition at line 3532 of file ImageView.cs.

3533 {
3534 update = true;
3535 Microscope.Stage.SetPosition(Images[i].Volume.Location.X, Images[i].Volume.Location.Y);
3536 UpdateView();
3537 }

◆ PasteSelection()

void BioImager.ImageView.PasteSelection ( )

We get the text from the clipboard, split it into lines, and then for each line, if it's longer than 8 characters, we convert it to an ROI and add it to the image

Definition at line 2765 of file ImageView.cs.

2766 {
2767 string[] sts = System.Windows.Forms.Clipboard.GetText().Split(BioImage.NewLine);
2768 foreach (string line in sts)
2769 {
2770 if (line.Length > 8)
2771 {
2772 ROI an = BioImage.StringToROI(line);
2773 //We set the coordinates of the ROI's we are pasting
2774 an.coord = GetCoordinate();
2775 SelectedImage.Annotations.Add(an);
2776 }
2777 }
2778 UpdateOverlay();
2779 }

◆ ProcessCmdKey()

override bool BioImager.ImageView.ProcessCmdKey ( ref Message msg,
Keys keyData )
protected

Definition at line 145 of file ImageView.cs.

146 {
147 const int WM_KEYDOWN = 0x0100;
148 const int WM_KEYUP = 0x0101;
149 const int WM_CHAR = 0x0102;
150
151 switch (msg.Msg)
152 {
153 case WM_KEYDOWN:
154 ImageView_KeyDown(this, new KeyEventArgs(keyData));
155 break;
156
157 case WM_KEYUP:
158 ImageView_KeyUp(this, new KeyEventArgs(keyData));
159 break;
160
161 case WM_CHAR:
162 char ch = (char)msg.WParam;
163 ImageView_KeyPress(this, new System.Windows.Forms.KeyPressEventArgs(ch));
164 break;
165 }
166
167 return base.ProcessCmdKey(ref msg, keyData);
168 }

◆ RemoveImage()

void BioImager.ImageView.RemoveImage ( int i)

Definition at line 1355 of file ImageView.cs.

1356 {
1357 do
1358 {
1359 System.Threading.Thread.Sleep(50);
1360 Application.DoEvents();
1361 } while (drawing || updating);
1362 Images[i].Dispose();
1363 Images.RemoveAt(i);
1364 UpdateImages();
1365 }

◆ RemoveImages()

void BioImager.ImageView.RemoveImages ( )

Definition at line 1366 of file ImageView.cs.

1367 {
1368 do
1369 {
1370 Thread.Sleep(50);
1371 Application.DoEvents();
1372 } while (drawing || updating);
1373 for (int i = 0; i < Images.Count; i++)
1374 {
1375 Images[i].Dispose();
1376 }
1377 Images.Clear();
1378 UpdateImages();
1379 }

◆ SetCoordinate()

void BioImager.ImageView.SetCoordinate ( int z,
int c,
int t )

‍Sets the coordinate of the image to the specified Z, C, and T values

Parameters
zthe z-coordinate of the image
cchannel
ttime
Returns
The method is returning the value of the zBar.Value, cBar.Value, and tBar.Value.

Definition at line 389 of file ImageView.cs.

390 {
391 System.Threading.Tasks.Task.Run(() =>
392 {
393 try
394 {
395 App.viewer.Invoke((MethodInvoker)delegate
396 {
397 if (SelectedImage == null)
398 return;
399 if (z >= SelectedImage.SizeZ)
400 zBar.Value = zBar.Maximum;
401 if (c >= SelectedImage.SizeC)
402 cBar.Value = cBar.Maximum;
403 if (t >= SelectedImage.SizeT)
404 tBar.Value = tBar.Maximum;
405 zBar.Value = z;
406 cBar.Value = c;
407 tBar.Value = t;
408 });
409 }
410 catch (Exception e)
411 {
412 Console.WriteLine(e.Message);
413 }
414
415 });
416 }

◆ ToScreenH()

float BioImager.ImageView.ToScreenH ( double y)

‍Convert a value in microns to a value in pixels

Parameters
ythe y coordinate of the point to be converted
Returns
The return value is a float.

Definition at line 3166 of file ImageView.cs.

3167 {
3168 return (float)(y * PxHmicron);
3169 }
double PxHmicron
Only used when opening stacks.
Definition ImageView.cs:600

◆ ToScreenRect()

RectangleD BioImager.ImageView.ToScreenRect ( double x,
double y,
double w,
double h )

It converts a rectangle in microns to a rectangle in pixels

Parameters
xThe x coordinate of the rectangle
y-0.0015
wwidth of the image in microns
hheight of the rectangle
Returns
A RectangleF object.

Definition at line 3055 of file ImageView.cs.

3056 {
3057 if (SelectedImage == null)
3058 {
3059 PointD pf;
3060 pf = ToScreenSpace(x, y);
3061 return new RectangleD(pf.X, pf.Y, ToScreenScaleW(w), ToScreenScaleH(h));
3062 }
3063 if (SelectedImage.isPyramidal)
3064 {
3065 PointD d = ToViewSpace(x, y);
3066 double dw = ToViewSizeW(w);
3067 double dh = ToViewSizeH(h);
3068 return new RectangleD((d.X - PyramidalOrigin.X), (d.Y - PyramidalOrigin.Y), dw, dh);
3069 }
3070 else
3071 {
3072 PointD pf = ToScreenSpace(x, y);
3073 return new RectangleD(pf.X, pf.Y, ToScreenScaleW(w), ToScreenScaleH(h));
3074 }
3075 }
double ToViewSizeH(double d)

◆ ToScreenScale()

PointF BioImager.ImageView.ToScreenScale ( PointD p)

‍Convert a point in the world coordinate system to a point in the screen coordinate system

Parameters
PointD
Returns
A PointF object.

Definition at line 3041 of file ImageView.cs.

3042 {
3043 float x = ToScreenScaleW((float)p.X);
3044 float y = ToScreenScaleH((float)p.Y);
3045 return new PointF(x, y);
3046 }

◆ ToScreenScaleH()

float BioImager.ImageView.ToScreenScaleH ( double y)

‍Convert a value in microns to a value in pixels

Parameters
ythe y coordinate of the point to be converted
Returns
The return value is a float.

Definition at line 3032 of file ImageView.cs.

3033 {
3034 return (float)(y * PxHmicron);
3035 }

◆ ToScreenScaleW()

float BioImager.ImageView.ToScreenScaleW ( double x)

ToScreenScaleW() returns the number of pixels that correspond to the given number of microns

Parameters
xthe x coordinate of the point to be converted
Returns
The return value is a float.

Definition at line 3023 of file ImageView.cs.

3024 {
3025 return (float)(x * PxWmicron);
3026 }
double PxWmicron
Only used when opening stacks.
Definition ImageView.cs:585

◆ ToScreenSpace() [1/10]

PointD BioImager.ImageView.ToScreenSpace ( double x,
double y )

‍It converts a point in world space to a point in screen space

Parameters
xThe x coordinate of the point to convert.
yThe y coordinate of the point to transform.
Returns
A PointD object.

Definition at line 2969 of file ImageView.cs.

2970 {
2971 double fx = ToScreenScaleW(Origin.X + x);
2972 double fy = ToScreenScaleH(Origin.Y + y);
2973 return new PointD(fx, fy);
2974 }

◆ ToScreenSpace() [2/10]

PointF BioImager.ImageView.ToScreenSpace ( Point3D p)

‍It converts a 3D point to a 2D point

Parameters
Point3D
Returns
A PointF object.

Definition at line 3013 of file ImageView.cs.

3014 {
3015 PointD pd = ToScreenSpace(p.X, p.Y);
3016 return new PointF((float)pd.X, (float)pd.Y);
3017 }

◆ ToScreenSpace() [3/10]

PointD BioImager.ImageView.ToScreenSpace ( PointD p)

‍Converts a point from world space to screen space

Parameters
PointDA class that contains an X and Y value.
Returns
A PointD object.

Definition at line 2980 of file ImageView.cs.

2981 {
2982 return ToScreenSpace(p.X, p.Y);
2983 }

◆ ToScreenSpace() [4/10]

PointF[] BioImager.ImageView.ToScreenSpace ( PointD[] p)

‍Convert a list of points from world space to screen space

Parameters
pThe point to convert
Returns
A PointF[] array of points.

Definition at line 3142 of file ImageView.cs.

3143 {
3144 PointF[] rs = new PointF[p.Length];
3145 for (int i = 0; i < p.Length; i++)
3146 {
3147 PointD pd = ToScreenSpace(p[i]);
3148 rs[i] = new PointF((float)pd.X, (float)pd.Y);
3149 }
3150 return rs;
3151 }

◆ ToScreenSpace() [5/10]

PointF BioImager.ImageView.ToScreenSpace ( PointF p)

Convert a point in the world coordinate system to the screen coordinate system

Parameters
PointFThe point you want to convert to screen space.
Returns
A PointD object.

Definition at line 2989 of file ImageView.cs.

2990 {
2991 PointD pd = ToScreenSpace(p.X, p.Y);
2992 return new PointF((float)pd.X, (float)pd.Y);
2993 }

◆ ToScreenSpace() [6/10]

PointF[] BioImager.ImageView.ToScreenSpace ( PointF[] p)

‍It takes an array of points and returns an array of points

Parameters
pThe point to convert
Returns
A PointF array.

Definition at line 2999 of file ImageView.cs.

3000 {
3001 PointF[] pf = new PointF[p.Length];
3002 for (int i = 0; i < p.Length; i++)
3003 {
3004 pf[i] = ToScreenSpace(p[i]);
3005 }
3006 return pf;
3007 }

◆ ToScreenSpace() [7/10]

RectangleD BioImager.ImageView.ToScreenSpace ( RectangleD p)

‍It converts a rectangle from world space to screen space

Parameters
RectangleDThe rectangle to convert.
Returns
A RectangleF object.

Definition at line 3096 of file ImageView.cs.

3097 {
3098 return ToScreenRect(p.X, p.Y, p.W, p.H);
3099 }

◆ ToScreenSpace() [8/10]

RectangleD[] BioImager.ImageView.ToScreenSpace ( RectangleD[] p)

It takes an array of RectangleD objects and returns an array of RectangleF objects

Parameters
pThe rectangle to convert
Returns
A RectangleF[]

Definition at line 3114 of file ImageView.cs.

3115 {
3116 RectangleD[] rs = new RectangleD[p.Length];
3117 for (int i = 0; i < p.Length; i++)
3118 {
3119 rs[i] = ToScreenSpace(p[i]);
3120 }
3121 return rs;
3122 }

◆ ToScreenSpace() [9/10]

RectangleD BioImager.ImageView.ToScreenSpace ( RectangleF p)

‍It converts a rectangle from world space to screen space

Parameters
RectangleFThe rectangle to convert.
Returns
A RectangleF object.

Definition at line 3105 of file ImageView.cs.

3106 {
3107 return ToScreenRect(p.X, p.Y, p.Width, p.Height);
3108 }

◆ ToScreenSpace() [10/10]

RectangleF[] BioImager.ImageView.ToScreenSpace ( RectangleF[] p)

It takes an array of RectangleF objects and returns an array of RectangleF objects

Parameters
pThe rectangle to convert
Returns
A RectangleF[]

Definition at line 3128 of file ImageView.cs.

3129 {
3130 RectangleF[] rs = new RectangleF[p.Length];
3131 for (int i = 0; i < p.Length; i++)
3132 {
3133 rs[i] = ToScreenSpace(p[i]).ToRectangleF();
3134 }
3135 return rs;
3136 }

◆ ToScreenW()

float BioImager.ImageView.ToScreenW ( double x)

ToScreenW(x) = x * PxWmicron

Parameters
xthe x coordinate of the point to be converted
Returns
The return value is a float.

Definition at line 3157 of file ImageView.cs.

3158 {
3159 return (float)(x * PxWmicron);
3160 }

◆ ToSKRect()

SKRect BioImager.ImageView.ToSKRect ( double x,
double y,
double w,
double h )

‍It takes a rectangle in the coordinate system of the stage and returns a rectangle in the coordinate system of the picturebox

Parameters
xThe x coordinate of the upper-left corner of the rectangle.
yThe y-coordinate of the upper-left corner of the rectangle.
wwidth of the rectangle
hheight of the rectangle
Returns
A SKRect object.

Definition at line 3085 of file ImageView.cs.

3086 {
3087 double xd = gl.Width / 2;
3088 double yd = gl.Height / 2;
3089 return new SKRect((float)(xd - x), (float)(yd - y), (float)(xd - (x + w)), (float)(yd - (y + h)));
3090 }

◆ ToViewH()

double BioImager.ImageView.ToViewH ( double d)

‍Convert a distance in microns to a distance in pixels

Parameters
dthe distance in microns
Returns
The return value is the y-coordinate of the point in the view.

Definition at line 2958 of file ImageView.cs.

2959 {
2960 double y = (double)(d / PxHmicron) / scale.Height;
2961 return y;
2962 }

◆ ToViewSizeH()

double BioImager.ImageView.ToViewSizeH ( double d)

‍Convert a value in microns to a value in pixels

Parameters
dthe size in microns
Returns
The return value is the size of the object in pixels.

Definition at line 2933 of file ImageView.cs.

2934 {
2935 if (SelectedImage != null)
2936 if (SelectedImage.isPyramidal)
2937 {
2938 return d / Resolution;
2939 }
2940 double y = (double)(d / PxHmicron);
2941 return y;
2942 }

◆ ToViewSpace() [1/3]

PointD BioImager.ImageView.ToViewSpace ( double x,
double y )

‍ToViewSpace(x, y) = (ToViewSizeW(x - (ViewWidth / 2)) / Scale.Width) - Origin.X;

Parameters
xThe x coordinate of the point to convert
yThe y coordinate of the point to convert.
Returns
A PointD object.

Definition at line 2899 of file ImageView.cs.

2900 {
2901 if (SelectedImage != null)
2902 if (SelectedImage.isPyramidal)
2903 {
2904 double ddx = x / Resolution;
2905 double ddy = y / Resolution;
2906 return new PointD(ddx, ddy);
2907 }
2908 double dx, dy;
2909 dx = (ToViewSizeW(x - (ViewWidth / 2)) / Scale.Width) - Origin.X;
2910 dy = (ToViewSizeH(y - (ViewHeight / 2)) / Scale.Height) - Origin.Y;
2911 return new PointD(dx, dy);
2912 }

◆ ToViewSpace() [2/3]

PointD BioImager.ImageView.ToViewSpace ( PointD p)

‍Converts a point from world space to view space

Parameters
PointDA class that contains an X and Y value.
Returns
A PointD object.

Definition at line 2889 of file ImageView.cs.

2890 {
2891 return ToViewSpace(p.X, p.Y); ;
2892 }

◆ ToViewSpace() [3/3]

PointF BioImager.ImageView.ToViewSpace ( PointF p)

Convert a point from world space to view space

Parameters
PointFThe point to convert
Returns
A PointD object.

Definition at line 2879 of file ImageView.cs.

2880 {
2881 PointD d = ToViewSpace(p.X, p.Y);
2882 return new PointF((float)d.X, (float)d.Y);
2883 }

◆ ToViewW()

double BioImager.ImageView.ToViewW ( double d)

Convert a distance in microns to a distance in pixels on the screen

Parameters
dthe distance in microns
Returns
The width of the image in pixels.

Definition at line 2948 of file ImageView.cs.

2949 {
2950 double x = (double)(d / PxWmicron) / scale.Width;
2951 return x;
2952 }

◆ UpdateImage()

void BioImager.ImageView.UpdateImage ( )

It takes a 16-bit image, converts it to 8-bit, and then converts it to a DirectX texture

Returns
A bitmap

Definition at line 1384 of file ImageView.cs.

1385 {
1386 UpdateImages();
1387 }

◆ UpdateImages()

async void BioImager.ImageView.UpdateImages ( bool updatePyramidal = false)

It takes a list of images, and for each image, it gets the image at the current Z, C, T coordinates, and then converts it to a bitmap

Returns
A Bitmap

Definition at line 1291 of file ImageView.cs.

1292 {
1293 if (SelectedImage == null)
1294 return;
1295 if (SelectedImage.isPyramidal && gl.Width > 1 && gl.Height > 1)
1296 {
1297 if (SelectedImage.isPyramidal)
1298 updatePyr = true;
1299 SelectedImage.PyramidalOrigin = PyramidalOrigin;
1300 SelectedImage.PyramidalSize = new AForge.Size(gl.Width, gl.Height);
1301 // Use the new renderer - no more ReadPixels!
1302 _ = slideRenderer.UpdateViewAsync(
1304 gl.Width,
1305 gl.Height,
1306 Resolution,
1308 );
1309 return;
1310 }
1311 for (int i = 0; i < Bitmaps.Count; i++)
1312 {
1313 Bitmaps[i].Dispose();
1314 Bitmaps[i] = null;
1315 }
1316 Bitmaps.Clear();
1317 if (zBar.Maximum != SelectedImage.SizeZ - 1 || tBar.Maximum != SelectedImage.SizeT - 1)
1318 {
1319 InitGUI();
1320 }
1321
1322 int bi = 0;
1323 foreach (BioImage b in Images)
1324 {
1325 if (b.isPyramidal)
1326 updatePyr = true;
1327 b.PyramidalOrigin = PyramidalOrigin;
1328 b.PyramidalSize = new AForge.Size(gl.Width, gl.Height);
1329 ZCT coords = new ZCT(zBar.Value, cBar.Value, tBar.Value);
1330 Bitmap bitmap = null;
1331
1332 int index = b.Coords[zBar.Value, cBar.Value, tBar.Value];
1333 if (Mode == ViewMode.Filtered)
1334 {
1335 bitmap = b.GetFiltered(coords, b.RChannel.RangeR, b.GChannel.RangeG, b.BChannel.RangeB);
1336 }
1337 else if (Mode == ViewMode.RGBImage)
1338 {
1339 bitmap = b.GetRGBBitmap(coords, b.RChannel.RangeR, b.GChannel.RangeG, b.BChannel.RangeB);
1340 }
1341 else if (Mode == ViewMode.Raw)
1342 {
1343 bitmap = (Bitmap)b.Buffers[index].GetImageRGBA();
1344 }
1345 else
1346 {
1347 bitmap = b.GetEmission(coords, b.RChannel.RangeR, b.GChannel.RangeG, b.BChannel.RangeB);
1348 }
1349 Bitmaps.Add(ToSysBitmap(bitmap));
1350 bi++;
1351 }
1352 update = true;
1353 }

◆ UpdateOverlay()

void BioImager.ImageView.UpdateOverlay ( )

If hardware acceleration is enabled, render the frame. Otherwise, set a flag to update the overlay and invalidate the overlay picture box

Returns
The return value is the value of the last expression evaluated in the method.

Definition at line 970 of file ImageView.cs.

971 {
972 gl.Invalidate();
973 updateOverlay = true;
974 }

◆ UpdateRGBChannels()

void BioImager.ImageView.UpdateRGBChannels ( )

"If the user has selected a channel, then set the channel to the selected index, otherwise set it to 0."

The above function is called when the user changes the channel selection

Definition at line 841 of file ImageView.cs.

842 {
843 //Buf = image.GetBufByCoord(GetCoordinate());
844 if (channelBoxR.SelectedIndex == -1)
845 SelectedImage.rgbChannels[0] = 0;
846 else
847 SelectedImage.rgbChannels[1] = channelBoxR.SelectedIndex;
848 if (channelBoxG.SelectedIndex == -1)
849 SelectedImage.rgbChannels[1] = 0;
850 else
851 SelectedImage.rgbChannels[1] = channelBoxG.SelectedIndex;
852 if (channelBoxB.SelectedIndex == -1)
853 SelectedImage.rgbChannels[2] = 0;
854 else
855 SelectedImage.rgbChannels[2] = channelBoxB.SelectedIndex;
856
857 }

◆ UpdateSelectBoxSize()

void BioImager.ImageView.UpdateSelectBoxSize ( float size)

This function is called from the Unity Editor when the user changes the size of the select box

Parameters
sizeThe size of the box that will be drawn around the ROI.

Definition at line 962 of file ImageView.cs.

963 {
964 ROI.selectBoxSize = size;
965 }

◆ UpdateStatus()

void BioImager.ImageView.UpdateStatus ( )

It updates the status bar of the image viewer

Returns
The statusLabel.Text is being returned.

Definition at line 978 of file ImageView.cs.

979 {
980 if (SelectedImage == null)
981 return;
982 string res = "";
983 if (SelectedImage.Type == BioImage.ImageType.well)
984 res = "Well:" + SelectedImage.Level;
985 else if (SelectedImage.Type == BioImage.ImageType.pyramidal)
986 {
987 res = "Res.:" + Resolution + " Level:" + Level;
988 }
989 if (Mode == ViewMode.RGBImage)
990 {
991 if (timeEnabled)
992 {
993 statusLabel.Text = (zBar.Value + 1) + "/" + (zBar.Maximum + 1) + ", " + (tBar.Value + 1) + "/" + (tBar.Maximum + 1) + ", " +
994 mousePoint + mouseColor + ", " + SelectedImage.Buffers[0].PixelFormat.ToString() + ", (" + -Origin.X + ", " + -Origin.Y + "), (" + SelectedImage.Volume.Location.X + ", " + SelectedImage.Volume.Location.Y + ") " + res;
995 }
996 else
997 {
998 statusLabel.Text = (zBar.Value + 1) + "/" + (cBar.Maximum + 1) + ", " + mousePoint + mouseColor + ", " + SelectedImage.Buffers[0].PixelFormat.ToString()
999 + ", (" + -Origin.X + ", " + -Origin.Y + "), (" + SelectedImage.Volume.Location.X + ", " + SelectedImage.Volume.Location.Y + ") " + res;
1000 }
1001
1002 }
1003 else
1004 {
1005 if (timeEnabled)
1006 {
1007 statusLabel.Text = (zBar.Value + 1) + "/" + (zBar.Maximum + 1) + ", " + (cBar.Value + 1) + "/" + (cBar.Maximum + 1) + ", " + (tBar.Value + 1) + "/" + (tBar.Maximum + 1) + ", " +
1008 mousePoint + mouseColor + ", " + SelectedImage.Buffers[0].PixelFormat.ToString() + ", (" + -Origin.X + ", " + -Origin.Y + "), (" + SelectedImage.Volume.Location.X + ", " + SelectedImage.Volume.Location.Y + ") " + res;
1009 }
1010 else
1011 {
1012 statusLabel.Text = (zBar.Value + 1) + "/" + (zBar.Maximum + 1) + ", " + (cBar.Value + 1) + "/" + (cBar.Maximum + 1) + ", " + mousePoint + mouseColor + ", " +
1013 SelectedImage.Buffers[0].PixelFormat.ToString() + ", (" + -Origin.X + ", " + -Origin.Y + "), (" + SelectedImage.Volume.Location.X + ", " + SelectedImage.Volume.Location.Y + ") " + res;
1014 }
1015 }
1016 }

◆ UpdateView() [1/2]

void BioImager.ImageView.UpdateView ( )

If hardware acceleration is enabled, render the frame. Otherwise, invalidate the picture box.

Returns
The method is returning void.

Definition at line 1021 of file ImageView.cs.

1022 {
1023 UpdateStatus();
1024 update = true;
1025 UpdateImages();
1026 gl.Invalidate();
1027 }

◆ UpdateView() [2/2]

void BioImager.ImageView.UpdateView ( bool refresh)

It draws the images and annotations to the screen

Returns
A Bitmap

‍Update the status of the application and then render the frame

Parameters
refreshboolean

Definition at line 1277 of file ImageView.cs.

1278 {
1279 UpdateStatus();
1280 update = refresh;
1281 if (update)
1282 {
1283 gl.Invalidate();
1284 }
1285 }

Member Data Documentation

◆ Buf

Image BioImager.ImageView.Buf = null

Definition at line 294 of file ImageView.cs.

◆ down

bool BioImager.ImageView.down
static

Definition at line 277 of file ImageView.cs.

◆ filepath

string BioImager.ImageView.filepath = ""

Definition at line 364 of file ImageView.cs.

◆ Images

List<BioImage> BioImager.ImageView.Images = new List<BioImage>()

Definition at line 298 of file ImageView.cs.

◆ init

bool BioImager.ImageView.init = false

Definition at line 295 of file ImageView.cs.

◆ Layers

List<Layer> BioImager.ImageView.Layers = new List<Layer>()

Definition at line 230 of file ImageView.cs.

◆ loopC

bool BioImager.ImageView.loopC = true

Definition at line 370 of file ImageView.cs.

◆ loopT

bool BioImager.ImageView.loopT = true

Definition at line 369 of file ImageView.cs.

◆ loopZ

bool BioImager.ImageView.loopZ = true

Definition at line 368 of file ImageView.cs.

◆ minSizeX

int BioImager.ImageView.minSizeX = 50

Definition at line 366 of file ImageView.cs.

◆ minSizeY

int BioImager.ImageView.minSizeY = 20

Definition at line 367 of file ImageView.cs.

◆ mouseDown

PointD BioImager.ImageView.mouseDown
static

Definition at line 276 of file ImageView.cs.

◆ mouseDownButtons

MouseButtons BioImager.ImageView.mouseDownButtons
static

Definition at line 290 of file ImageView.cs.

◆ mouseUp

PointD BioImager.ImageView.mouseUp
static

Definition at line 278 of file ImageView.cs.

◆ mouseUpButtons

MouseButtons BioImager.ImageView.mouseUpButtons
static

Definition at line 289 of file ImageView.cs.

◆ selectedAnnotations

List<ROI> BioImager.ImageView.selectedAnnotations = new List<ROI>()
static

Definition at line 243 of file ImageView.cs.

◆ serie

int BioImager.ImageView.serie = 0

Definition at line 365 of file ImageView.cs.

◆ showBounds

bool BioImager.ImageView.showBounds = true
static

Definition at line 292 of file ImageView.cs.

◆ showBROIs

bool BioImager.ImageView.showBROIs = true

Definition at line 1910 of file ImageView.cs.

◆ showGROIs

bool BioImager.ImageView.showGROIs = true

Definition at line 1909 of file ImageView.cs.

◆ showRROIs

bool BioImager.ImageView.showRROIs = true

Definition at line 1908 of file ImageView.cs.

◆ showText

bool BioImager.ImageView.showText = true
static

Definition at line 293 of file ImageView.cs.

◆ up

bool BioImager.ImageView.up
static

Definition at line 279 of file ImageView.cs.

Property Documentation

◆ AnnotationsB

List<ROI> BioImager.ImageView.AnnotationsB
get

Definition at line 1929 of file ImageView.cs.

1930 {
1931 get
1932 {
1933 return SelectedImage.GetAnnotations(SelectedImage.Coordinate.Z, SelectedImage.BChannel.Index, SelectedImage.Coordinate.T);
1934 }
1935 }

◆ AnnotationsG

List<ROI> BioImager.ImageView.AnnotationsG
get

Definition at line 1921 of file ImageView.cs.

1922 {
1923 get
1924 {
1925 return SelectedImage.GetAnnotations(SelectedImage.Coordinate.Z, SelectedImage.GChannel.Index, SelectedImage.Coordinate.T);
1926 }
1927 }

◆ AnnotationsR

List<ROI> BioImager.ImageView.AnnotationsR
get

Definition at line 1913 of file ImageView.cs.

1914 {
1915 get
1916 {
1917 return SelectedImage.GetAnnotations(SelectedImage.Coordinate.Z, SelectedImage.RChannel.Index, SelectedImage.Coordinate.T);
1918 }
1919 }

◆ AnnotationsRGB

List<ROI> BioImager.ImageView.AnnotationsRGB
get

Definition at line 1936 of file ImageView.cs.

1937 {
1938 get
1939 {
1940 if (SelectedImage == null)
1941 return null;
1942 List<ROI> ans = new List<ROI>();
1943 if (Mode == ViewMode.RGBImage)
1944 {
1945 if (showRROIs)
1946 ans.AddRange(AnnotationsR);
1947 if (showGROIs)
1948 ans.AddRange(AnnotationsG);
1949 if (showBROIs)
1950 ans.AddRange(AnnotationsB);
1951 }
1952 else
1953 {
1954 ans.AddRange(SelectedImage.GetAnnotations(SelectedImage.Coordinate));
1955 }
1956 return ans;
1957 }
1958 }

◆ BChannel

Channel BioImager.ImageView.BChannel
get

Getting the B channel of the image. *‍/.

Definition at line 694 of file ImageView.cs.

695 {
696 get
697 {
698 return SelectedImage.Channels[SelectedImage.rgbChannels[2]];
699 }
700 }

◆ CFps

int BioImager.ImageView.CFps
getset

Setting the interval of the timer to the inverse of the fps. *‍/.

Definition at line 894 of file ImageView.cs.

895 {
896 get
897 {
898 return cfps;
899 }
900 set
901 {
902 cfps = value;
903 float f = value;
904 cTimer.Interval = (int)Math.Floor(1000 / f);
905 }
906 }

◆ Ctrl

bool BioImager.ImageView.Ctrl
staticget

Definition at line 280 of file ImageView.cs.

281 {
282 get
283 {
284 return Win32.GetKeyState(Keys.LControlKey);
285 }
286 }

◆ GChannel

Channel BioImager.ImageView.GChannel
get

A property that returns the G channel of the image. *‍/.

Definition at line 686 of file ImageView.cs.

687 {
688 get
689 {
690 return SelectedImage.Channels[SelectedImage.rgbChannels[1]];
691 }
692 }

◆ LabelResolution

int? BioImager.ImageView.LabelResolution
get

Definition at line 709 of file ImageView.cs.

709{ get { return SelectedImage.LabelResolution; } }

◆ Level

int BioImager.ImageView.Level
get

Current level when viewing whole-slide and pyramidal images.

Definition at line 795 of file ImageView.cs.

796 {
797 get
798 {
799 if (SelectedImage != null)
800 return SelectedImage.Level;
801 else
802 return 0;
803 }
804 }

◆ MacroResolution

int? BioImager.ImageView.MacroResolution
get

Definition at line 708 of file ImageView.cs.

708{ get { return SelectedImage.MacroResolution; } }

◆ Mode

ViewMode BioImager.ImageView.Mode
getset

Setting the view mode of the application. *‍/.

Definition at line 620 of file ImageView.cs.

621 {
622 get
623 {
624 return viewMode;
625 }
626 set
627 {
628 viewMode = value;
629 //If view mode is changed we update.
630 update = true;
631 UpdateImages();
632 App.tabsView.UpdateViewMode(viewMode);
633 UpdateView();
635 if (viewMode == ViewMode.RGBImage)
636 {
637 cBar.Value = 0;
638 rgbBoxsPanel.BringToFront();
639 cBar.SendToBack();
640 cLabel.SendToBack();
641 gl.BringToFront();
642 }
643 else
644 if (viewMode == ViewMode.Filtered)
645 {
646 rgbBoxsPanel.SendToBack();
647 cBar.BringToFront();
648 cLabel.BringToFront();
649 gl.BringToFront();
650 }
651 else
652 if (viewMode == ViewMode.Raw)
653 {
654 rgbBoxsPanel.SendToBack();
655 cBar.BringToFront();
656 cLabel.BringToFront();
657 gl.BringToFront();
658 }
659 else
660 {
661 cBar.Value = 0;
662 rgbBoxsPanel.BringToFront();
663 cBar.SendToBack();
664 cLabel.SendToBack();
665 gl.BringToFront();
666 }
667 }
668 }

◆ MouseDownInt

PointD BioImager.ImageView.MouseDownInt
getset

Definition at line 3268 of file ImageView.cs.

3269 {
3270 get { return mouseDownInt; }
3271 set { mouseDownInt = value; }
3272 }

◆ MouseMoveInt

PointD BioImager.ImageView.MouseMoveInt
getset

Definition at line 3280 of file ImageView.cs.

3281 {
3282 get { return mouseMoveInt; }
3283 set { mouseMoveInt = value; }
3284 }

◆ MouseUpInt

PointD BioImager.ImageView.MouseUpInt
getset

Definition at line 3274 of file ImageView.cs.

3275 {
3276 get { return mouseUpInt; }
3277 set { mouseUpInt = value; }
3278 }

◆ OpenSlide

bool BioImager.ImageView.OpenSlide
get

Definition at line 704 of file ImageView.cs.

705 {
706 get { return openSlide; }
707 }

◆ Origin

PointD BioImager.ImageView.Origin
getset

A property of the class PointD. *‍/.

Definition at line 726 of file ImageView.cs.

727 {
728 get { return origin; }
729 set
730 {
731 origin = value;
732 update = true;
733 UpdateView();
734 }
735 }

◆ OverView

Rectangle BioImager.ImageView.OverView
get

Definition at line 373 of file ImageView.cs.

374 {
375 get { return overview; }
376 }

◆ Path

string BioImager.ImageView.Path
get

A property that returns the filepath. *‍/.

Definition at line 670 of file ImageView.cs.

671 {
672 get
673 {
674 return filepath;
675 }
676 }

◆ PxHmicron

double BioImager.ImageView.PxHmicron
getset

Only used when opening stacks.

Definition at line 599 of file ImageView.cs.

600 {
601 get
602 {
603 return pxHmicron;
604 }
605 set
606 {
607 pxHmicron = value;
608 }
609 }

◆ PxWmicron

double BioImager.ImageView.PxWmicron
getset

Only used when opening stacks.

Definition at line 584 of file ImageView.cs.

585 {
586 get
587 {
588 return pxWmicron;
589 }
590 set
591 {
592 pxWmicron = value;
593 }
594 }

◆ PyramidalOrigin

PointD BioImager.ImageView.PyramidalOrigin
getset

Setting the value of the pyramidalOrigin variable. *‍/.

Definition at line 738 of file ImageView.cs.

739 {
740 get
741 {
742 return SelectedImage.PyramidalOrigin;
743 }
744 set
745 {
746 SelectedImage.PyramidalOrigin = value;
747 }
748 }

◆ PyramidalOriginTransformed

PointD BioImager.ImageView.PyramidalOriginTransformed
getset

Definition at line 3257 of file ImageView.cs.

3258 {
3259 get { return new PointD(PyramidalOrigin.X * Resolution, PyramidalOrigin.Y * Resolution); }
3260 set { PyramidalOrigin = new PointD(value.X / Resolution, value.Y / Resolution); }
3261 }

◆ RChannel

Channel BioImager.ImageView.RChannel
get

A property that returns the R channel of the selected image. *‍/.

Definition at line 678 of file ImageView.cs.

679 {
680 get
681 {
682 return SelectedImage.Channels[SelectedImage.rgbChannels[0]];
683 }
684 }

◆ Resolution

double BioImager.ImageView.Resolution
getset

A property of the class ImageViewer. It is a getter and setter for the resolution of the image.

Definition at line 751 of file ImageView.cs.

752 {
753 get
754 {
755 if (SelectedImage == null)
756 return 1;
757 return SelectedImage.Resolution;
758 }
759 set
760 {
761 double dp = Resolution / value;
762 SelectedImage.PyramidalOrigin = new PointD((dp * PyramidalOrigin.X), (dp * PyramidalOrigin.Y));
763 SelectedImage.Resolution = value;
764 if (SelectedImage.Type == BioImage.ImageType.well)
765 SelectedImage.Level = (int)value;
766 updatePyr = true;
767 }
768 }

◆ Scale

new AForge.SizeF BioImager.ImageView.Scale
getset

Scale when opening image stacks.

Definition at line 809 of file ImageView.cs.

810 {
811 get
812 {
813 return scale;
814 }
815 set
816 {
817 scale = value;
818 update = true;
819 UpdateView();
820 if (SelectedImage != null)
821 if (SelectedImage.isPyramidal)
822 {
823 Tools.selectBoxSize = (float)(ROI.selectBoxSize * Resolution);
824 }
825 else
826 Tools.selectBoxSize = ROI.selectBoxSize;
827 }
828 }

◆ SelectedBuffer

Bitmap BioImager.ImageView.SelectedBuffer
staticget

Definition at line 268 of file ImageView.cs.

269 {
270 get
271 {
272 int ind = SelectedImage.Coords[SelectedImage.Coordinate.Z, SelectedImage.Coordinate.C, SelectedImage.Coordinate.T];
273 return SelectedImage.Buffers[ind];
274 }
275 }

◆ SelectedImage

BioImage BioImager.ImageView.SelectedImage
staticgetset

Definition at line 245 of file ImageView.cs.

246 {
247 get
248 {
249 if (App.viewer != null)
250 {
251 if (App.viewer.Images.Count > 0)
252 return App.viewer.Images[selectedIndex];
253 else
254 return null;
255 }
256 else
257 return null;
258 }
259 set
260 {
261 if (App.viewer != null)
262 {
263 if (App.viewer.Images.Count > 0)
264 App.viewer.Images[selectedIndex] = value;
265 }
266 }
267 }

◆ SelectedIndex

int BioImager.ImageView.SelectedIndex = 0
getset

A property that is used to set the selected index of the image. *‍/.

Definition at line 350 of file ImageView.cs.

351 {
352 get;
353 set
354 {
355 if (value >= 0 && Images.Count > 0)
356 {
357 field = value;
358 selectedIndex = field;
359 InitGUI();
360 }
361 }
362 } = 0;

◆ ShowControls

bool BioImager.ImageView.ShowControls
getset

Setting the visibility of the trackBarPanel. *‍/.

Definition at line 510 of file ImageView.cs.

511 {
512 get { return trackBarPanel.Visible; }
513 set
514 {
515 showControls = value;
516 if (!value)
517 {
518 trackBarPanel.Hide();
519 if (ShowStatus)
520 {
521 gl.Top = 25;
522 gl.Height += 75;
523 }
524 else
525 {
526 gl.Top = 0;
527 gl.Height += 75;
528 }
529 hideControlsToolStripMenuItem1.Text = "Show Controls";
530 }
531 else
532 {
533 trackBarPanel.Show();
534 if (ShowStatus)
535 {
536 gl.Top = 25;
537 gl.Height -= 75;
538 }
539 else
540 {
541 gl.Top = 0;
542 gl.Height += 75;
543 }
544
545 //panel.Anchor = AnchorStyles.Top | AnchorStyles.Right | AnchorStyles.Bottom | AnchorStyles.Left;
546 hideControlsToolStripMenuItem1.Text = "Hide Controls";
547 }
548 UpdateView();
549 }
550 }
bool ShowStatus
Setting the value of the property ShowStatus. *‍/.
Definition ImageView.cs:556

◆ ShowMasks

bool BioImager.ImageView.ShowMasks = true
getset

Definition at line 3287 of file ImageView.cs.

3287{ get; set; } = true;

◆ ShowOverview

bool BioImager.ImageView.ShowOverview
getset

Definition at line 505 of file ImageView.cs.

505{ get; set; }

◆ ShowStage

bool BioImager.ImageView.ShowStage
getset

Definition at line 378 of file ImageView.cs.

378{ get; set; }

◆ ShowStatus

bool BioImager.ImageView.ShowStatus
getset

Setting the value of the property ShowStatus. *‍/.

Definition at line 555 of file ImageView.cs.

556 {
557 get { return showStatus; }
558 set
559 {
560 showStatus = true;
561 if (!value)
562 {
563 statusPanel.Hide();
564 gl.Top = 0;
565 gl.Height += 25;
566 showControlsToolStripMenuItem.Visible = true;
567 hideControlsToolStripMenuItem.Text = "Show Status";
568 }
569 else
570 {
571 statusPanel.Show();
572 statusPanel.Visible = value;
573 gl.Top = 25;
574 showControlsToolStripMenuItem.Visible = false;
575 hideControlsToolStripMenuItem.Text = "Hide Status";
576 }
577 }
578 }

◆ TimeFps

int BioImager.ImageView.TimeFps
getset

Setting the interval of the timer to the value of the timefps variable. *‍/.

Definition at line 878 of file ImageView.cs.

879 {
880 get
881 {
882 return timefps;
883 }
884 set
885 {
886 timefps = value;
887 float f = value;
888 timelineTimer.Interval = (int)Math.Floor(1000 / f);
889 }
890 }

◆ tools

Tools BioImager.ImageView.tools
get

Definition at line 363 of file ImageView.cs.

363{ get { return App.tools; } }

◆ ViewContextMenu

ContextMenuStrip BioImager.ImageView.ViewContextMenu
get

A property that returns a ContextMenuStrip object. *‍/.

Definition at line 830 of file ImageView.cs.

831 {
832 get
833 {
834 return contextMenuStrip;
835 }
836 }

◆ ViewHeight

int BioImager.ImageView.ViewHeight
get

Definition at line 717 of file ImageView.cs.

718 {
719 get
720 {
721 return gl.Height;
722 }
723 }

◆ ViewWidth

int BioImager.ImageView.ViewWidth
get

Definition at line 710 of file ImageView.cs.

711 {
712 get
713 {
714 return gl.Width;
715 }
716 }

◆ ZFps

int BioImager.ImageView.ZFps
getset

Setting the interval of the timer to the value of the fps. *‍/.

Definition at line 862 of file ImageView.cs.

863 {
864 get
865 {
866 return zfps;
867 }
868 set
869 {
870 zfps = value;
871 float f = value;
872 zTimer.Interval = (int)Math.Floor(1000 / f);
873 }
874 }

The documentation for this class was generated from the following files: