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
 Why LegacyBitmap is always True?
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  

yogiyang

India
727 Posts

Posted - Dec 28 2013 :  03:26:17  Show Profile  Reply
In the demos that I am studying I have observed that in all of them the property LegacyBitmap is always True. Why?

I read somewhere that now we can keep it false but in the demos that are shipped with ImageEN this property is always True.

Can someone explain this in greater details and as to when we should use this and when we should not use this?

Is high memory consumption of PSD files loaded in ImageEN View related some how to this property setting?

TIA



Yogi Yang

w2m

USA
1990 Posts

Posted - Dec 28 2013 :  13:21:38  Show Profile  Reply
If LegacyBitmap is True, ImageEn uses TBitmap to store the image, otherwise ImageEn uses TIEBitmap.
TIEBitmap handles images using memory mapped file (for large images) or main memory.
This allows handling of large images and to include input/output and image processing in a multi-threaded environment.
Also TIEBitmap supports a larger number of pixel formats (TIEPixelFormat) than TBitmap (TPixelFormat).

So as I understand, it is best to set LegacyBitmap to False for your large PSD images so they are loaded as a memory mapped TIEBitmap. You should get better performance and less memory problems because the images are memory mapped. Large image IO can also be improved by compiling your application as Win64 because more memory will be available. Compiling as 64bit is simple. Just add the ielib64.dll to the exe folder. Image loading will also be about 30% faster than with Win32bit.

When you set LegacyBitmap to False all references to ImageEnView.Bitmap will be nil. As a result you can not access TBitmap properties. So if LegacyBitmap is False and you try to access Bitmap an exception will be produced. In this case use IEBitmap to access the image.

For example:

{ Use TIEBitmap to handle images using memory mapped file (for large images) or main memory by setting LegacyBitmap to False }
ImageEnView.LegacyBitmap := False;
{ An exception will occur in the next line because Bitmap is nil}
ImageEnView.Bitmap.Modified := False;

To get a TBitmap instead of an TIEBitmap when LegacyBitmap is False
use ImageEnView.IEBitmap.VclBitmap.


So you must use a global var instead to track if a IEBitmap has been modified or use the ImageEnView.IEBitmap.VclBitmap.Modified property.

The nice part of setting ImageEnView.LegacyBitmap := True is you can access both the TBitmap or TIEBitmap properties. So both TBitmap and TIEBitmap properties will be valid and both will contain a valid graphic and will not nil.

Having said this, Nigel or Fabrizio probably can offer better guidance than I, and make any corrections to my comments.

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

yogiyang

India
727 Posts

Posted - Dec 30 2013 :  04:26:55  Show Profile  Reply
@William,

Thanks for the detailed explanation.

It seems I should go with LegacyMode set to False.

Actually I do not have any need to access the Modified property. But to change over from LecacyMode would mean changing my code heavily as I have used TBitmape at quite a lot of places.

But if setting this mode to false do yield better performance then I am ready to do this also.

Anybody more practical experience on this? Please share your views.

TIA



Yogi Yang
Go to Top of Page

xequte

39053 Posts

Posted - Jan 01 2014 :  00:39:19  Show Profile  Reply
Hi

Many of the demos were created prior to the TIEBitmap functionality so they default to LegacyMode = true. With your new projects you should almost always set LegacyMode to false.



Nigel
Xequte Software
www.xequte.com
nigel@xequte.com
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
Jump To: