简体   繁体   中英

How can I get png image RGBcolors in delphi 2009

I have a cipher encoded as a color series in a png image

the image is RGB-colored but the code is ciphered only in the green byte

How can I get the RGB colors in this 1x84 pixel image?

This is not difficult. Example, showing the R, G, and B bytes of pixel (0, 0):

procedure TForm1.Click(Sender: TObject);
var
  png: TPngImage;
  clr: TColor;
begin
  png := TPngImage.Create;
  try
    png.LoadFromFile('C:\example.png');
    clr := png.Canvas.Pixels[0, 0];
    ShowMessage(IntToStr(GetRValue(clr)));
    ShowMessage(IntToStr(GetGValue(clr)));
    ShowMessage(IntToStr(GetBValue(clr)));
  finally
    png.Free;
  end;
end;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM