Results 1 to 5 of 5

Thread: TDirectDrawSurface and TDirectDrawPalette

  1. #1

    TDirectDrawSurface and TDirectDrawPalette

    This has got me stumped, and I cannot google anything to help me. I`m trying to set the palette of a TDirectDrawSurface.

    Code:
      DXFont8: TDirectDrawSurface;
      FlickPal: TDirectDrawPalette;
      FlickPalEntries: Array[0..255] of TPaletteEntry;
    Code:
    procedure TForm1.DXDraw1Initialize(Sender: TObject);
    begin
     DXFont8:=TDirectDrawSurface.Create(DXDraw1.DDraw);
     DXFont8.LoadFromGraphic(DxImageList1.Items.Find('robotron_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)
    Code:
    // 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);
    
     DXFont8.Palette:=FlickPal;
      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.

  2. #2

    TDirectDrawSurface and TDirectDrawPalette

    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).
    [size=10px][ Join us in #pgd on irc.freenode.net ] [ Sign the Petition for a Software Patent Free Europe ][/size]

  3. #3

    TDirectDrawSurface and TDirectDrawPalette

    This is an 8bit palette.

  4. #4

    TDirectDrawSurface and TDirectDrawPalette

    *bump*

  5. #5

    TDirectDrawSurface and TDirectDrawPalette

    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?

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •