Recent

Author Topic: Incorrect painting on png image loaded from file  (Read 1910 times)

wp

  • Hero Member
  • *****
  • Posts: 11858
Incorrect painting on png image loaded from file
« on: December 20, 2012, 04:04:47 pm »
Suppose I want to paint a red rectangle onto the canvas of a png graphic. The graphic is loaded from the attached file. But the image into which the modified png is copied shows only a punched-out rectangle. I tried various different approaches, but don't find the clue.

The issue seems to be related to this particular file. When I am using png files that I saved from screenshots the program has normal behaviour..

 I am using the following code to load and modify the png file and to show it in a TImage component:

Code: [Select]
procedure TForm1.FormCreate(Sender: TObject);
var
  png: TPortableNetworkGraphic;
begin
  png := TPortableNetworkGraphic.Create;
  try
    png.LoadFromFile('test.png');
    png.Canvas.Brush.Style := bsSolid;
    png.Canvas.Brush.Color := clRed;
    png.Canvas.Rectangle(100, 100, 200, 200);
    Image1.Picture.Assign(png);
  finally
    png.Free;
  end;
end;
       

What is wrong?

 

TinyPortal © 2005-2018