Vampyre Imaging Library Forum

Imaging Category => Bugs And Other Insects => Topic started by: kusdogan on 4 November 2009, 04:19:58

Title: Access violation when converting large (>90 Mb) BMP files to JPEG2000
Post by: kusdogan on 4 November 2009, 04:19:58
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;
Title: Re: Access violation when converting large (>90 Mb) BMP files to JPEG2000
Post by: Galfar on 7 November 2009, 19:24:15
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.
Title: Re: Access violation when converting large (>90 Mb) BMP files to JPEG2000
Post by: kusdogan on 23 November 2009, 16:43:11
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.
Title: Re: Access violation when converting large (>90 Mb) BMP files to JPEG2000
Post by: kusdogan on 24 November 2009, 02:42:39
let me make a correction. it's also related with size. If image file is 32b and greater than 90MB, it fails.
Title: Re: Access violation when converting large (>90 Mb) BMP files to JPEG2000
Post by: Galfar on 25 December 2009, 02:46:49
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.