L3DT documentation
Large 3D terrain generator

zmap_GetPixel

Description

Get the value of a pixel in a map.

Files

Declaration Zeolite.h
Implementation Zeolite.cpp

Function prototype

bool zmap_GetPixel(ZMAP hMap, long x, long y, void* pValue);

Arguments

Name Type Comment
hMap ZMAP A ZMAP handle to a map, the pixel of which is to be retrieved.
x long The x-coordinate of the pixel.
y long The y-coordinate of the pixel.
pValue void* A pointer (of unknown type) to the user-supplied entity that shall receive the pixel value.

Return value

False if an error occurred, and true otherwise.

Comments

None.

Example

int nx = zmap_GetWidth(hMap);
int ny = zmap_GetHeight(hMap);

// check the map type before messing with pixels
if(MAP_Heightfield!=zmap_GetTypeID(hMap))
  return false;

float val;

// step through all pixels
for(int j=0; j<ny; j++) {
  for(int i=0; i<nx; i++) {
    if(!zmap_GetPixel(hMap, i, j, &val)) // get the pixel value
      return false;
 
    val+=10.0f; // increment the value by 10

    if(!zmap_SetPixel(hMap, i, j, &val)) // set the pixel value again
      return false;
  }
}

return true;
 
zeolite/functions/zmap_getpixel.txt · Last modified: 2017/08/31 07:29 (external edit)
 
Except where otherwise noted, content on this wiki is licensed under the following license:CC Attribution-Share Alike 3.0 Unported
Recent changes RSS feed Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki