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
 Error saving to png after adding vector layer

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 - Jul 25 2020 : 05:22:39
I have a png file which I add a layer to, then try to save it again. Code as follows:

vect1.IO.LoadFromFile('f:\temp\image.png');

// Append a text layer
vect1.LayersAdd( ielkText );
TIETextLayer(vect1.CurrentLayer).BorderColor := clInfoBk;
TIETextLayer(vect1.CurrentLayer).BorderWidth := 1;
TIETextLayer(vect1.CurrentLayer).FillColor := clWhite;
TIETextLayer(vect1.CurrentLayer).Font.Color := clBlack;
TIETextLayer(vect1.CurrentLayer).Alignment := iejCenter;
TIETextLayer(vect1.CurrentLayer).Layout := ielCenter;
vect1.CurrentLayer.PosX := 0;
vect1.CurrentLayer.PosY := 57;
vect1.CurrentLayer.Width := 128;
vect1.CurrentLayer.Height := 14;

TIETextLayer(vect1.CurrentLayer).Font.Size := 8;
TIETextLayer(vect1.CurrentLayer).Font.Name := 'Times New Roman';
TIETextLayer(vect1.CurrentLayer).Text := 'SOME WATERMARK';
TIETextLayer(vect1.CurrentLayer).SizeToText;

vect1.CurrentLayer.Width := 128;
vect1.CurrentLayer.PosY := (128 - vect1.CurrentLayer.Height) div 2;

vect1.CurrentLayer.Transparency := 170;

vect1.Update;

vect1.LayersMergeAll(False);
vect1.IO.savetofile('f:\temp\image_watermark.png', ioPng);

Upon saving, the error 'Error on creating PNG' is raised. Is there something wrong with my code? It doesn't happen for all files, just some. I'm attaching one of the affected files.

Thanks in advance.

Ray



2   L A T E S T    R E P L I E S    (Newest First)
yeohray2 Posted - Jul 28 2020 : 00:50:01
I see, thx. I'll just adjust the SamplesPerPixel then.
xequte Posted - Jul 27 2020 : 19:53:43
Hi Ray

The source image has SamplesPerPixel=1 and BitsPerSample=16, so the PNG encoder tries to save the image as gray scale. But due to the watermark, the image is no longer gray scale, which causes the issue.

You can correct the SamplesPerPixel in the image, or you can email me for a fix, which automatically resolves it.

Nigel
Xequte Software
www.imageen.com