Previous: 4.51.2.4.40. ogLine() To the Table of Contents Next: 4.51.2.4.42. ogPolygon()
4.51.2.4.40. ogLine() Table of Contents 4.51.2.4.42. ogPolygon()

- 4.51.2.4.41. -
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.41. ogLoadPal()


4.51.2.4.41. ogLoadPal()

Targets: MS-DOS, Win32 console


ObjGfx40 Unit

Loads a palette off disk into a surface.

Declaration:
  function ogLoadPal(const palfile:string):boolean; virtual;
Remarks:

Loads a palette contained in 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 load was successful. Returns FALSE if the file doesn't exist or the palette couldn't be completely read in. In the event there is an error loading the palette, the original palette will be restored.

Restrictions:

Only relevant in 8BPP surfaces. The palette is unused for high and true colour buffers. Will allocate a new palette if none exists.

See also: Sample code:
{ogLoadPal.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.40. ogLine() To the Table of Contents Next: 4.51.2.4.42. ogPolygon()
4.51.2.4.40. ogLine() Table of Contents 4.51.2.4.42. ogPolygon()

- 4.51.2.4.41. -