View Issue Details

IDProjectCategoryView StatusLast Update
0038147LazarusLCLpublic2020-11-30 21:53
ReporterMaurizio Assigned To 
PrioritynormalSeverityminorReproducibilityalways
Status newResolutionopen 
Product Version2.0.10 
Summary0038147: TBitmap.SetPalette does nothing
DescriptionAssignment of a palette to TBitmap.Palette (i.e. the call to TBitmap.SetPalette) doesn't work.
The program executes immediately the ancestor TGraphic.SetPalette that's a simple placeholder (i.e. does nothing).
TagsNo tags attached.
Fixed in Revision
LazTarget-
WidgetsetWin32/Win64
Attached Files

Activities

Don Siders

2020-11-28 22:14

reporter   ~0127248

What is the color depth for the image? LCL asks for the palette info in raw image data for 4-bit and 8-bit only.

Maurizio

2020-11-28 22:21

reporter   ~0127249

Last edited: 2020-11-28 22:23

View 2 revisions

Color depth tried: pf1bit, pf4bit, pf8bit
N.B. The same code works perfectly in Delphi

Maurizio

2020-11-29 11:31

reporter   ~0127254

Inheritance tree:
TGraphic -> TRasterImage -> TCustomBitmap -> TFPImageBitmap -> TBitmap
The only one that "implements" SetPalette is TGraphic but, as I wrote, only as an abstract procedure.
SetPalette must be implemented somewhere in between, possibly in TCustomBitmap where already GetPalette is overrided.

Juha Manninen

2020-11-30 17:29

developer   ~0127269

> N.B. The same code works perfectly in Delphi

Which code? Can you please upload a simple example to reproduce the problem.

Maurizio

2020-11-30 21:53

reporter   ~0127282

Well: whatever use of the assignment of a palette to a bitmap is faulty.
Anyway, a stupid example:

var
  ImageBitmap: TBitmap;

procedure SetPalette;
const
  MaxPaletteColors = 256;
var
  LocalPalette: PLogPalette;
  Color: integer;
begin
  GetMem(LocalPalette, Sizeof(TLogPalette) + Sizeof(TPaletteEntry)*(MaxPaletteColors - 1));
  LocalPalette.palVersion:=$300;
  LocalPalette.palNumEntries:=MaxPaletteColors;
  for Color:=0 to Pred(MaxPaletteColors) do
  begin
    LocalPalette.palPalEntry[Color].peRed:=Color;
    LocalPalette.palPalEntry[Color].peGreen:=Color;
    LocalPalette.palPalEntry[Color].peBlue:=Color;
    LocalPalette.palPalEntry[Color].peFlags:=0;
  end;
  ImageBitmap.Palette:=CreatePalette(LocalPalette^);
  FreeMem(LocalPalette);
end; { SetPalette }

begin
  ImageBitmap:=TBitmap.Create;
  SetPalette;
  ImageBitmap.Free;
end.

Issue History

Date Modified Username Field Change
2020-11-28 20:21 Maurizio New Issue
2020-11-28 22:14 Don Siders Note Added: 0127248
2020-11-28 22:21 Maurizio Note Added: 0127249
2020-11-28 22:23 Maurizio Note Edited: 0127249 View Revisions
2020-11-29 11:31 Maurizio Note Added: 0127254
2020-11-30 17:29 Juha Manninen Note Added: 0127269
2020-11-30 18:00 Bart Broersma Status new => feedback
2020-11-30 18:00 Bart Broersma LazTarget => -
2020-11-30 21:53 Maurizio Note Added: 0127282
2020-11-30 21:53 Maurizio Status feedback => new