Note that there are some explanatory texts on larger screens.

plurals
  1. POHow can I access the palette of a TPicture.Graphic?
    primarykey
    data
    text
    <p>I have searched the web for hours but I can not find anything about how to get the palette from a TPicture.Graphic. I also need to get the color values so I can pass these values to a TStringList for filling cells in a colorpicker.</p> <p>Here is the code that I currently have:</p> <pre><code>procedure TFormMain.OpenImage1Click( Sender: TObject ); var i: integer; S: TStringList; AColor: TColor; AColorCount: integer; N: string; Pal: PLogPalette; HPal: hPalette; begin if OpenPictureDialog1.Execute then begin Screen.Cursor := crHourGlass; try Pal := nil; try S := TStringList.Create; ABitmap.Free; // Release any existing bitmap ABitmap := TBitmap.Create; Image1.Picture.LoadFromFile( OpenPictureDialog1.Filename ); ABitmap.Canvas.Draw( 0, 0, Image1.Picture.Graphic ); GetMem( Pal, Sizeof( TLogPalette ) + Sizeof( TPaletteEntry ) * 255 ); Pal.palversion := $300; Pal.palnumentries := 256; for i := 0 to 255 do begin AColor := Pal.PalPalEntry[ i ].PeRed shl 16 + Pal.PalPalEntry[ i ].PeGreen shl 8 + Pal.PalPalEntry[ i ].PeBlue; N := ColorToString( AColor ); S.Add( N ); end; HPal := CreatePalette( Pal^ ); ABitmap.Palette := HPal; Memo1.Lines := S; finally; FreeMem( Pal ); end; S.Free; finally; Screen.Cursor := crDefault; end; end; end; </code></pre> <p>I am drawing to the canvas of ABitmap with the image contained in Image1.Picture.Graphic because I want to support all TPicture image types such as Bitmap, Jpeg, PngImage, and GIfImg.</p> <p>Any assistance would be appreciated. Am I on the correct path or is something different needed?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload