Jump to content


Photo

PNG into CustomDraw


  • Please log in to reply
1 reply to this topic

#1 Afiag

Afiag
  • Members
  • 117 posts

Posted 19 August 2010 - 03:53 AM

Hi Boki,

I was using the following code before:

procedure TForm1.NextDBGrid1CustomDrawCell(Sender: TObject; ACol, ARow: Integer;
CellRect: TRect; CellState: TCellState);
var
ABitmap: TBitmap;
FileName: string;
begin
FileName := 'images\ficons\' + QueryRankings.FieldByName('Location').AsString + '.bmp';
ABitmap := TBitmap.Create;
ABitmap.LoadFromFile(FileName);
NextDBGrid1.Canvas.Draw(CellRect.Left, CellRect.Top + 5, ABitmap);
ABitmap.Free;
end;


This worked fine with *.bmp files ... however I find myself needing to use *.png images instead ... when I try to use this code (but ofcourse changing "+ '.bmp'; to "+ '.png';") I get a error "not a valid bitmap image"... how would I go about on getting it to load my png images ?

Thanks !

#2 Boki (Berg)

Boki (Berg)

    Boki (Berg)

  • Forum Admin
  • PipPipPipPipPip
  • 8,195 posts
  • Gender:Male

Posted 19 August 2010 - 03:28 PM

Hello Afiag,

I think that you need to get some thirdparty PNG component.

Then, you need to have something like PNGImage and then draw it.

Please sorry for such a short answer, I didn't have much experience in PNG Images.

What you can do is to use 32Bit BMP files (with ALPHA channel) and then use my built procedure ApplyBitmap to draw this image.

More about 32 bit bitmaps on: http://dn.bergsoft.n...ps-tutorial.htm

Best regards
boki@bergsoft.net | LinkedIn Profile
--
BergSoft Home Page: www.bergsoft.net
Users Section: users.bergsoft.net
Articles and Tutorials: help.bergsoft.net (Developers Network)
--
BergSoft Facebook page
--
Send us applications made with our components and we will submit them on: www.bergsoft.net/apps.htm. Link to this page will be also set on home page too.




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users