diff --git a/BioCore.sln b/BioCore.sln index c3a7167..0aaac19 100644 --- a/BioCore.sln +++ b/BioCore.sln @@ -11,8 +11,6 @@ Project("{54435603-DBB4-11D2-8724-00A0C9A8B90C}") = "BioCoreSetup", "..\BioCoreS EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PluginExampleWIN", "..\PluginExampleWIN\PluginExampleWIN.csproj", "{4350D3BC-54DE-439B-8544-C1BAAB8C1FC9}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenSlideGTK", "..\OpenSlideGTK\src\OpenSlideSharp\OpenSlideGTK.csproj", "{1675E8BA-EA48-4883-B7BA-CCA6211E9D21}" -EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -43,8 +41,8 @@ Global {633C711A-2C74-4DEE-9DA1-E2E2D7132E1B}.Debug|x86.Build.0 = Debug|Any CPU {633C711A-2C74-4DEE-9DA1-E2E2D7132E1B}.Release|Any CPU.ActiveCfg = Release|Any CPU {633C711A-2C74-4DEE-9DA1-E2E2D7132E1B}.Release|Any CPU.Build.0 = Release|Any CPU - {633C711A-2C74-4DEE-9DA1-E2E2D7132E1B}.Release|x64.ActiveCfg = Release|Any CPU - {633C711A-2C74-4DEE-9DA1-E2E2D7132E1B}.Release|x64.Build.0 = Release|Any CPU + {633C711A-2C74-4DEE-9DA1-E2E2D7132E1B}.Release|x64.ActiveCfg = Release|x64 + {633C711A-2C74-4DEE-9DA1-E2E2D7132E1B}.Release|x64.Build.0 = Release|x64 {633C711A-2C74-4DEE-9DA1-E2E2D7132E1B}.Release|x86.ActiveCfg = Release|Any CPU {633C711A-2C74-4DEE-9DA1-E2E2D7132E1B}.Release|x86.Build.0 = Release|Any CPU {9F71BCBA-FB42-48F3-8CE2-B492365008A6}.Debug|Any CPU.ActiveCfg = Debug @@ -70,18 +68,6 @@ Global {4350D3BC-54DE-439B-8544-C1BAAB8C1FC9}.Release|x64.Build.0 = Release|Any CPU {4350D3BC-54DE-439B-8544-C1BAAB8C1FC9}.Release|x86.ActiveCfg = Release|Any CPU {4350D3BC-54DE-439B-8544-C1BAAB8C1FC9}.Release|x86.Build.0 = Release|Any CPU - {1675E8BA-EA48-4883-B7BA-CCA6211E9D21}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {1675E8BA-EA48-4883-B7BA-CCA6211E9D21}.Debug|Any CPU.Build.0 = Debug|Any CPU - {1675E8BA-EA48-4883-B7BA-CCA6211E9D21}.Debug|x64.ActiveCfg = Debug|x64 - {1675E8BA-EA48-4883-B7BA-CCA6211E9D21}.Debug|x64.Build.0 = Debug|x64 - {1675E8BA-EA48-4883-B7BA-CCA6211E9D21}.Debug|x86.ActiveCfg = Debug|Any CPU - {1675E8BA-EA48-4883-B7BA-CCA6211E9D21}.Debug|x86.Build.0 = Debug|Any CPU - {1675E8BA-EA48-4883-B7BA-CCA6211E9D21}.Release|Any CPU.ActiveCfg = Release|Any CPU - {1675E8BA-EA48-4883-B7BA-CCA6211E9D21}.Release|Any CPU.Build.0 = Release|Any CPU - {1675E8BA-EA48-4883-B7BA-CCA6211E9D21}.Release|x64.ActiveCfg = Release|x64 - {1675E8BA-EA48-4883-B7BA-CCA6211E9D21}.Release|x64.Build.0 = Release|x64 - {1675E8BA-EA48-4883-B7BA-CCA6211E9D21}.Release|x86.ActiveCfg = Release|Any CPU - {1675E8BA-EA48-4883-B7BA-CCA6211E9D21}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/BioCore/BioCore.csproj b/BioCore/BioCore.csproj index 1b03698..708cd31 100644 --- a/BioCore/BioCore.csproj +++ b/BioCore/BioCore.csproj @@ -80,6 +80,7 @@ all runtime; build; native; contentfiles; analyzers; buildtransitive + @@ -125,7 +126,4 @@ \ - - - diff --git a/BioCore/Source/Bio.cs b/BioCore/Source/Bio.cs index 12fe0cb..40774e1 100644 --- a/BioCore/Source/Bio.cs +++ b/BioCore/Source/Bio.cs @@ -5846,11 +5846,6 @@ public PointD PyramidalOrigin get { return pyramidalOrigin; } set { - if (Resolutions[Level].SizeX < value.X || Resolutions[Level].SizeY < value.Y || value.X < 0 || value.Y < 0) - { - pyramidalOrigin = new PointD(Resolutions[Level].SizeX - s.Width, Resolutions[Level].SizeY - s.Height); - return; - } pyramidalOrigin = value; } } @@ -5945,7 +5940,9 @@ public void UpdateBuffersPyramidal() if (openSlideImage != null) { byte[] bts = openSlideBase.GetSlice(new OpenSlideGTK.SliceInfo(PyramidalOrigin.X, PyramidalOrigin.Y, PyramidalSize.Width, PyramidalSize.Height, resolution)); - Buffers.Add(new BufferInfo((int)Math.Round(OpenSlideBase.destExtent.Width), (int)Math.Round(OpenSlideBase.destExtent.Height), PixelFormat.Format24bppRgb, bts, new ZCT(), "")); + BufferInfo bf = new BufferInfo((int)Math.Round(OpenSlideBase.destExtent.Width), (int)Math.Round(OpenSlideBase.destExtent.Height), PixelFormat.Format24bppRgb, bts, new ZCT(), ""); + bf.Stats = Statistics.FromBytes(bf); + Buffers.Add(bf); } else { @@ -5960,10 +5957,12 @@ public void UpdateBuffersPyramidal() pyramidalOrigin = new PointD(0, 0); goto start; } - Buffers.Add(new BufferInfo((int)Math.Round(SlideBase.destExtent.Width), (int)Math.Round(SlideBase.destExtent.Height), PixelFormat.Format24bppRgb, bts, new ZCT(), "")); + BufferInfo bf = new BufferInfo((int)Math.Round(SlideBase.destExtent.Width), (int)Math.Round(SlideBase.destExtent.Height), PixelFormat.Format24bppRgb, bts, new ZCT(), ""); + bf.Stats = Statistics.FromBytes(bf); + Buffers.Add(bf); } } - BioImage.AutoThreshold(this, true); + BioImage.AutoThreshold(this, false); if (bitsPerPixel > 8) StackThreshold(true); else @@ -9522,7 +9521,7 @@ public static BioImage FolderToStack(string path) Recorder.AddLine("BioImage.FolderToStack(\"" + path + "\");"); return b; } - public static BioImage OpenOME(string file, int serie, bool tab, bool addToImages, bool tile, int tilex, int tiley, int tileSizeX, int tileSizeY, bool useOpenSlide = false) + public static BioImage OpenOME(string file, int serie, bool tab, bool addToImages, bool tile, int tilex, int tiley, int tileSizeX, int tileSizeY, bool useOpenSlide = true) { if (file == null || file == "") throw new InvalidDataException("File is empty or null"); diff --git a/BioCore/Source/Bio/ISlideSource.cs b/BioCore/Source/Bio/ISlideSource.cs index b035280..6d5c449 100644 --- a/BioCore/Source/Bio/ISlideSource.cs +++ b/BioCore/Source/Bio/ISlideSource.cs @@ -85,7 +85,7 @@ public virtual byte[] GetSlice(SliceInfo sliceInfo) var dstPixelWidth = sliceInfo.Parame.DstPixelWidth > 0 ? sliceInfo.Parame.DstPixelWidth : dstPixelExtent.Width; destExtent = new Extent(0, 0, dstPixelWidth, dstPixelHeight); sourceExtent = srcPixelExtent; - /* + if (UseVips) { try @@ -101,7 +101,7 @@ public virtual byte[] GetSlice(SliceInfo sliceInfo) Console.WriteLine(e.Message); } } - */ + try { Image im = OpenSlideGTK.ImageUtil.Join(tiles, srcPixelExtent, new Extent(0, 0, dstPixelWidth, dstPixelHeight)); diff --git a/BioCore/Source/ImageView.cs b/BioCore/Source/ImageView.cs index 28682e9..21f1a04 100644 --- a/BioCore/Source/ImageView.cs +++ b/BioCore/Source/ImageView.cs @@ -6,6 +6,7 @@ using BioCore.Graphics; using Point = System.Drawing.Point; using AForge.Imaging.Filters; +using org.checkerframework.checker.units.qual; namespace BioCore { @@ -674,7 +675,7 @@ public int Level if (!openSlide) l = SelectedImage.Level; else - l = OpenSlideGTK.TileUtil.GetLevel(_slideBase.Schema.Resolutions, Resolution); + l = OpenSlideGTK.TileUtil.GetLevel(_openSlideBase.Schema.Resolutions, Resolution); return l; } } @@ -695,10 +696,7 @@ public int Level if (SelectedImage != null) if (SelectedImage.isPyramidal) { - if (openSlide) - Tools.selectBoxSize = (float)(ROI.selectBoxSize * Resolution); - else - Tools.selectBoxSize = ROI.selectBoxSize; + Tools.selectBoxSize = (float)(ROI.selectBoxSize * Resolution); } else Tools.selectBoxSize = ROI.selectBoxSize * Scale.Width; @@ -1947,10 +1945,7 @@ private void DrawOverlay(System.Drawing.Graphics g) float width = (float)ToViewSizeW(ROI.selectBoxSize / w); if (SelectedImage.isPyramidal) { - if (openSlide) - width = (float)(ROI.selectBoxSize * Resolution); - else - width = ROI.selectBoxSize; + width = (float)(ROI.selectBoxSize * Resolution); } if (an.type == ROI.Type.Point) { @@ -2422,7 +2417,8 @@ private void pictureBox_MouseDown(object sender, MouseEventArgs e) { if (!OpenSlide) { - double dsx = SelectedImage.GetUnitPerPixel(Level) / Resolution; + double up = SelectedImage.GetUnitPerPixel(Level); + double dsx = (SelectedImage.PhysicalSizeX / Resolution); Resolution rs = SelectedImage.Resolutions[(int)Level]; double dx = ((double)e.X / overview.Width) * (rs.SizeX * dsx); double dy = ((double)e.Y / overview.Height) * (rs.SizeY * dsx); @@ -2468,7 +2464,7 @@ private void pictureBox_MouseDown(object sender, MouseEventArgs e) { float width = (float)ToViewSizeW(ROI.selectBoxSize / Scale.Width); float height = (float)ToViewSizeH(ROI.selectBoxSize / Scale.Height); - if (openSlide) + if (SelectedImage.isPyramidal) { width = Tools.selectBoxSize; height = Tools.selectBoxSize; @@ -2749,12 +2745,7 @@ public PointD ImageToViewSpace(double x, double y) { if (SelectedImage.isPyramidal) { - if (openSlide) - { - return new PointD((PyramidalOrigin.X + x) * Resolution, (PyramidalOrigin.Y + y) * Resolution); - } - else - return new PointD(PyramidalOrigin.X + x, PyramidalOrigin.Y + y); + return new PointD((PyramidalOrigin.X + x) * Resolution, (PyramidalOrigin.Y + y) * Resolution); } else return ToViewSpace(x, y); @@ -2788,14 +2779,9 @@ public PointD ToViewSpace(double x, double y) { if (SelectedImage.isPyramidal) { - if (openSlide) - { - double ddx = x / Resolution; - double ddy = y / Resolution; - return new PointD(ddx, ddy); - } - else - return new PointD(PyramidalOrigin.X + x, PyramidalOrigin.Y + y); + double ddx = x / Resolution; + double ddy = y / Resolution; + return new PointD(ddx, ddy); } double dx = (ToViewSizeW(x - (pictureBox.Width / 2)) / Scale.Width) - Origin.X; @@ -2809,7 +2795,7 @@ public PointD ToViewSpace(double x, double y) /// @return The return value is the size of the object in pixels. private double ToViewSizeW(double d) { - if (openSlide) + if (SelectedImage.isPyramidal) { return d / Resolution; } @@ -2823,7 +2809,7 @@ private double ToViewSizeW(double d) /// @return The return value is the size of the object in pixels. public double ToViewSizeH(double d) { - if (openSlide) + if (SelectedImage.isPyramidal) { return d / Resolution; } @@ -2960,29 +2946,13 @@ public PointF ToScreenScale(PointD p) public System.Drawing.RectangleF ToScreenRectF(double x, double y, double w, double h) { if (SelectedImage == null) - { - PointD pf; - if (HardwareAcceleration) - { - double dx = (pxWmicron * (-Origin.X)) * Scale.Width; - double dy = (pxHmicron * (-Origin.Y)) * Scale.Height; - System.Drawing.RectangleF rf = new System.Drawing.RectangleF((float)(PxWmicron * -x * Scale.Width + dx), (float)(PxHmicron * -y * Scale.Height + dy), (float)(PxWmicron * -w * Scale.Width), (float)(PxHmicron * -h * Scale.Height)); - return rf; - } - pf = ToScreenSpace(x, y); - return new System.Drawing.RectangleF((float)pf.X, (float)pf.Y, ToScreenScaleW(w), ToScreenScaleH(h)); - } + return new RectangleF(); if (SelectedImage.isPyramidal) { - if (openSlide) - { - PointD d = ToViewSpace(x, y); - double dw = ToViewSizeW(w); - double dh = ToViewSizeH(h); - return new System.Drawing.RectangleF((float)(d.X - PyramidalOrigin.X), (float)(d.Y - PyramidalOrigin.Y), (float)dw, (float)dh); - } - else - return new System.Drawing.RectangleF((float)(x - pyramidalOrigin.X), (float)(y - pyramidalOrigin.Y), (float)w, (float)h); + PointD d = ToViewSpace(x, y); + double dw = ToViewSizeW(w); + double dh = ToViewSizeH(h); + return new System.Drawing.RectangleF((float)(d.X - PyramidalOrigin.X), (float)(d.Y - PyramidalOrigin.Y), (float)dw, (float)dh); } else { @@ -3081,10 +3051,6 @@ public PointF[] ToScreenSpace(PointD[] p) /// @return The return value is a float. public float ToScreenW(double x) { - if (HardwareAcceleration) - { - return (float)(x * PxWmicron); - } return (float)(x * PxWmicron); } /// > Convert a value in microns to a value in pixels @@ -3094,10 +3060,6 @@ public float ToScreenW(double x) /// @return The return value is a float. public float ToScreenH(double y) { - if (HardwareAcceleration) - { - return (float)(y * PxHmicron); - } return (float)(y * PxHmicron); } /// If the user presses the "C" key while holding down the "Control" key, then the function @@ -3216,6 +3178,7 @@ public void GoToImage(int i) { int lev = MacroResolution.Value - 1; Resolution = Math.Round(SelectedImage.GetUnitPerPixel(lev),2); + PyramidalOrigin = new PointD(0, 0); } else {