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
 Access Violation when loading PSD file...
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Andy_Bell

United Kingdom
23 Posts

Posted - Jun 29 2020 :  07:29:17  Show Profile  Reply
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

Andy_Bell

United Kingdom
23 Posts

Posted - Jun 29 2020 :  07:42:30  Show Profile  Reply
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
Go to Top of Page

xequte

5327 Posts

Posted - Jun 29 2020 :  23:37:31  Show Profile  Reply
Hi Andy

Please post your PSD file for me to download.

Nigel
Xequte Software
www.imageen.com
Go to Top of Page

Andy_Bell

United Kingdom
23 Posts

Posted - Jun 30 2020 :  04:02:02  Show Profile  Reply
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
Go to Top of Page

xequte

5327 Posts

Posted - Jun 30 2020 :  19:44:16  Show Profile  Reply
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
Go to Top of Page

xequte

5327 Posts

Posted - Jul 01 2020 :  17:29:03  Show Profile  Reply
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
Go to Top of Page

Andy_Bell

United Kingdom
23 Posts

Posted - Jul 01 2020 :  18:08:21  Show Profile  Reply
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
Go to Top of Page

Andy_Bell

United Kingdom
23 Posts

Posted - Jul 01 2020 :  18:17:39  Show Profile  Reply
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
Go to Top of Page

xequte

5327 Posts

Posted - Jul 01 2020 :  19:06:19  Show Profile  Reply
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
Go to Top of Page

Andy_Bell

United Kingdom
23 Posts

Posted - Jul 02 2020 :  04:24:09  Show Profile  Reply
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
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To: