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
 Error saving to png after adding vector layer
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  

yeohray2

Malaysia
106 Posts

Posted - Jul 25 2020 :  05:22:39  Show Profile  Reply
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



xequte

38611 Posts

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

yeohray2

Malaysia
106 Posts

Posted - Jul 28 2020 :  00:50:01  Show Profile  Reply
I see, thx. I'll just adjust the SamplesPerPixel then.
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
Jump To: