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
 Problem EOutOfResource Big Images
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  

Sam

21 Posts

Posted - Dec 13 2012 :  10:19:53  Show Profile  Reply
Hi,

I use
ImageEnView.LegacyBitmap := false;

to load big images (10000x10000 Pixels). So, I only use TIEBitmap. This works fine and I can load many big images into memory or page file. I donīt free the images, because I have got a CAD-component, where I can show the images, when scrolling in the CAD-component (showing aerial images).
I have to copy the images from memory to the CAD-Canvas after scrolling in the CAD-component via the "StretchBlt" API-command of Windows. I canīt use a ImageEnView on the CAD-Component directly.

This is how I copy the image then from memory:

SetStretchBltMode(CAD.Canvas.Handle, HALFTONE);
StretchBlt(CAD.Canvas.Handle,0,0,CAD.Width,CAD.Height,ImageEnView.IEBitmap.canvas.Handle,0,0,ImageEnView.IEBitmap.Width,ImageEnView.IEBitmap.Height,SRCCOPY);


But After loading two big images, there comes the error message EOutOfResource in Delphi at the "StretchBlt"-command. When I comment out the "StretchBlt", I can load many of the big images without any problems.

Does anyone have an idea?

Thank you very much!

w2m

USA
1990 Posts

Posted - Dec 13 2012 :  10:24:32  Show Profile  Reply
Maybe try TIEBitmap.DrawToCanvas instead.

Declaration
procedure DrawToCanvas(DestCanvas:TCanvas; xDst,yDst:integer);

Description
Draws the whole bitmap to specified DestCanvas canvas, at xDst, yDst coordinates.

William Miller
Email: w2m@frontiernet.net
EBook: http://www.imageen.com/ebook/
Apprehend: http://www.frontiernet.net/~w2m/index.html
Go to Top of Page

Sam

21 Posts

Posted - Dec 14 2012 :  02:47:03  Show Profile  Reply
Hi, thank you!
Unfortunately, I get an exception after loading one picture (in unit hyietuils.pas, TIEBitmap.GetCanvas). The first picture is good, but the second one fails.
An Iīve got another problem, too, when I use DrawToCanvas: Iīve to resize the picture on my CAD-Canvas (not in memory, only in my CAD-Window, depends on zoom-level). I canīt do that with DrawToCanvas...
Go to Top of Page

Sam

21 Posts

Posted - Dec 14 2012 :  03:26:46  Show Profile  Reply
Maybe, someone can reproduce the error. I have got a very simple example which shows the problem.
You can download it here:

http://www.file-upload.net/download-6926054/ImageEn_Light.zip.html

Can anyone make this project work???
Important:
- I need to have all pics in memory for copying
- I have to copy the pics from memory to a canvas (and resize them in my canvas)
- I canīt use any ImageEn-component in my CAD-component. My Cad-Component has got an own Canvas for drawings vektor data, images, text etc.

Thank you again!
Go to Top of Page

fab

1310 Posts

Posted - Dec 14 2012 :  04:32:56  Show Profile  Reply
When you ask for "Canvas" to TIEBitmap, it just embeds a TBitmap: for this reason you still have the TBitmap size limitations.
You should avoid ImageEnView.IEBitmap.canvas.Handle and ImageEnView.IEBitmap.canvas.

Do you have only CAD.Canvas.Handle as source?
Otherwise you can use CopyFromDIB or CopyFromMemory.
Go to Top of Page

Sam

21 Posts

Posted - Dec 14 2012 :  05:39:49  Show Profile  Reply
Hi, thank you for your answer. Now, I know, why the "DrawToCanvas" - function could not find a Canvas, because the Location was set to "ieFile" after loading a second picture...

But "CAD.Canvas" is not my source, itīs my destination.
So, I already loaded data to a TIEBitmap-Object and want to copy the data from TIEBitmap to my CAD-Object to the Screen. And as I can see, I can only use the CAD.Canvas for drawing to my CAD-Object, or not??
Or is there another possibility to copy the data instead of using "StretchBlt"???
Or it is not possible to copy the big IEBitmap-data to my CAD Canvas?
Go to Top of Page

ehkhalid

27 Posts

Posted - Dec 14 2012 :  09:26:29  Show Profile  Reply
Hi,
I modified your delphi project to can upload the six images, the idea is to draw each image on a canvas and stores this canvas in a list, to draw image on cad component, we do just a copyrect from stored canvas, by doing this i can load six images at the same time. i added same commentary in the code to explain what i do, hope it will work for you.

i simulate the Cad component with a timage in a scrollbox, so you can show image at real size.

I uploaded only the delphi project without images files
http://www.2shared.com/file/IhtFoBoZ/ImageEn_Light_Modified.html
Go to Top of Page

Sam

21 Posts

Posted - Dec 17 2012 :  04:01:23  Show Profile  Reply
Hi,

thank you very much for your help!

But now, I get the error "Not enough memory for this operation"
at "wImage.Canvas.CopyRect(...)".
Did you tried it with the 10000x10000 Picture and it is working for you?

I am confused...
Go to Top of Page

ehkhalid

27 Posts

Posted - Dec 17 2012 :  06:27:32  Show Profile  Reply
Hi,
Yes i tried with images in the zip, i can load 7 images, i have 4 Go of RAM, every image loaded take about 300 Mo, how many images you can load before getting the error ?


Go to Top of Page

Sam

21 Posts

Posted - Dec 17 2012 :  06:46:24  Show Profile  Reply
Hi,

the error comes directly when I try to load the first picture.
Iīve got Windows XP with 3GB RAM.
The error is at the wImage.Canvas.CopyRect() Method.
When I debug it, Delphi shows EOutOfResources Error at wImage.Canvas. So I canīt even get the Canvas-Object.
Iīm frustrated. Can be a problem of Delphi/Windows/Graphic card/driver/whatever...
Perhaps itīs not possible to handle these big images, I donīt know.
Anyway, thank you for testing!
Go to Top of Page

ehkhalid

27 Posts

Posted - Dec 17 2012 :  07:38:08  Show Profile  Reply
I have another solution for your problem, it's about loading and storing jpeg, and when you need to show image in the cad component, you decompress jpeg to get bitmap, by using this method, your program will use low memory and you can load many images without consuming memory, decompressing jpeg with imageen or standard lib take much time, so i suggest to use a specific jpeg lib developped by using SSE2 instructions, by doing this the descopression is very fast (about 2 sec for your big images 10000x10000).

with such big images, you can''t stored it on memory, so i think real time decoding is the best solution.

here is a modified version of your delphi project that use the real time decompression, hope will be useful, in this version i don't use imageen, only Timage componenets and the jpeg lib (under gpl license).

the program support only jpeg images

http://www.2shared.com/file/DpafbP3p/BigImages_LowMemory.html
Go to Top of Page

Sam

21 Posts

Posted - Dec 17 2012 :  09:22:15  Show Profile  Reply
Thank you very much.
I will test it...
Go to Top of Page

Sam

21 Posts

Posted - Dec 18 2012 :  03:03:02  Show Profile  Reply
Unfortunately, the jpeg decoder doesnīt work with Delphi 5 (yes, we still use Delphi 5!) :-(
But the real time decoding might be the right way, I have to check this...

The problem is that you canīt access the data from ImageEnView.IEBitmap,
when LegacyBitmap := false and the data is loaded into swap file (Location = ieFile).
There should be something like "CopyIEBitmapDataToCanvas".
The "DrawToCanvas"-Method shows an exception when the data is not in memory (Location = ieFile, error at GetCanvas).
As I understand, the IEBitmap.Canvas is always the Canvas of the TBitmap. So, IEBitmap has got not a special canvas, right?
Go to Top of Page

ehkhalid

27 Posts

Posted - Dec 18 2012 :  08:00:15  Show Profile  Reply
Hi,
Exact Jpeg lib use SSE instruction, so it's compatible with Delphi7 and higher, in my case i use delphi7 at work (XE3 ath home), so at work it's a little bit better than Delphi 5 ;).
Here another solution that consume very low memory, the solution is to use mapped files to store bitmap, so the only memory consumption in the program will be thumbs and the image drawed in cad component.
The mapped files are stored in temporary folder (a folder "temp" is created ).

this time, the zip contain the exe too, so you can test my exe and the one you generate from source.

http://www.2shared.com/file/TpWjnW4c/ImageEn_Mappedfiles.html
Go to Top of Page

Sam

21 Posts

Posted - Dec 19 2012 :  06:54:42  Show Profile  Reply
Hi,

thank you for your efforts! But I still get an error (no memory).
I think, it depends on the OS, video card, video driver...

I saw other CAD-Programs where you can load many big images without any errors and very fast. I wonder, how they solved the problem and which component they use...
Go to Top of Page

ehkhalid

27 Posts

Posted - Dec 19 2012 :  07:33:36  Show Profile  Reply
you get error when you use the exe in the zip ? and when you load the first image ? or you get error when you use real cad component ?
Go to Top of Page

Sam

21 Posts

Posted - Dec 19 2012 :  08:18:16  Show Profile  Reply
I get the error when loading the first image with the exe from the zip.
Go to Top of Page

ehkhalid

27 Posts

Posted - Dec 21 2012 :  08:36:17  Show Profile  Reply
Hi
try to debug program and see wich function failed, i think there are some problem width canvas draw function, maybe you can try the same code but replacing the canvas draw function with bitblt or other draw functions.

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