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
 LayersMergeAll error

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
yeohray2 Posted - Dec 21 2020 : 04:33:06
Similar to this https://www.imageen.com/ieforum/topic.asp?TOPIC_ID=3942, I'm getting the 'Cannot create TIECanvas. Ensure GDI+ is installed.' error or access violations intermittently when creating text layers and trying to flatten them using LayersMergeAll.

I am writing text onto images using threads. Each thread has its own TImageEn instance. Converting and resizing the images don't raise any errors. Creating layers and trying to merge the layers causes errors intermittently. If I restrict the thread pool to only use a single thread, then no error is raised.

Is there some setting that needs to be used when using TImageEn and text layers in threads? The TImageEn instance is created this way:

FWorkImage := TImageEn.Create(nil);
FWorkImage.LegacyBitmap := False;

Thanks in advance.
6   L A T E S T    R E P L I E S    (Newest First)
xequte Posted - Jan 01 2021 : 22:32:12
Thank you. Happy New Year to you too.

Nigel
Xequte Software
www.imageen.com
yeohray2 Posted - Dec 31 2020 : 04:28:00
Hi, thanks for taking the time to take a look at this.

What I've done is to use TIEBitmap instead of TImageEn/TImageEnView instances. That seems to cut down the GDI+ errors to very rare occurrences. When that happens, I simply retry the processing again.

Thanks for your help, and wishing you a happy new year.
xequte Posted - Dec 28 2020 : 18:15:59
Hi

I can't reproduce an exception when I disable layer usage.

I think you are courting trouble using a TImageEnView object that is shared by all threads. Either create the TImageEnView in the thread execute method, or better yet, don't use a TImageEnView, just a TIEBitmap which you draw using TIECanvas methods.

Ensure you avoid any functions (such as TCanvas ones) that force TIEBitmap to change its location to TBitmap:

https://www.imageen.com/help/TIEBitmap.Location.html

Nigel
Xequte Software
www.imageen.com
yeohray2 Posted - Dec 22 2020 : 11:17:56
Ok, I tried using the TextOut methods, and they do work better, but still occasionally raise the GDI+ error.

I'm attaching a test app, together with the sample image. With layers selected, it's easy to reproduce the error. Deselect the layers option, and it'll use the TextOut methods. It's harder to reproduce the error (might error out the first time, or not at all).

If you can't reproduce the error, try clicking on the Test button repeatedly a few times.

Thanks in advance.

attach/yeohray2/20201222111739_source.zip
149.31 KB
xequte Posted - Dec 21 2020 : 15:49:57
Hi

Have you tried writing directly to the image using TIECanvas text methods, rather than a TIETextLayer?

Are you able to send us a simple demo that reproduce the issue?

Nigel
Xequte Software
www.imageen.com
yeohray2 Posted - Dec 21 2020 : 05:00:20
The GDI+ error occur in:
TIECanvas.Create

Access violations occur at:
IE_GdipDeleteFont in TIECanvas.DrawTextEx
IE_GdipMeasureString in TIECanvas.DrawTextEx
IE_GdipDeleteStringFormat in TIECanvas.DrawTextEx
IE_GdipDrawString in TIECanvas.DrawTextEx
TIEBitmap.SynchronizeRGBA
TIEBitmap.BuildBitmapScanlines;

If I use a common critical section around each thread's LayersMergeAll call like this:

CriticalSection.Enter;
try
FWorkImage.LayersMergeAll;
WorkImage.Update;
finally
CriticalSection.Leave;
end;

then the access violations occur only in the DrawTextEx function.

Should also add that I'm formatting the text in the layers using RichEdit formatting, so errors are also intermittenly raised in the TIERichEdit unit.