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

 

ImageEn Forum
Profile    Join    Active Topics    Forum FAQ    Search this forumSearch
 All Forums
 ImageEn Library for Delphi, C++ and .Net
 ImageEn and IEvolution Support Forum
 Access Violation when loading PSD file...

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

View 
UserName:
Password:
Format  Bold Italicized Underline  Align Left Centered Align Right  Horizontal Rule  Insert Hyperlink   Browse for an image to attach to your post Browse for a zip to attach to your post Insert Code  Insert Quote Insert List
   
Message 

 

Emoji
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Black Eye [B)]
Frown [:(] Shocked [:0] Angry [:(!] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
Andy_Bell Posted - Jun 29 2020 : 07:29:17
Hi

C++ Builder 2007

The attached project demonstrates the error.

I'm using a TImageEnIO component that I manually attach to a TIEBitmap. I also attach a TImageEnProc to the same TIEBitmap;

I then load a fairly big .PSD image (422 megs) and process it and save it into a TMemoryStream as a JPEG:


if (IO->LoadFromFile(imagePath)) {
		Proc->Resample(800,800, rfFastLinear, true);
		IO->Params->JPEG_Quality = 75;
		IO->SaveToStreamJpeg(Stream);
		Stream->Position = 0;
}


This all works fine. But, if I then try to do the same thing in the same TImageEnIO component, I get an access violation on loading the same image or another PSD image.

If I comment out the IO->SaveToStreamJpeg(Stream); line then the problem goes away.

So it seems that the line IO->SaveToStreamJpeg(Stream); prevents me from using the TImageEnIO component again.

Is this a bug or do I need to do something to the TImageEnIO to make is usable again?

This doesn't happen with TIF files or JPEGS...

I can supply the PSD file if you need it.

attach/Andy_Bell/20206297193_IE_StreamIssue.zip
7.63 KB

Andy
9   L A T E S T    R E P L I E S    (Newest First)
Andy_Bell Posted - Jul 02 2020 : 04:24:09
Hi Nigel

Here's the file: http://andybellphotography.com/ImageEn/IEIssues.zip

It contains the latest code, project and executable.The stream is not reused in the demo...

Both PC's that I'm getting the issue on are Windows 10, 64 bit PC's with plenty of memory and disk space.

The demo is built without dynamic runtime packages the dynamic RTL.

Andy
xequte Posted - Jul 01 2020 : 19:06:19
Hi Andy

Can you fix the demo to not reuse the stream, then post a link to the source and compiled exe?

Nigel
Xequte Software
www.imageen.com
Andy_Bell Posted - Jul 01 2020 : 18:17:39
I get the same issue on the PC with the 'out of the box' ImageEn installed...

Maybe it is something about this image? I reran my test loading a large TIF 8 times in a row without issues...

Andy
Andy_Bell Posted - Jul 01 2020 : 18:08:21
Hi Nigel

No, that's not the intention. In the real code, the stream supplies the data to another process and then the code processes the next image.

It is using the same stream, however I get the same error if I delete and recreate the stream between image loads.

The only workaround I have found is to delete and recreate the TIEBitmap and reattach it to the IO and Proc components.

So, it seems something weird happens to the TIEBitmap after IO->SaveToStreamJpeg(Stream);

I get the same problem if I use a TImageEnIO component...I don't think it's the image - as long as I don't save it to the stream it happily loads multiple times. I also get the same error if I save to file and then reload the same image or another image.

I wonder if it has anything to do with me having recompiled ImageEn to use the faster loading DLL? I will test the code on another PC that has not recompiled it...

Andy

Andy
xequte Posted - Jul 01 2020 : 17:29:03
Sorry, I just realized that in your demo you are adding both PSD files to the same stream.

Are you intending to create a JPEG stream of multiple images? If so, you need to enable StreamHeaders.

  ms := TMemoryStream.Create();
  imageenview.io.loadfromfile('1.psd');
  imageenview.IO.StreamHeaders := true;    // <<<<<
  imageenview.IO.savetostreamjpeg(ms);
  ms.Position := ms.Size;
  imageenview.io.loadfromfile('2.png');
  imageenview.IO.savetostreamjpeg(ms);
  ms.position := 0;


Nigel
Xequte Software
www.imageen.com
xequte Posted - Jun 30 2020 : 19:44:16
Hi Andy

I'm not seeing the issue here, but will have my partner test it too.

Can you also upload the exe for Project19.cbproj (loading _SAM0676.psd). It may be a resource issue.

Nigel
Xequte Software
www.imageen.com
Andy_Bell Posted - Jun 30 2020 : 04:02:02
Hi Nigel

https://andybellphotography.com/ImageEn/_SAM0676.psd

I'm doing some heavy batch processing and the above problem occurs occasionally. The uploaded .psd file causes it consistently... Once I have opened it in TImageEnIO and saved it as a JPEG to a memory stream then the next image load throws the exception.

If I don't save to the memory stream then I don't get any issues, so I don't think it's a problem with the image itself, but something goes wrong after the saving it to a stream...

Andy
xequte Posted - Jun 29 2020 : 23:37:31
Hi Andy

Please post your PSD file for me to download.

Nigel
Xequte Software
www.imageen.com
Andy_Bell Posted - Jun 29 2020 : 07:42:30
As a workaround, I'm manually deleting and recreating the TImageEnIO AND the TIEBitmap after each call to IO->SaveToStreamJpeg(Stream);

It doesn't work to just recreate the TImageEnIO. The TIEBitmap hhas to be recreated too.

Whilst this approach succeeds, it's not very efficient.

Andy