Previous: 4.51.2.4.30. ogGetPal() To the Table of Contents Next: 4.51.2.4.32. ogGetPixFmt()
4.51.2.4.30. ogGetPal() Table of Contents 4.51.2.4.32. ogGetPixFmt()

- 4.51.2.4.31. -
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.31. ogGetPixel()


4.51.2.4.31. ogGetPixel()

Targets: MS-DOS, Win32 console


ObjGfx40 Unit

Gets the pixel value at (x,y).

Declaration:
  function ogGetPixel(x, y:int32):uInt32; virtual;
Remarks:

Gets the pixel value at (x,y). If the surface's bit-depth is 8BPP, this will return the indexed colour value, otherwise it will return a packed pixel.

Restrictions:

Any pixel out of bounds of the surface will return the transparent colour.

See also: Sample code:
{ogGetPixel.pas}

uses
  ObjGfx40, CRT;

var 
  buf:^ogSurface;
  xx, yy:uInt32;
    
begin

  new(buf, ogInit);

  {Create a 640x480x8bpp surface}
  if not buf^.ogCreate(640, 480, OG_PIXFMT_8BPP) then
    begin
      writeln('Error allocating memory');
      halt
    end;

  {Fill Buf with vertical lines}
  for xx:=0 to buf^.ogGetMaxX do
    buf^.ogVLine(xx, 0, buf^.ogGetMaxY, xx);

  {Init 640x480x8bpp video mode}
  if not screen^.ogCreate(640, 480, OG_PIXFMT_8BPP) then
    begin
      writeln('Error setting video mode');
      halt
    end;

  {Copy all the pixels in Buf to the screen using an inefficient method}
  for yy:=0 to buf^.ogGetMaxY do
    for xx:=0 to buf^.ogGetMaxX do
      screen^.ogSetPixel(xx, yy, buf^.ogGetPixel(xx, yy));

  readKey;
  dispose(buf, ogDone);
end.



Previous: 4.51.2.4.30. ogGetPal() To the Table of Contents Next: 4.51.2.4.32. ogGetPixFmt()
4.51.2.4.30. ogGetPal() Table of Contents 4.51.2.4.32. ogGetPixFmt()

- 4.51.2.4.31. -