HI
I am trying to implement the weight concept of each "unique color pixel" that a bitmap contains, just like what BGRA ColorQuantizer does, and I thought I can do it by computing number of pixels of the colors that the bitmap contains for each color, but I was wrong, it seems that its doing more things. I was tring to read BGRA methods, and now I have some problem understanding purpose and steps of GetAsArrayOfWeightedColors method in class TBGRAColorTree in unit BGRAColorQuantization, (line 1274), as you can see in Screenshot attached.
I am getting BGRA package from git.
Any idea how BGRA ColorQuantizer works to implement weight concept for colors pallet??
I just wanna understand the concept and steps to gaining each color weights in BGRA.
Any help appreciated prior
Regards
Here is my test code to gain color pallet from BGRA:
procedure TForm1.ColorPallet;
var
quant: TBGRAColorQuantizer;
i, j, ColorPalleteCount: integer;
arr: ArrayOfWeightedColor;
begin
SourceBmp := TBGRABitmap.Create('Pics' + PathDelim + 'Picture.jpg');
quant := TBGRAColorQuantizer.Create(SourceBmp, acFullChannelInPalette, 10);
ColorPalleteCount := quant.ReducedPalette.Count;
arr := quant.ReducedPalette.GetAsArrayOfWeightedColor;
//Display the color pallet
for i := 0 to ColorPalleteCount - 1 do
begin
WriteLn('Weight [ ', i, ' ] : ', arr[i].Weight);
WriteLn('Color [ ', i, ' ] : (', arr[i].Color.red, ' , ', arr[i].Color.green, ' , ', arr[i].Color.blue, ' )');
end;
quant.Free;
SourceBmp.Free;
end;