Replies: 1 comment 1 reply
-
I would advise you to use the |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello~!
I need to convert 8bit grayscale image to Jpeg2000(.j2k or .jp2).
I want to control the image quality or rate.
How can I do that?
Below is the sample code I wrote.
Is it right?
----- Encoding ---------
var settings = new MagickReadSettings();
settings.Width = isoData.representationHeaders[i].ImageWidth;
settings.Height = isoData.representationHeaders[i].ImageHeight;
settings.Format = MagickFormat.Gray;
MagickImage image = new MagickImage(isoData.representationHeaders[i].Image, settings);
var memStream = new MemoryStream();
image.Format = MagickFormat.J2k;
image.Settings.Compression = CompressionMethod.JPEG2000;
image.Quality = 50; // Quality is compression rate?
image.Write(memStream);
var data = memStream.GetBuffer(); // data has J2k?
-----Decoding ---------
var settings = new MagickReadSettings();
settings.Width = isoData.representationHeaders[i].ImageWidth;
settings.Height = isoData.representationHeaders[i].ImageHeight;
settings.Format = MagickFormat.J2k;
MagickImage image = new MagickImage(isoData.representationHeaders[i].Image, settings);
var memStream = new MemoryStream();
image.Format = MagickFormat.Gray;
image.Quality = 50;
image.Write(memStream);
var data = memStream.GetBuffer(); // data has decompress?
Beta Was this translation helpful? Give feedback.
All reactions