• Welcome to Vampyre Imaging Library Forum. Please login or sign up.
 

Post reply

Other options

Shortcuts: ALT+S save/post or ALT+P preview

Topic summary

Posted by mbojanks
 - 24 September 2011, 15:43:00
Thank you for your detailed reply. The most important thing is that it is not hopeless nor impossible to be done in FPC, but it would be much easier if we could know more precisely if we have enough memory available for loading a certain image, or how to estimate the tiles' dimension.
I observed memory consumption in Windows Task manager of applications using Imaging. Out of memory exception occurred sometimes even at 600MB of the application's memory consumption, and on the other side, even above 1,2 GB would not raise the exception. What would you suggest, how to cope with this memory consumption issues?
Thank you anyway for this really amazing library and keep up in further improving it.
Posted by Galfar
 - 24 September 2011, 02:28:49
This is the difference between VCL demo and LCL demo - the conversion has both R8G8B8 and A8R8G8B8 images in the memory at the same time. VCL demo only converts images incompatible with canvas class so for R8G8B8 input no conversion is needed - thus it uses nearly half the memory of LCL demo.
In VampConvert if you just resave to another format no conversion is needed so again it's half the memory usage of LCL imager.

Determining the memory limit is not so easy, even if you have 1GB free and try to allocate 500MB it can still fail due to memory
fragmenation.

Imaging can work with these large images provided that you have a lot of RAM and use 64 bit compiler. I just tried loading 20000x20000 R8G8B8 image and it opened ok in VCL demo. Memory mapping and using tiled images would work (probably what Photoshop itself uses when working with these large images) when the memory needed to hold the images is bigger than installed RAM but that's quite a lot of work.
Posted by mbojanks
 - 23 September 2011, 17:38:53
After further testing, I can say that the problem occurs when an application is trying to convert from R8G8B8 to A8R8G8B8. So maybe there was sufficient memory for 3, but not for 4 channels. But the question is: How to estimate the memory limit (MemAvail() is available?) and how to overcome that limit. Is there any chance that Vampyre Imaging Library would be capable of opening those files and up to about PSD file limit (30000px x 30000px x 3 or 4 channels) in any (development) environment (Linux, Windows, FPC, Delphi...)?
Posted by mbojanks
 - 23 September 2011, 16:26:47
I performed the following test: Used VampConvert demo console application and successfully converted my 8504x9213 PSD file into .bmp and .jpg. Loading those .bmp and .jpg files FAILED IN LCLImager.exe with the same exception: Out of Memory.
So, my PSD file being successfully loaded by VampConvert, I converted the corresponding Delphi project VampConvert.dpr into Lazarus project and built VampConvert.exe. Then I repeated the conversion of my PSD file to .jpg and .bmp with this FPC-compiled VampConvert.exe WITH THE SAME SUCCESS! Hence my PSD file was successfully loaded and converted by FPC-compiled VampConvert.exe. And again, NO USE OF LOADING either .bmp, .jpg, or .psd 8504x9213 file in LCLImager.exe.
I really hope these test results will be useful for finding out what could cause the Out of memory exception.
Thank you in advance for any support.
Posted by mbojanks
 - 23 September 2011, 12:52:09
Thank you for your immediate reply. I have 2GB RAM, so it is not a problem, I suppose. I 'll surely make the test you suggested and let you know about the results as soon as possible.
Posted by Galfar
 - 23 September 2011, 12:12:59
How much RAM does your computer have installed?
This image should take up ~300MB of memory.
Since it works in Delphi app maybe it's some problem with memory manager used by FPC
(cannot allocate continuous mem block of that size).

Could you try saving that image in some other file format and try to open it in LCLImager? To see
if this problem is tied to PSD loader or the whole LCL/FPC app.
Posted by mbojanks
 - 23 September 2011, 12:03:45
When trying loading of an 8504h x 9213w PSD A8R8G8B8 image to the LCLImager demo application compiled in Lazarus 0.9.30 with FPC 2.2.4 in Windows XP, I get the following exception message:

Out of memory.

Is there any memory size limit for psd images or is it a bug?

Additionally, when trying loading the same image in Delphi-compiled VCL Image Browser (ImgBrowser.exe) demo application, everything works fine.
SMF spam blocked by CleanTalk