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
 [Fixed]Crashes in 5.0.6 when loading images
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  

RonaldKats

Netherlands
5 Posts

Posted - Mar 05 2014 :  09:13:44  Show Profile  Reply
Hi,

We're using ImageEN components throughout our Delphi software and recently updated from 5.0.5 to 5.0.6. Now we're getting reports from users about Access Violations and Out Of Memory errors. It turns out that suddenly some images are not handled correctly.

We use this code to add an image to an image list runtime:

theImageIO := TImageEnIO.Create(nil);
theBMP := TIEBitmap.Create;
theBMP.Location := ieMemory;
theImageIO.LoadFromFile(mImagePath);
theBMP.Assign (theImageIO.IEBitmap);
if mImageIndex < 0 then
  mImageIndex := dmGlobal.ilSmall.AddMasked(theBMP.VclBitmap, TColor($FF00FF))
else
  dmGlobal.ilSmall.ReplaceMasked(mImageIndex, theBMP.VclBitmap, TColor($FF00FF));


ilSmall is a normal TImageList. I've attached an image (FYI: it is a picture of actress Abigail Breslin) sent to us by a user. The image causes many crashes. The weird thing is, it doesn't always crash in the same code. Sometimes it is in the JPEG image reader code, sometimes in standard Delphi functions in units like GETMEM.inc and system.pas. Or it just hangs or throws a Out Of Memory error.

However when it crashes, it is related to the image. Once we downgraded to 5.0.5 again, the crashes are gone. I hope this helps.

King regards,

Ronald Kats
Collectorz.com


w2m

USA
1990 Posts

Posted - Mar 05 2014 :  10:00:59  Show Profile  Reply
I have never seen imageen produce the problems you describe, so it is unlikely the problem is caused by imageen itself... rather there are problems with your code.

Without seeing all your code it is difficult to know the real problem, but I noticed you create a TIEBitmap, but do not set the TheImageEnIO.AttachedIEBitmap property:

theImageIO := TImageEnIO.Create(nil);
theBMP := TIEBitmap.Create;
theBMP.Location := ieMemory;
TheImageEnIO.AttachedIEBitmap := theBMP;
if mImageIndex < 0 then
  mImageIndex := dmGlobal.ilSmall.AddMasked(theBMP.VclBitmap, TColor($FF00FF))
else
  dmGlobal.ilSmall.ReplaceMasked(mImageIndex, theBMP.VclBitmap, TColor($FF00FF));

I am not sure if this will solve your problem, but you are assigning the bitmap incorrectly.

Also, when adding a image to an imagelist I generally use a TBitmap, not a TIEBitmap:
var
iBitmap: TBitmap;
dmGlobal.ilSmall.AddMasked(iBitmap, clBlack);

In addition, if the image dimensions do not match the settings in the imagelist there will be further problems, so it is good to resample the bitmap to make sure it is the correct size if necessary:
iBitmap := TBitmap.Create;
try
  iImageEnIO := TImageEnIO.Create(nil);
  try
    iImageEnProc := TImageEnProc.Create(nil);
    try
      iImageEnIO.AttachedBitmap := iBitmap;
      iImageEnIO.LoadFromFile(iImageName);
      { Add a TBitmap to the imagelist }
      iImageEnProc.AttachedBitmap := iBitmap;
      if (iBitmap.Width <> 16) and (iBitmap.Height <> 16) then
        iImageEnProc.Resample(16, 16);
      dmGlobal.ilSmall.AddMasked(iBitmap, clBlack);
    finally
       iImageEnProc.Free;
    end;
  finally
     iImageEnIO.Free;
  end;
finally
   iBitmap.Free;
end;

This or similar code is used in several active applications to deal with imagelist's and there has been no problems.

I can load your sample image into ImageEnView with no errors with 5.0.6 here.

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

RonaldKats

Netherlands
5 Posts

Posted - Mar 05 2014 :  11:28:21  Show Profile  Reply
Thanks for the quick reply. This code is only used for 16x16 images. The images already have been resampled and it includes a check for dimensions before this code is used.

I used the following code for the attached image to display in an TImageEnView. This fails in 5.0.6:

ImageEnView1.IO.LoadFromFileFormat(thePicturePath, FindFileFormat(thePicturePath,false) );

It is working fine in 5.0.5.

I've uploaded a zip with a demo project:
http://downloads.collectorz.com/AVImageView.zip

All it does is load the image. There are two builds in the zip, one with 5.0.5 and one with 5.0.6. Notice that the 5.0.5 build works, where the 5.0.6 one crashes. Copy the demopic.jpg from the zip file to your My Documents folder.

I hope this helps.

Kind regards,

Ronald Kats
Collectorz.com
Go to Top of Page

w2m

USA
1990 Posts

Posted - Mar 05 2014 :  13:19:26  Show Profile  Reply
Unfortunately, your zip file was corrupt or you are using Delphi XE5. The project will not compile here at all...

I ran your two demos and both loaded the image, but 5.0.6 produced an exception then the image was shown. I am not sure if the problem is caused by ImageEn or by the code you are using to load the picture.

William Miller
Go to Top of Page

RonaldKats

Netherlands
5 Posts

Posted - Mar 06 2014 :  01:51:04  Show Profile  Reply
Ah, yes, it is in XE5.

The code I use to load the picture, is entirely ImageEN's. Since it is just this one line:

ImageEnView1.IO.LoadFromFileFormat(thePicturePath, FindFileFormat(thePicturePath,false) );

If you open unit1.pas in a text editor, you'll see I'm not doing anything else. It is a simple demo, with only the ImageENView component where the image gets loaded in the FormShow.
Go to Top of Page

xequte

38611 Posts

Posted - Mar 06 2014 :  14:10:16  Show Profile  Reply
Hi Ronald

I can reproduce the issue with the EXE you supplied, but not when I compile your demo myself in XE5.

Does the issue only occur with JPEG images?





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

RonaldKats

Netherlands
5 Posts

Posted - Mar 07 2014 :  01:30:03  Show Profile  Reply
Hi,

Yes, so far it seems the reports are only about JPEG images indeed. One of the Access Violations I could reproduce was in the ImageEN JPEG reader.
Go to Top of Page

Murat

Russia
48 Posts

Posted - Mar 12 2014 :  01:11:00  Show Profile  Reply
I experienced the same issue when tried to run the Ronald's code by XE5 and ImageEN 5.0.6.

All is Ok when I launch it using 5.0.1 version.
Go to Top of Page

xequte

38611 Posts

Posted - Mar 12 2014 :  16:15:44  Show Profile  Reply
Hi

We have a fix for this for v5.0.7, which will be released as soon as we finish implementation of a new feature (in the next week or two).

Email us if you are urgent for the fix.



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

Murat

Russia
48 Posts

Posted - Mar 13 2014 :  01:37:16  Show Profile  Reply
Did you have a chance to take look at the problem with PSD files that I sent you recently. I this issue was fixed I'd wanted to kindly ask you to send me the latest 5.0.7 version. Thanks!
Go to Top of Page

xequte

38611 Posts

Posted - Mar 13 2014 :  17:23:37  Show Profile  Reply
Hi Murat

It is a corrupted file. For the next update we will make it cope with it more gracefully.

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

Murat

Russia
48 Posts

Posted - Mar 14 2014 :  03:56:45  Show Profile  Reply
Thanks! If you will include it into the 5.0.7 version, I'd be appreciate you'll send me the 5.0.7 version
Go to Top of Page

spurgeon

54 Posts

Posted - Mar 17 2014 :  12:44:07  Show Profile  Reply
We also just discovered a crash with an .MRW file and 5.0.6 (9.2MB so I can't attach to forum). Reverting to 5.0.5 fixed the problem for us. I assume this is also related to the same issue? Looking forward to the 5.0.7 update.
Go to Top of Page

xequte

38611 Posts

Posted - Mar 17 2014 :  15:28:58  Show Profile  Reply
V5.0.7 should be ready within the week. If you post a link to you MRW file i can test it.



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

spurgeon

54 Posts

Posted - Mar 18 2014 :  08:37:51  Show Profile  Reply
Can't post a public link at the moment. I sent as an email attachment instead. Hope that's alright.
Go to Top of Page

Murat

Russia
48 Posts

Posted - Mar 18 2014 :  09:06:44  Show Profile  Reply
You can also share it via dropbox or wetransfer.com service. So only ImageEn developers will see your image.
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
Jump To: