below code gives access violation if fSource is a bmp file larger than 90 mb (i last tried with 115 mb) and fDest is jp2. Is it because of TSingleImage ? It works very good for all other bmp files.
Imaging Library Version: 0.26.4
Compiler: Delphi 2007
OS: Windows Vista Ultimate
var
mImage: TSingleImage;
begin
fSource := 'C:\x.bmp';
fDest := 'C:\x.jp2';
mImage := TSingleImage.Create;
mImage.LoadFromFile(fSource);
Imaging.SetOption(ImagingJpeg2000LosslessCompression, 1);
try
mImage.SaveToFile(fDest);
finally
mImage.Free;
end;
end;
So unfortunately the exception is raised inside OpenJpeg library, so finding out what's wrong will be more difficult. I'll check their forums if someone encountered error like this before.
I checked it from OpenJPEG web site and realized that library does not support 32b BMP files. After i convert it to 24b it worked. It was not related with size.
let me make a correction. it's also related with size. If image file is 32b and greater than 90MB, it fails.
I've tried compressing 100+ MB large images in C++ program so I could see better where OpenJpeg fails - it was always some memory allocation function. OpenJpeg uses
a lot of memory for images. For each channel Width*Height*SizeOf(Integer) large buffer is used. So for 100MB 24bit bitmap it's 400MB of buffers. There's also additional memory used to store compressed image. So basically you run out of free memory.
This all should be fixed in OpenJpeg version 2 (unfortunately still looks like far future).
QuoteI checked it from OpenJPEG web site and realized that library does not support 32b BMP files. After i convert it to 24b it worked. It was not related with size.
You can store 1bit as well as 1024bit per pixel images in JPEG2000, so 32bits are not a problem for OpenJpeg.
24b image only used less memory.