Hello,
I trying to export specific area from czi image file to jpeg use ZeissImageLib.dll.
Is there any way to do this?
Best regards
Rick
Export CZI to JPEG
Hello ricklina90,
here some code snippets
to get the 'specific area'
This delivers a 1000*1000 BitmapSource of the upper left corner of the image.
To save the BitmapSource as a png, bmp or jpeg image you can use:
Instead of the PngBitmapEncoder you can also use BmpBitmapEncoder or JpegBitmapEncoder.
I hope this helps!
here some code snippets
to get the 'specific area'
Code: Select all
SubsetBounds subsetBounds = imageDocument.Bounds.Clone();
subsetBounds.SetSize(ImageDimension.X, 1000);
subsetBounds.SetSize(ImageDimension.Y, 1000);
BitmapSource bitmapSource = imageAccessor.GetBitmapSource(subsetBounds, null, 0.0);
To save the BitmapSource as a png, bmp or jpeg image you can use:
Code: Select all
using (var fileStream = new FileStream(filePath, FileMode.Create))
{
BitmapEncoder encoder = new PngBitmapEncoder();
encoder.Frames.Add(BitmapFrame.Create(bitmapSource));
encoder.Save(fileStream);
}
I hope this helps!