Search code examples
pascallazarus

Cannot use TFPColor identifier in Lazarus


I'm trying to declare a function that returns TFPColor type but I got an error message:

Error: Identifier not found "TFPColor"

function luminosity(img: TImage; i,j: Integer): TFPColor;
var
  r, g, b: byte;
begin
  r:= round(red(img.Picture.bitmap.canvas.pixels[i,j]) * 0.21);
  g:=  round(green(img.Picture.bitmap.canvas.pixels[i,j]) * 0.72);
  b:= round(blue(img.Picture.bitmap.canvas.pixels[i,j]) * 0.07);
  luminosity := TColorToFPColor(RGBToColor(r, g, b));
end; 

I've already declared the Graphics unit in the preamble of the unit!


Solution

  • TFPColor is declared in the FPImage.Pas unit:

      TFPColor = record
        red,green,blue,alpha : word;
      end;
    

    so you need to add FPImage.Pas to your Uses list.

    Btw afaics, it's not declared in any of the Delphi7 standard units.