[Lazarus] Color thief
Michael Van Canneyt
michael at freepascal.org
Wed Jul 8 23:20:12 CEST 2015
On Wed, 8 Jul 2015, aradeonas wrote:
> Here you are.
>
> http://lokeshdhakar.com/projects/color-thief/img/photo1.jpg
Your program contained an error, I should have seen it at once.
You used TFPCustomImage. This is an abstract class.
You should have used a descendent like TFPMemoryImage instead.
(
the compiler warns you:
testpalette.lpr(10,37) Warning: Constructing a class "TFPCustomImage" with abstract method "SetInternalPixel"
)
So:
program testpalette;
uses fpimage,fpreadjpeg;
var
i: Integer;
Img: TFPCustomImage;
begin
Img := TFPMemoryImage.Create(0, 0);
try
img.LoadFromFile('photo1.jpg');
img.UsePalette := True;
for i := 0 to img.Palette.Count-1 do
With img.Palette.Color[i] do
Writeln(red,',',green,',',blue);
finally
Img.free;
end;
end.
Works as expected.
Michael.
More information about the Lazarus
mailing list