TBGRABitmap image palette converting lazarus / 39-Graphics ---------------------------------------------------------------------- SteenJorgensen · 2019-07-27 07:22 I need help for converting a TBGRABitmap to a customize palette. In my code i end up with a image in correct size but i also need to converted all the color to 20 different TColor i have pre-defined. This give me trouble, any idea? I use BGRABitmap v10.4. ---------------------------------------------------------------------- circular · 2019-07-27 20:58 Ok. So you can supply your palette using a TBGRAPalette object (unit BGRAPalette). You can add your color using AddColor. Then you can use a TBGRAColorQuantizer object (unit BGRAColorQuantization). Create it using your palette as a parameter. With ApplyDitheringInplace, it replaces the colors directly. Otherwise GetDitheredBitmap will return a new bitmap. ---------------------------------------------------------------------- SteenJorgensen · 2019-07-29 05:51 Thanks, great! I have made a little test procedure and this works with 20 color. BUT not with my colorpallet. I can't find where to put the pallette parameter in, in the TBGRAColorQuantizer.create.   Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure TForm1.bTestConvClick(Sender: TObject);var  ImageP: TBGRABitmap;  Quant: TBGRAColorQuantizer;  WorkPalette: TBGRAPalette;begin  Try    WorkPalette := TBGRAPalette.Create;    If FileExists('WorkPallet.pal') then      WorkPalette.LoadFromFile('WorkPallet.pal');     ImageP  := TBGRABitmap.Create(200, 200, ColorToBGRA(ColorToRGB(clBtnFace)));    BGRAReplace(ImageP, ImageCrop.Resample(200, 200, rmFineResample));   Quant := TBGRAColorQuantizer.Create(ImageP, acFullChannelInPalette, 20);    Quant.ApplyDitheringInplace(daNearestNeighbor, ImageP);     ImageP.Draw(Panel10.Canvas, 0, 0, True);   finally    ImageP.Free;    WorkPalette.Free;  end;end; ---------------------------------------------------------------------- circular · 2019-07-29 10:43 When creating TBGRAColorQuantizer, change the parameter of Create to your palette WorkPalette instead of ImageP. Note that you can also replace Code: Delphi  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i     ImageP  := TBGRABitmap.Create(200, 200, ColorToBGRA(ColorToRGB(clBtnFace)));    BGRAReplace(ImageP, ImageCrop.Resample(200, 200, rmFineResample));by Code: Delphi  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i     ImageP  := ImageCrop.Resample(200, 200, rmFineResample) as TBGRABitmap;