Author Topic: Access violation when converting large (>90 Mb) BMP files to JPEG2000  (Read 1156 times)

Offline kusdogan

  • Imaging User
  • *
  • Posts: 3
    • View Profile
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;
« Last Edit: 4 November 2009, 12:59:35 by kusdogan »

Offline Galfar

  • Administrator
  • Imaging User
  • *****
  • Posts: 312
    • View Profile
    • Galfar's Homepage
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.
« Last Edit: 9 November 2009, 13:59:53 by Galfar »

Offline kusdogan

  • Imaging User
  • *
  • Posts: 3
    • View Profile
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.

Offline kusdogan

  • Imaging User
  • *
  • Posts: 3
    • View Profile
let me make a correction. it's also related with size. If image file is 32b and greater than 90MB, it fails.

Offline Galfar

  • Administrator
  • Imaging User
  • *****
  • Posts: 312
    • View Profile
    • Galfar's Homepage
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).

Quote
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.

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.