Skip to content

Commit

Permalink
4.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
BiologyTools committed Jul 30, 2024
1 parent 1593e71 commit 5a371b1
Show file tree
Hide file tree
Showing 7 changed files with 109 additions and 72 deletions.
22 changes: 18 additions & 4 deletions BioCore.sln
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BioCoreApp", "..\BioCoreApp
EndProject
Project("{54435603-DBB4-11D2-8724-00A0C9A8B90C}") = "BioCoreSetup", "..\BioCoreSetup\BioCoreSetup\BioCoreSetup.vdproj", "{9F71BCBA-FB42-48F3-8CE2-B492365008A6}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BioLib", "..\BioLib\BioLib.csproj", "{C7A4FE0F-B632-48C8-AFD4-573973CC7E92}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -19,8 +21,8 @@ Global
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{9A5177C9-401B-44C3-8F2E-D4327A25DDCC}.Debug|Any CPU.ActiveCfg = Debug|x64
{9A5177C9-401B-44C3-8F2E-D4327A25DDCC}.Debug|Any CPU.Build.0 = Debug|x64
{9A5177C9-401B-44C3-8F2E-D4327A25DDCC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{9A5177C9-401B-44C3-8F2E-D4327A25DDCC}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9A5177C9-401B-44C3-8F2E-D4327A25DDCC}.Debug|x64.ActiveCfg = Debug|x64
{9A5177C9-401B-44C3-8F2E-D4327A25DDCC}.Debug|x64.Build.0 = Debug|x64
{9A5177C9-401B-44C3-8F2E-D4327A25DDCC}.Debug|x86.ActiveCfg = Debug|x86
Expand All @@ -31,8 +33,8 @@ Global
{9A5177C9-401B-44C3-8F2E-D4327A25DDCC}.Release|x64.Build.0 = Release|x64
{9A5177C9-401B-44C3-8F2E-D4327A25DDCC}.Release|x86.ActiveCfg = Release|x86
{9A5177C9-401B-44C3-8F2E-D4327A25DDCC}.Release|x86.Build.0 = Release|x86
{633C711A-2C74-4DEE-9DA1-E2E2D7132E1B}.Debug|Any CPU.ActiveCfg = Debug|x64
{633C711A-2C74-4DEE-9DA1-E2E2D7132E1B}.Debug|Any CPU.Build.0 = Debug|x64
{633C711A-2C74-4DEE-9DA1-E2E2D7132E1B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{633C711A-2C74-4DEE-9DA1-E2E2D7132E1B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{633C711A-2C74-4DEE-9DA1-E2E2D7132E1B}.Debug|x64.ActiveCfg = Debug|Any CPU
{633C711A-2C74-4DEE-9DA1-E2E2D7132E1B}.Debug|x64.Build.0 = Debug|Any CPU
{633C711A-2C74-4DEE-9DA1-E2E2D7132E1B}.Debug|x86.ActiveCfg = Debug|Any CPU
Expand All @@ -55,6 +57,18 @@ Global
{9F71BCBA-FB42-48F3-8CE2-B492365008A6}.Release|x64.Build.0 = Release
{9F71BCBA-FB42-48F3-8CE2-B492365008A6}.Release|x86.ActiveCfg = Release
{9F71BCBA-FB42-48F3-8CE2-B492365008A6}.Release|x86.Build.0 = Release
{C7A4FE0F-B632-48C8-AFD4-573973CC7E92}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C7A4FE0F-B632-48C8-AFD4-573973CC7E92}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C7A4FE0F-B632-48C8-AFD4-573973CC7E92}.Debug|x64.ActiveCfg = Debug|x64
{C7A4FE0F-B632-48C8-AFD4-573973CC7E92}.Debug|x64.Build.0 = Debug|x64
{C7A4FE0F-B632-48C8-AFD4-573973CC7E92}.Debug|x86.ActiveCfg = Debug|Any CPU
{C7A4FE0F-B632-48C8-AFD4-573973CC7E92}.Debug|x86.Build.0 = Debug|Any CPU
{C7A4FE0F-B632-48C8-AFD4-573973CC7E92}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C7A4FE0F-B632-48C8-AFD4-573973CC7E92}.Release|Any CPU.Build.0 = Release|Any CPU
{C7A4FE0F-B632-48C8-AFD4-573973CC7E92}.Release|x64.ActiveCfg = Release|x64
{C7A4FE0F-B632-48C8-AFD4-573973CC7E92}.Release|x64.Build.0 = Release|x64
{C7A4FE0F-B632-48C8-AFD4-573973CC7E92}.Release|x86.ActiveCfg = Release|Any CPU
{C7A4FE0F-B632-48C8-AFD4-573973CC7E92}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
4 changes: 3 additions & 1 deletion BioCore/BioCore.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="BioLib" Version="2.5.0" />
<PackageReference Include="FlaUI.Core" Version="4.0.0" />
<PackageReference Include="FlaUI.UIA3" Version="4.0.0" />
<PackageReference Include="H.InputSimulator" Version="1.4.2" />
Expand Down Expand Up @@ -122,6 +121,9 @@
<PackagePath>\</PackagePath>
</None>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\BioLib\BioLib.csproj" />
</ItemGroup>
<ItemGroup>
<Using Include="AForge.Bitmap">
<Alias>Bitmap</Alias>
Expand Down
11 changes: 6 additions & 5 deletions BioCore/Source/ColorTool.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,21 @@ namespace BioCore
{
public partial class ColorTool : Form
{
private ColorS color = new ColorS(65535, 65535, 65535);
private int bitsPerPixel = 16;
private ColorS colors = new ColorS(65535, 65535, 65535);
private int bitsPerPx = 16;
/* A property. */
public ColorS Color
{
get
{
return color;
return colors;
}
set
{
color = value;
colors = value;
}
}

/*
/// It updates the GUI
public void UpdateGUI()
{
Expand All @@ -39,6 +39,7 @@ public void UpdateGUI()
if (bBar.Value != blueBox.Value)
blueBox.Value = bBar.Value;
}
*/
/* A constructor. */
public ColorTool()
{
Expand Down
18 changes: 7 additions & 11 deletions BioCore/Source/ImageJ.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@
using System.IO;
using CSScripting;
using AForge;
using Color = AForge.Color;
using RectangleD = AForge.RectangleD;
using BioLib;
namespace BioCore
{
public class ImageJ
Expand Down Expand Up @@ -99,7 +98,7 @@ internal static void Initialize()
}
public static List<Macro.Command> Macros = new List<Macro.Command>();
public static List<Process> processes = new List<Process>();
public static string ImageJPath = Settings.GetSettings("ImageJPath");
public static string ImageJPath = Properties.Settings.Default.ImageJPath;
private static Random rng = new Random();
static bool init = false;
public static bool Initialized { get { return init; } private set { } }
Expand Down Expand Up @@ -274,10 +273,7 @@ public static bool SetImageJPath()
return true;
}
else
{
ImageJPath = Properties.Settings.Default.ImageJPath;
return true;
}
}

/* It reads a binary file and returns a ROI object */
Expand Down Expand Up @@ -726,14 +722,14 @@ void getStrokeWidthAndColor(ROI roi, int hdr2Offset, bool scaleStrokeWidth)
if (strokeColor != 0)
{
byte[] bts = BitConverter.GetBytes(strokeColor);
Color c = Color.FromArgb(bts[0], bts[1], bts[2], bts[3]);
AForge.Color c = AForge.Color.FromArgb(bts[0], bts[1], bts[2], bts[3]);
roi.strokeColor = c;
}
int fillColor = getInt(FILL_COLOR);
if (fillColor != 0)
{
byte[] bts = BitConverter.GetBytes(strokeColor);
Color c = Color.FromArgb(bts[0], bts[1], bts[2], bts[3]);
AForge.Color c = AForge.Color.FromArgb(bts[0], bts[1], bts[2], bts[3]);
roi.fillColor = c;
}
}
Expand Down Expand Up @@ -1411,10 +1407,10 @@ void saveStrokeWidthAndColor(ROI roi)
//BasicStroke stroke = roi.getStroke();
//if (stroke != null)
putShort(RoiDecoder.STROKE_WIDTH, (int)roi.strokeWidth);
Color strokeColor = roi.strokeColor;
AForge.Color strokeColor = roi.strokeColor;
int intColor = (strokeColor.R << 16) | (strokeColor.G << 8) | (strokeColor.B);
putInt(RoiDecoder.STROKE_COLOR, 0);
Color fillColor = roi.fillColor;
AForge.Color fillColor = roi.fillColor;
int intFillColor = (fillColor.R << 16) | (fillColor.G << 8) | (fillColor.B);
putInt(RoiDecoder.FILL_COLOR, 0);
}
Expand Down Expand Up @@ -1553,7 +1549,7 @@ void putHeader2(ROI roi, int hdr2Offset)
putInt(hdr2Offset + RoiDecoder.Z_POSITION, roi.coord.Z + 1);
putInt(hdr2Offset + RoiDecoder.T_POSITION, roi.coord.T + 1);
//Overlay proto = roi.getPrototypeOverlay();
Color overlayLabelColor = roi.strokeColor; //proto.getLabelColor();
AForge.Color overlayLabelColor = roi.strokeColor; //proto.getLabelColor();
int intColor = (overlayLabelColor.R << 16) | (overlayLabelColor.G << 8) | (overlayLabelColor.B);
//if (overlayLabelColor != null)
putInt(hdr2Offset + RoiDecoder.OVERLAY_LABEL_COLOR, 0);
Expand Down
55 changes: 31 additions & 24 deletions BioCore/Source/ImageView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -313,34 +313,42 @@ public void AddImage(BioImage im)
/// </summary>
private void InitPreview()
{
if (SelectedImage.Resolutions.Count == 1)
if (!SelectedImage.isPyramidal)
return;
overview = new Rectangle(0, 0, 120, 120);
Resolution res;
if (!MacroResolution.HasValue)
res = SelectedImage.Resolutions.Last();
else
res = SelectedImage.Resolutions[MacroResolution.Value];
int aspx = res.SizeX / 10;
int aspy = res.SizeY / 10;
overview = new Rectangle(0, 0, aspx, aspy);
Bitmap bm;
ResizeNearestNeighbor re = new ResizeNearestNeighbor(overview.Width, overview.Height);
byte[] bts;
Bitmap bf;
if (_openSlideBase != null)
{
bts = _openSlideBase.GetSlice(new OpenSlideGTK.SliceInfo(0, 0, res.SizeX, res.SizeY, SelectedImage.GetUnitPerPixel(SelectedImage.Resolutions.Count - 1)));
bf = new Bitmap((int)Math.Round(OpenSlideBase.destExtent.Width), (int)Math.Round(OpenSlideBase.destExtent.Height), PixelFormat.Format24bppRgb, bts, new ZCT(), "");
if (MacroResolution.HasValue)
{
double aspx = (double)SelectedImage.Resolutions[MacroResolution.Value - 1].SizeX / (double)SelectedImage.Resolutions[MacroResolution.Value - 1].SizeY;
double aspy = (double)SelectedImage.Resolutions[MacroResolution.Value - 1].SizeY / (double)SelectedImage.Resolutions[MacroResolution.Value - 1].SizeX;
overview = new Rectangle(0, 0, (int)(aspx * 120), (int)(aspy * 120));
Bitmap bm = BioImage.GetTile(SelectedImage, GetCoordinate(), MacroResolution.Value - 1, 0, 0, SelectedImage.Resolutions[MacroResolution.Value - 1].SizeX, SelectedImage.Resolutions[MacroResolution.Value - 1].SizeY);
ResizeNearestNeighbor re = new ResizeNearestNeighbor(overview.Width, overview.Height);
Bitmap bmp = re.Apply((Bitmap)bm.ImageRGB);
overviewBitmap = bmp;
}
else
{
bts = _slideBase.GetSlice(new BioLib.SliceInfo(0, 0, res.SizeX, res.SizeY, SelectedImage.GetUnitPerPixel(SelectedImage.Resolutions.Count - 1), GetCoordinate())).Result;
bf = new Bitmap((int)Math.Round(SlideBase.destExtent.Width), (int)Math.Round(SlideBase.destExtent.Height), PixelFormat.Format24bppRgb, bts, new ZCT(), "");
Resolution res = SelectedImage.Resolutions.Last();
double aspx = (double)res.SizeX / (double)res.SizeY;
double aspy = (double)res.SizeY / (double)res.SizeX;
overview = new Rectangle(0, 0, (int)(aspx * 120), (int)(aspy * 120));
Bitmap bm;
ResizeNearestNeighbor re = new ResizeNearestNeighbor(overview.Width, overview.Height);
byte[] bts;
Bitmap bf;
if (_openSlideBase != null)
{
bts = _openSlideBase.GetSlice(new OpenSlideGTK.SliceInfo(PyramidalOrigin.X, PyramidalOrigin.Y, SelectedImage.PyramidalSize.Width, SelectedImage.PyramidalSize.Height, SelectedImage.GetUnitPerPixel(Level)));
bf = new Bitmap((int)Math.Round(OpenSlideBase.destExtent.Width), (int)Math.Round(OpenSlideBase.destExtent.Height), PixelFormat.Format24bppRgb, bts, new ZCT(), "");
}
else
{
bts = _slideBase.GetSlice(new BioLib.SliceInfo(PyramidalOrigin.X, PyramidalOrigin.Y, SelectedImage.PyramidalSize.Width, SelectedImage.PyramidalSize.Height, SelectedImage.GetUnitPerPixel(Level), GetCoordinate())).Result;
bf = new Bitmap((int)Math.Round(SlideBase.destExtent.Width), (int)Math.Round(SlideBase.destExtent.Height), PixelFormat.Format24bppRgb, bts, new ZCT(), "");
}
bm = re.Apply((Bitmap)bf.ImageRGB);
overviewBitmap = bm;
}
bm = re.Apply((Bitmap)bf.ImageRGB);
overviewBitmap = bm;

ShowOverview = true;
Console.WriteLine("Preview Initialized.");
}
Expand Down Expand Up @@ -1352,8 +1360,7 @@ public void UpdateImages()
dBitmaps[bi].Dispose();
dBitmaps[bi] = null;
}
Bitmap bf = new Bitmap("", bitmap, new ZCT(), 0);
dBitmaps.Add(DBitmap.FromImage(dx.RenderTarget2D, (bf)));
dBitmaps.Add(DBitmap.FromImage(dx.RenderTarget2D, bitmap));
}
else
Bitmaps.Add(bitmap);
Expand Down
20 changes: 14 additions & 6 deletions BioCore/Source/TabsView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ private void openToolStripMenuItem_Click(object sender, EventArgs e)
int img = Images.images.Count;
foreach (string item in openFilesDialog.FileNames)
{
BioImage im = BioImage.OpenFile(item, 0, true,true);
BioImage im = BioImage.OpenFile(item, 0, true, true);
AddTab(im);
if (!App.recent.Contains(im.ID))
App.recent.Add(im.ID);
Expand Down Expand Up @@ -803,7 +803,7 @@ private void openOMEToolStripMenuItem_Click_1(object sender, EventArgs e)
return;
foreach (string sts in openFilesDialog.FileNames)
{
BioImage im = BioImage.OpenOME(sts,true);
BioImage im = BioImage.OpenOME(sts, true);
if (im == null)
return;
AddTab(im);
Expand Down Expand Up @@ -972,7 +972,7 @@ private void addImagesToTabToolStripMenuItem_Click(object sender, EventArgs e)
return;
}
}

}

/// If the user selects a file, open it and add it to the viewer
Expand All @@ -989,7 +989,7 @@ private void addImagesOMEToolStripMenuItem_Click(object sender, EventArgs e)
{
if (i == 0 && tabControl.TabPages.Count == 0)
{
AddTab(BioImage.OpenOME(openFilesDialog.FileNames[0],false));
AddTab(BioImage.OpenOME(openFilesDialog.FileNames[0], false));
}
else
App.viewer.AddImage(BioImage.OpenOME(openFilesDialog.FileNames[i], false));
Expand All @@ -1012,7 +1012,7 @@ private async void openSeriesToolStripMenuItem_Click(object sender, EventArgs e)
int c = BioImage.GetSeriesCount(file);
for (int i = 0; i < c; i++)
{
await BioImage.OpenAsync(file, true, true, true,c);
await BioImage.OpenAsync(file, true, true, true, c);
}
}
}
Expand Down Expand Up @@ -1097,7 +1097,7 @@ private void openSeriesToolStripMenuItem_Click_1(object sender, EventArgs e)
BioImage[] bms = null;
foreach (string item in openFilesDialog.FileNames)
{
bms = BioImage.OpenSeries(openFilesDialog.FileName,true);
bms = BioImage.OpenSeries(openFilesDialog.FileName, true);
for (int i = 0; i < bms.Length; i++)
{
if (i == 0)
Expand Down Expand Up @@ -1401,5 +1401,13 @@ private void exportQuPathROIToolStripMenuItem_Click(object sender, EventArgs e)
QuPath.Save(item, ImageView.SelectedImage);
}
}

private void extractRegionPyramidalToolStripMenuItem_Click(object sender, EventArgs e)
{
BioImage b = ImageView.SelectedImage;
BioImage bm = b.GetRegion((int)b.PyramidalOrigin.X, (int)b.PyramidalOrigin.Y, b.PyramidalSize.Width, b.PyramidalSize.Height);
AddTab(bm);
Images.AddImage(bm, true);
}
}
}
Loading

0 comments on commit 5a371b1

Please sign in to comment.