Export CZI to JPEG

Discuss questions and projects related to processing of imaging data here
Post Reply
user-7094
Posts: 7
Joined: Thu Jan 01, 1970 1:00 am

Export CZI to JPEG

Post by user-7094 »

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
user-4
Posts: 397
Joined: Thu Jan 01, 1970 1:00 am

Post by user-4 »

Hello ricklina90,

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);
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:

Code: Select all

using (var fileStream = new FileStream(filePath, FileMode.Create))
{
    BitmapEncoder encoder = new PngBitmapEncoder();
    encoder.Frames.Add(BitmapFrame.Create(bitmapSource));
    encoder.Save(fileStream);
}
Instead of the PngBitmapEncoder you can also use BmpBitmapEncoder or JpegBitmapEncoder.

I hope this helps!
user-7094
Posts: 7
Joined: Thu Jan 01, 1970 1:00 am

Post by user-7094 »

Hello

Thanks for the answer.Very appreciated.

Regards,
Rick
Post Reply