From c7bf8fb1adfe73db308d727cafa6b77511e27d6d Mon Sep 17 00:00:00 2001
From: Erik Repo <84872500+BiologyTools@users.noreply.github.com>
Date: Mon, 6 Jan 2025 19:32:54 +0200
Subject: [PATCH] 3.4.1 OMERO Support.
---
BioGTK.csproj | 11 ++++-------
Source/ImageView.cs | 34 ++++++++++------------------------
Source/OMERO.cs | 3 +++
3 files changed, 17 insertions(+), 31 deletions(-)
diff --git a/BioGTK.csproj b/BioGTK.csproj
index 6fa376a..e5fe22f 100644
--- a/BioGTK.csproj
+++ b/BioGTK.csproj
@@ -427,6 +427,7 @@
+
@@ -439,18 +440,14 @@
all
runtime; build; native; contentfiles; analyzers; buildtransitive
-
+
-
-
-
-
-
-
+
+
diff --git a/Source/ImageView.cs b/Source/ImageView.cs
index cf0e679..40f5ad1 100644
--- a/Source/ImageView.cs
+++ b/Source/ImageView.cs
@@ -346,8 +346,10 @@ private async void Render(object sender, SkiaSharp.Views.Desktop.SKPaintSurfaceE
canvas.DrawImage(SKImages[i], 0, 0, paint);
if (overviewImage != null)
{
+ var ims = BitmapToSKImage(overviewImage.GetImageRGB());
+ paint.Style = SKPaintStyle.Fill;
// Draw the overview image at the top-left corner
- canvas.DrawImage(BitmapToSKImage(overviewImage), 0, 0, paint);
+ canvas.DrawImage(ims, 0, 0, paint);
}
// Set the paint style to stroke for drawing rectangles
paint.Style = SKPaintStyle.Stroke;
@@ -355,27 +357,13 @@ private async void Render(object sender, SkiaSharp.Views.Desktop.SKPaintSurfaceE
paint.Color = SKColors.Gray;
canvas.DrawRect(overview.X, overview.Y, overview.Width, overview.Height, paint);
paint.Color = SKColors.Red;
- if (!openSlide)
- {
- double dsx = _slideBase.Schema.Resolutions[Level].UnitsPerPixel / Resolution;
- Resolution rs = SelectedImage.Resolutions[Level];
- double dx = ((double)PyramidalOrigin.X / (rs.SizeX * dsx)) * overview.Width;
- double dy = ((double)PyramidalOrigin.Y / (rs.SizeY * dsx)) * overview.Height;
- double dw = ((double)viewStack.AllocatedWidth / (rs.SizeX)) * overview.Width * dsx;
- double dh = ((double)viewStack.AllocatedHeight / (rs.SizeY)) * overview.Height * dsx;
- canvas.DrawRect((int)dx, (int)dy, (int)dw, (int)dh, paint);
- }
- else
- {
- double dsx = _openSlideBase.Schema.Resolutions[Level].UnitsPerPixel / Resolution;
- var rs = _openSlideBase.Schema.Resolutions.Last();
- Resolution rss = SelectedImage.Resolutions[Level];
- double dx = ((double)PyramidalOrigin.X / (rss.SizeX * dsx)) * overview.Width;
- double dy = ((double)PyramidalOrigin.Y / (rss.SizeY * dsx)) * overview.Height;
- double dw = ((double)viewStack.AllocatedWidth / (rss.SizeX * dsx)) * overview.Width;
- double dh = ((double)viewStack.AllocatedHeight / (rss.SizeY * dsx)) * overview.Height;
- canvas.DrawRect((int)dx, (int)dy, (int)dw, (int)dh, paint);
- }
+ double dsx = _slideBase.Schema.Resolutions[Level].UnitsPerPixel / Resolution;
+ Resolution rs = SelectedImage.Resolutions[Level];
+ double dx = ((double)PyramidalOrigin.X / (rs.SizeX * dsx)) * overview.Width;
+ double dy = ((double)PyramidalOrigin.Y / (rs.SizeY * dsx)) * overview.Height;
+ double dw = ((double)viewStack.AllocatedWidth / (rs.SizeX)) * overview.Width * dsx;
+ double dh = ((double)viewStack.AllocatedHeight / (rs.SizeY)) * overview.Height * dsx;
+ canvas.DrawRect((int)dx, (int)dy, (int)dw, (int)dh, paint);
}
}
catch (Exception ex)
@@ -832,7 +820,6 @@ private void InitPreview()
Bitmap bm = BioImage.GetTile(SelectedImage, SelectedImage.GetFrameIndex(GetCoordinate().Z, GetCoordinate().C, GetCoordinate().T), MacroResolution.Value - 2, 0, 0, SelectedImage.Resolutions[MacroResolution.Value - 2].SizeX, SelectedImage.Resolutions[MacroResolution.Value - 2].SizeY);
ResizeBilinear re = new ResizeBilinear(overview.Width, overview.Height);
Bitmap bmp = re.Apply(bm.GetImageRGB());
- bmp.SwitchRedBlue();
overviewImage = bmp;
}
else
@@ -851,7 +838,6 @@ private void InitPreview()
Bitmap bm = BioImage.GetTile(SelectedImage, SelectedImage.GetFrameIndex(GetCoordinate().Z, GetCoordinate().C, GetCoordinate().T), lev, 0, 0, SelectedImage.Resolutions[lev].SizeX, SelectedImage.Resolutions[lev].SizeY);
ResizeBilinear re = new ResizeBilinear(overview.Width, overview.Height);
Bitmap bmp = re.Apply(bm.GetImageRGB());
- bmp.SwitchRedBlue();
overviewImage = bmp;
}
ShowOverview = true;
diff --git a/Source/OMERO.cs b/Source/OMERO.cs
index 93ef2fb..83598f7 100644
--- a/Source/OMERO.cs
+++ b/Source/OMERO.cs
@@ -68,6 +68,7 @@ protected OMERO(Builder builder, IntPtr handle) : base(handle)
private void View_ItemActivated(object o, ItemActivatedArgs args)
{
+ BioLib.OMERO.ReConnect();
TreePath path = args.Path;
store.GetIter(out TreeIter iter, path);
string selectedItem;
@@ -154,6 +155,8 @@ private void InitIcons()
if (db.getId() == long.Parse(sts[1]))
continue;
List str = BioLib.OMERO.GetDatasetIds(db.getId());
+ if (str.Count == 0)
+ BioLib.OMERO.ReConnect();
foreach (var item in str)
{
Image image = new Image();