Hi,
I am trying to create a PNG image from scratch using the TImage class.
I can import easily a PNG image into TImage, using
TImage *img = TImage::Open(“file.png”);
I can then modify the image directly using i.e. PutPixel( x, y, color )
And I can Draw it without problems.
However, if I do
TImage *img = new TImage( 60, 60 );
I define the pixels color using
for( int n = 0; n < 60; n++ )
for( int m = 0; m < 60; m++ )
img->PutPixel( n, m, "#0000FF");
but then when I try to draw img->Draw(); it shows nothing on the canvas.
There is something else missing?
Thanks!
couet
April 25, 2017, 8:51am
2
Do you have a small running script showing the problem ?
NewPNG.C (275 Bytes)
LoadPNG.C (228 Bytes)
Here I send two macros. LoadPNG works as I expect. But NewPNG does not.
couet
April 25, 2017, 9:03am
4
Your macro is wrong. In the 2nd loop at line 12 “m” is not defined.
Just replace the “m” by a number between 0 and 59. The problem is still not solved.
couet
April 25, 2017, 9:24am
6
I tried to mimic what is done in TImageDump. But until now I have no success with your macro.
The only way I found working was to load and white image from a png file.
Ok, it seems my problem is solved by using TImage::Create and SetImage.
I attach the macro that finally did it.
NewPNG2.C (321 Bytes)
system
Closed
May 9, 2017, 9:48am
8
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.