Jump to content
Sign in to follow this  
Wayne Fulcher

TPNGImage.SetSize method has a bug.

Recommended Posts

I am using the latest version of Delphi 12 and I want to simply create a PNG and draw an image on the canvas.

However when I try to set the size it always crashes due to bug.

 

My code is simple:

png := TPNGImage.Create ;
png.SetSize(800, 1100) ;  <- Exception occurs here 
png.Canvas.Draw(.....) ;

This code works fine in Delphi 7 so I am trying to understand how to set the size of a TPNGImage instance.

Whats happening in Delphi 12 code the SetWidth and the SetHeight just calls Resize() in the background.

The problem is when it first calls Resize from the SetWidth, the height has not been set yet so it throws an exception.

And if I modify my code to call png.Resize(800, 1100) directly then it throws another exception saying there is no header.

What am I missing?

 

TIA

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×