Zen API

- Home
- Topics
- Types
- Files

All Classes Files Functions Variables Typedefs Friends Macros Modules Pages
Public Member Functions
kImage Class Reference
kApi/Data

## Description

Represents a 2D collection of pixels.

The kImage class is similar to the kArray2 class, with some important differences:

- By default, image memory is allocated such that rows are aligned to 8-byte boundaries.
- Pixels are limited to value types.
- Image indices/dimensions are given in (column, row) rather than (row, column) order.
- kImage contains additional image-specific attributes (e.g. color filter array type).

In particular, the row-alignment behaviour means that image memory should typically be accessed by getting a pointer to the beginning of a row, and then iterating over pixels. E.g.

kSize height = kImage_Height(image);
kSize width = kImage_Width(image);
kSize i, j;
k32u sum = 0;
kAssert(kImage_PixelType(image, kTypeOf(k8u)));
for (i = 0; i < height; ++i)
{
k8u* row = kImage_RowAt(image, i);
for (j = 0; j < width; ++j)
{
sum += row[j];
}
}

kImage supports the kObject_Clone and kObject_Size methods.

kImage supports the kdat5 and kdat6 serialization protocols.

Inheritance diagram for kImage:

## Public Member Functions
kStatus | kImage_Allocate (kImage image, kType pixelType, kSize width, kSize height)
| Reallocates the internal pixel buffer. More...
kSize | kImage_Area (kImage image)
| Returns the area of the image, in pixels. More...
kStatus | kImage_Assign (kImage image, kImage source)
| Copies a given source image into this image. More...
void * | kImage_At (kImage image, kSize x, kSize y)
| Returns a pointer to the specified pixel in the pixel buffer. More...
kStatus | kImage_Attach (kImage image, void *pixels, kType pixelType, kSize width, kSize height, kSize stride)
| Attaches the image to an external pixel buffer. More...
kCfa | kImage_Cfa (kImage image)
| Gets the color filter array type associated with this image. More...
kStatus | kImage_Construct (kImage *image, kType pixelType, kSize width, kSize height, kAlloc allocator)
| Constructs a kImage object. More...
void * | kImage_Data (kImage image)
| Returns a pointer to the first row in the pixel buffer. More...
kSize | kImage_DataSize (kImage image)
| Reports the size, in bytes, of the pixel buffer. More...
kStatus | kImage_Export (kImage image, const char *fileName)
| Saves an image to file. More...
kSize | kImage_Height (kImage image)
| Returns the height of the image, in pixels. More...
kStatus | kImage_Import (kImage *image, const char *fileName, kAlloc allocator)
| Loads an image from file. More...
kStatus | kImage_Pixel (kImage image, kSize x, kSize y, void *pixel)
| Gets the value of a pixel. More...
kPixelFormat | kImage_PixelFormat (kImage image)
| Gets the optional pixel format descriptor associated with this image. More...
kSize | kImage_PixelSize (kImage image)
| Returns the pixel size. More...
kType | kImage_PixelType (kImage image)
| Returns the pixel type. More...
void * | kImage_RowAt (kImage image, kSize y)
| Returns a pointer to the specified row in the pixel buffer. More...
kStatus | kImage_SetCfa (kImage image, kCfa cfa)
| Sets the color filter array type associated with this image. More...
kStatus | kImage_SetPixel (kImage image, kSize x, kSize y, const void *pixel)
| Sets the value of a pixel. More...
kStatus | kImage_SetPixelFormat (kImage image, kPixelFormat format)
| Sets the optional pixel format descriptor associated with this image. More...
kSize | kImage_Stride (kImage image)
| Returns the size of an image row, including alignment padding bytes, in bytes. More...
kSize | kImage_Width (kImage image)
| Returns the width of the image, in pixels. More...
kStatus | kImage_Zero (kImage image)
| Sets all pixel bits to zero. More...
Public Member Functions inherited from kObject
kAlloc | kObject_Alloc (kObject object)
| Gets the memory allocator associated with this object. More...
kStatus | kObject_Clone (kObject *object, kObject source, kAlloc allocator)
| Constructs a new object by copying an existing object, including any aggregated child elements. More...
kStatus | kObject_Destroy (kObject object)
| Destroys the object. More...
kStatus | kObject_Dispose (kObject object)
| Destroys the object and any aggregated child elements. More...
kBool | kObject_Equals (kObject object, kObject other)
| Determines whether the object is equal to another object. More...
kSize | kObject_HashCode (kObject object)
| Gets a hash code representing the state of this object. More...
kBool | kObject_Is (kObject object, kType type)
| Determines whether this object is an instance of the specified type. More...
kBool | kObject_IsShared (kObject object)
| Reports whether the object is currently shared (reference count greater than one). More...
kStatus | kObject_SetPool (kObject object, kObjectPool pool)
| Sets the object pool associated with this object. More...
kStatus | kObject_Share (kObject object)
| Increments the reference count associated with this object. More...
kSize | kObject_Size (kObject object)
| Estimates the memory consumed by this object, including any aggregated child elements. More...
kType | kObject_Type (kObject object)
| Returns the type of the object. More...

## Related
#define | kImage_Data_(IMAGE) kxImage_Data_(IMAGE)
| Macro version of kImage_Data.
#define | kImage_DataSize_(IMAGE) kxImage_DataSize_(IMAGE)
| Macro version of kImage_DataSize.
#define | kImage_At_(IMAGE, X, Y) kxImage_At_(IMAGE, X, Y)
| Macro version of kImage_At.
#define | kImage_RowAt_(IMAGE, Y) kxImage_RowAt_(IMAGE, Y)
| Macro version of kImage_RowAt.
#define | kImage_PixelType_(IMAGE) kxImage_PixelType_(IMAGE)
| Macro version of kImage_PixelType.
#define | kImage_PixelSize_(IMAGE) kxImage_PixelSize_(IMAGE)
| Macro version of kImage_PixelSize.
#define | kImage_Width_(IMAGE) kxImage_Width_(IMAGE)
| Macro version of kImage_Width.
#define | kImage_Height_(IMAGE) kxImage_Height_(IMAGE)
| Macro version of kImage_Height.
#define | kImage_Area_(IMAGE) kxImage_Area_(IMAGE)
| Macro version of kImage_Area.
#define | kImage_Stride_(IMAGE) kxImage_Stride_(IMAGE)
| Macro version of kImage_Stride.
#define | kImage_PixelFormat_(IMAGE) kxImage_PixelFormat_(IMAGE)
| Macro version of kImage_PixelFormat.
#define | kImage_Cfa_(IMAGE) kxImage_Cfa_(IMAGE)
| Macro version of kImage_Cfa.
#define | kImage_As_(IMAGE, X, Y, TYPE) kxImage_As_(IMAGE, X, Y, TYPE)
| Accesses a pixel at the specified location, and casts the value to the specified type. More...
Related inherited from kObject
#define | kObject_Type_(OBJ) kxObject_Type_(OBJ)
| Macro version of kObject_Type.
#define | kObject_Is_(OBJ, TYPE) kxObject_Is_(OBJ, TYPE)
| Macro version of kObject_Is.
#define | kObject_Alloc_(OBJ) kxObject_Allocator_(OBJ)
| Macro version of kObject_Alloc.

The documentation for this class was generated from the following file:

- Data/kImage.h