ImageEn for Delphi and C++ Builder ImageEn for Delphi and C++ Builder

 

ImageEn Forum
Profile    Join    Active Topics    Forum FAQ    Search this forumSearch
Forum membership is Free!  Click Join to sign-up
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 ImageEn Library for Delphi, C++ and .Net
 ImageEn and IEvolution Support Forum
 responding to out of memory for large JPG
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  

jrpcguru

USA
260 Posts

Posted - Jul 17 2015 :  21:34:54  Show Profile  Reply
I have a 12 megabyte JPG file that was apparently a high resolution scan of an old photograph. My photo viewing app uses ImageEnView and successfully loads the image, while reporting that it is 191 megapixels.

My computer is Win 7 Pro, 8 gig of ram, 32 bit ImageEn 6.0.1 with XE2.

My scanning app uses ImageEnMView to acquire images and to reload them from disk. It then transfers each image as needed to an ImageEnView for display and editing. When this program tries to load this large JPG file, an out of memory error happens while using ImageEnMView1.MIO.LoadFromFile, or sometimes "Not enough storage is available to process this command.".

I find that reloading the image into ImageEnView using ImageEnView1.IO.Params.JPEG_Scale := ioJPEG_AUTOCALC;
allows me to load and display the image at a much lower resolution and transfer it back to the ImagenMView, but only for a JPG file can I do this.

1. Is there a way to tell ImageEnMView to load all files at a lower resolution like with ImageEnView and .JPG files? I would like to trap the out of memory error and retry loading at a lower resolution.
2. I use ImageEnView1.clear, ImageEnView1.blank before loading into ImageEnView, and ImageEnMView.Clear before loading into ImageEnMView. However, after loading several copies of this large JPG and other TIF and JPG files, they all start claiming out of memory even though they are much smaller files. Is there another way to release all memory used by ImageEnView and ImageEnMView?

I would be happy to send a copy of the JPG file but your attach feature says it is too big.

J.R.

xequte

38514 Posts

Posted - Jul 20 2015 :  17:18:30  Show Profile  Reply
Hi JR

1. You can set ImageEnMView1.StoreType := ietThumb; to store at display size and load only as large as is necessary, though naturally for TIFF files there is no quick loading method (other than embedded thumbnail loading which scanned files are unlikely to have).

If you are getting memory issues, you should supply us some of your images for anaysis.


2. I suspect there is some leakage taking place. Can you please upload a demo and sample files, and the precise steps to reproduce.

Prior to this, email us for the latest source code, it addresses a number of memory issues.



Nigel
Xequte Software
www.xequte.com
nigel@xequte.com
Go to Top of Page

jrpcguru

USA
260 Posts

Posted - Aug 21 2015 :  16:25:47  Show Profile  Reply
I initially believed that my photo viewing app was successful in loading this huge file, but then I discovered it generated the "Not enough storage is available to process this command." error when I tried to copy the image to a popup form that I use for viewing on a second monitor. I used the following code initially:

try
begin
frmImagePopUp.ImageEnView1.Blank;
frmImagePopUp.ImageEnView1.Bitmap.Assign ( frmMainView.Form1.ImageEnView1.Bitmap);
frmImagePopUp.ImageEnView1.Fit;
end;
except
end;

Nigel provided the following suggestion to fix this:

Try setting ImageEnView1.LegacyBitmap to false and assign IEBitmap rather than Bitmap.

The good news is that this worked. I am now able to load this huge .JPG file into the main form's ImageEnView1 and transfer it to the popup form via:
frmImagePopUp.ImageEnView1.IEBitmap.Assign ( frmMainView.Form1.ImageEnView1.IEBitmap);

The bad news:
Rotating the image on the popup form via: ImageEnView1.Proc.Rotate(90, ierNone);
usually crashes the program. Flipping the image does not cause a problem. I flip with:

ImageEnView1.proc.Flip(fdHorizontal);
ImageEnView1.proc.Flip(fdVertical);

If I shrink the image from 191 megapixels to 50 megapixels before rotating, then it rotates just fine. If I try to shrink the image to 80 megapixels, the shrinking code generates an Out of Memory error. This is my shrinking code which yields 50 megapixels from the original 191mp:

iNewWidth := (ImageEnView1.IEBitmap.Width Div 2) ;
iNewHeight := (ImageEnView1.IEBitmap.Height div 2) ;
ImageEnView1.Proc.Resample(iNewWidth, iNewHeight,rfLanczos3, true);

Is it reasonable for flipping to require less memory than rotating?
Is there a better work around to get it to reliably rotate huge images?


J.R.
Go to Top of Page

xequte

38514 Posts

Posted - Aug 23 2015 :  18:44:23  Show Profile  Reply
Hi JR

Please forward us the image and the exact steps to reproduce the issue so we can investigate.

Nigel
Xequte Software
www.xequte.com
nigel@xequte.com
Go to Top of Page

xequte

38514 Posts

Posted - Aug 24 2015 :  23:15:03  Show Profile  Reply
Thanks JR,

I received the image, but I could not reproduce a crash. What version of Windows do you use? Check that all of the TImageEnViews in your project have LegacyBitmap set to false.

Nigel
Xequte Software
www.xequte.com
nigel@xequte.com
Go to Top of Page

jrpcguru

USA
260 Posts

Posted - Aug 25 2015 :  08:39:25  Show Profile  Reply
I am using Win 7 Pro-64, 8 gig of ram. I compiled your demo program PhotoEn with D7 and it instantly gives out of memory when trying to rotate the image. When I compile with XE2 it announces "Not enough storage is available to process this command.' when trying to rotate the image.

I ran through the options in PhotoEn under Image menu and it worked until I tried get HSV channels which yielded an Access Violation. The same happened for get RGB channel. Edge Detection yielded Out of Memory. Resize yielded "Not enough storage is available to process this command.' but Resample worked. Horizontal & Vertical flip also worked.

I added LegacyBitmap := false to this demo program but it still won't rotate the image. After finding the rotate form and adding LegacyBitmap to it also, it displayed and defaulted to Fast but as soon I tried to set an angle it yielded Out of Memory. I set anti-aliasing to None and that does allow very slow rotation. BiLinear also worked though it reported "Not Responding" in the rotate form title bar for awhile. Bicubic was the same as BiLinear.

After I added LegacyBitmap to the Resize and Resample code, it yielded Access Violation. And Resample did the same.

BTW: I have found that this 191 megapixel file loads just fine in ImageEnView though slowly. Similarly I used Photoshop Elements to combine this file with 2 others to generate a 466Mp file which also loads just fine. The smaller file does not load into ImageEnMView. I will have more on my research, hopefully later today.

J.R.
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
Jump To: