Previous: 4.51.2.4.45. ogRGBA() To the Table of Contents Next: 4.51.2.4.47. ogScale()
4.51.2.4.45. ogRGBA() Table of Contents 4.51.2.4.47. ogScale()

- 4.51.2.4.46. -
Table of Contents
4. Standard Units
4.51. ObjGfx40 - ObjectGraphics 4.0 Unit
4.51.2. ObjGfx40 Unit Object Types
4.51.2.4. ogSurface object
4.51.2.4.46. ogSavePal()


4.51.2.4.46. ogSavePal()

Targets: MS-DOS, Win32 console


ObjGfx40 Unit

Saves a palette from a surface to disk.

Declaration:
  function ogSavePal(const palFile:string):boolean;
Remarks:

Saves a palette to palFile. A palette is an array of 256 RGBA byte values. For each RGB value 0 is minimum, and 255 is maximum. The A (alpha) field is used for alignment. Returns TRUE if the save was successful. Returns FALSE if the file could not be created or written to.

Restrictions:

Only relevant in 8BPP surfaces. The palette is unused for high and true colour surfaces.

See also: Sample code:
{ogSavePal.pas}

uses
  ObjGfx40;

var 
  buf1, buf2:^ogSurface;

begin
  new(buf1, ogInit);
  new(buf2, ogInit);

  {Create an 8bpp surface}
  if not buf1^.ogCreate(200, 200, OG_PIXFMT_8BPP) then
    begin
      writeln('Error creating buf1');
      halt
    end;

  {Create another 8bpp surface}
  if not Buf2^.ogCreate(400, 400, OG_PIXFMT_8BPP) then
    begin
      writeln('Error creating buf2');
      halt
    end;

  {Save the palette in buf1 to disk.}
  buf1^.ogSavePal('default.pal');

  {Load the palette we just saved into buf2.  This can also be
   done directly with dest.ogCopyPal(source);}
  if not buf2^.ogLoadPal('default.pal') then
    writeln('Error loading palette');

  dispose(buf2, ogDone);
  dispose(buf1, ogDone);
end.



Previous: 4.51.2.4.45. ogRGBA() To the Table of Contents Next: 4.51.2.4.47. ogScale()
4.51.2.4.45. ogRGBA() Table of Contents 4.51.2.4.47. ogScale()

- 4.51.2.4.46. -