View Full Version : TDirectDrawSurface and TDirectDrawPalette

13-03-2005, 01:31 PM
This has got me stumped, and I cannot google anything to help me. I`m trying to set the palette of a TDirectDrawSurface.

DXFont8: TDirectDrawSurface;
FlickPal: TDirectDrawPalette;
FlickPalEntries: Array[0..255] of TPaletteEntry;

procedure TForm1.DXDraw1Initialize(Sender: TObject);
DXFont8.LoadFromGraphic(DxImageList1.Items.Find('r obotron_font8').Picture.Graphic);

FlickPal:=TDirectDrawPalette.Create(DXFont8.DDraw) ;
FlickPal.CreatePalette(DDPCAPS_8BIT or DDPCAPS_INITIALIZE or DDPCAPS_ALLOW256,FlickPalEntries);

Then I try to draw the surface to the backbuffer (16 bit)

// try this?
FlickPal.Entries[0]:=RGBQuadToPaletteEntry(RGBQuad (255, 255, 255));
FlickPal.Entries[1]:=RGBQuadToPaletteEntry(RGBQuad (0, 0, 0));

// or try this?
FlickPalEntries[0]:=RGBQuadToPaletteEntry(RGBQuad( 255, 0, 0));
FlickPalEntries[1]:=RGBQuadToPaletteEntry(RGBQuad( 0, 0, 0));
FlickPal.SetEntries(0, 256, FlickPalEntries);

DXDraw1.Surface.Draw(px+(x*8), py, rect(lChar,0,lChar+8,7), DXFont8, False);

But the same (original) palette is effective.
No errors are returned from the palette creation or setting, but just doesn't take effect.

Useless Hacker
17-03-2005, 12:56 AM
Palettes are only used for 8-bit colour or less, for higher bitrates the colours are represented directly. You will either have to create the surface with an 8-bit palette, or manipulate the pixels individually (which will be very slow).

22-03-2005, 07:42 PM
This is an 8bit palette.

06-05-2007, 01:43 PM

11-06-2007, 12:07 AM
Well, I had to recode a lot of stuff cos I could never get an answer / solution to this. It was a major problem for me, but hasn't this caused problems for anyone else?