|
Zen API
|
Represents a 2D collection of pixels.
The kImage class is similar to the kArray2 class, but has some important differences:
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.
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... | |
| 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... | |
Reallocates the internal pixel buffer.
| image | Image object. |
| pixelType | Type of pixel (values types only). |
| width | Image width, in pixels. |
| height | Image height, in pixels. |
Returns the area of the image, in pixels.
Image area is the product of image width and image height.
| image | Image object. |
Copies a given source image into this image.
| image | Image object. |
| source | Source image to be copied. |
Returns a pointer to the specified pixel in the pixel buffer.
| image | Image object. |
| x | Column index. |
| y | Row index. |
| kStatus kImage_Attach | ( | kImage | image, |
| void * | pixels, | ||
| kType | pixelType, | ||
| kSize | width, | ||
| kSize | height, | ||
| kSize | stride | ||
| ) |
Attaches the image to an external pixel buffer.
Attached pixel buffers are not freed when the image is destroyed.
| image | Image object. |
| pixels | Pointer to external pixel buffer. |
| pixelType | Type of pixel (values types only). |
| width | Image width, in pixels. |
| height | Image height, in pixels. |
| stride | Image stride (row size), in bytes. |
Gets the color filter array type associated with this image.
| image | Image object. |
| kStatus kImage_Construct | ( | kImage * | image, |
| kType | pixelType, | ||
| kSize | width, | ||
| kSize | height, | ||
| kAlloc | allocator | ||
| ) |
Constructs a kImage object.
| image | Receives the constructed image object. |
| pixelType | Pixel type (must be a value type). |
| width | Image width. |
| height | Image height. |
| allocator | Memory allocator. |
| void * kImage_Data | ( | kImage | image | ) |
Returns a pointer to the first row in the pixel buffer.
| image | Image object. |
Reports the size, in bytes, of the pixel buffer.
| image | Image object. |
Saves an image to file.
The file extension is used to determine to image format. Currently, only the BMP (.bmp) format is supported.
| image | Image object. |
| fileName | File path. |
Returns the height of the image, in pixels.
| image | Image object. |
Loads an image from file.
The file extension is used to determine to image format. Currently, only the BMP (.bmp) format is supported.
| image | Receives the constructed image object. |
| fileName | File path. |
| allocator | Memory allocator (or kNULL for default). |
Gets the value of a pixel.
This method is convenient in some contexts, but is not an efficient method to access many pixels. In performance-critical code, use kImage_RowAt to directly access the pixel buffer.
| image | Image object. |
| x | Column index. |
| y | Row index. |
| pixel | Destination for pixel copied from the image. |
| kPixelFormat kImage_PixelFormat | ( | kImage | image | ) |
Gets the optional pixel format descriptor associated with this image.
| image | Image object. |
Returns the pixel size.
| image | Image object. |
Returns the pixel type.
| image | Image object. |
Returns a pointer to the specified row in the pixel buffer.
| image | Image object. |
| y | Row index. |
Sets the color filter array type associated with this image.
| image | Image object. |
| cfa | Color filter array type. |
Sets the value of a pixel.
This method is convenient in some contexts, but is not an efficient method to manipulate many pixels. In performance-critical code, use kImage_RowAt to directly access the pixel buffer.
| image | Image object. |
| x | Column index. |
| y | Row index. |
| pixel | Pointer to pixel value that will be copied into the image. |
| kStatus kImage_SetPixelFormat | ( | kImage | image, |
| kPixelFormat | format | ||
| ) |
Sets the optional pixel format descriptor associated with this image.
| image | Image object. |
| format | Pixel format. |
Returns the size of an image row, including alignment padding bytes, in bytes.
| image | Image object. |
Returns the width of the image, in pixels.
| image | Image object. |
Sets all pixel bits to zero.
| image | Image object. |
Gets the memory allocator associated with this object.
Most objects are constructed with an allocator, which is used to allocate the memory required by the object. Objects retain a reference to this allocator to enable further allocations and to free memory when the object is destroyed.
| object | Object. |
Constructs a new object by copying an existing object, including any aggregated child elements.
If the source object is an object collection (e.g. kArrayList<kString>), any aggregated child objects are also cloned. In this case, the kObject_Dispose method can be used to free the cloned collection and its associated elements.
This method will fail if the source object (or an aggregated child element) does not support cloning.
| object | Receives the constructed object. |
| source | Source object. |
| allocator | Memory allocator (or kNULL for default). |
Destroys the object.
The kObject_Destroy method destroys the object itself and any resources that are owned by the object. See Object Destruction for more information.
When an object is destroyed (or disposed), its reference count is decremented. The object is only truly destroyed when the reference count reaches zero. See Reference Counting for more information.
| object | Object (or kNULL). |
Destroys the object and any aggregated child elements.
The kObject_Dispose method destroys the object itself, any resources that are owned by the object, and if the object represents a collection of objects, any child objects in the collection. See Object Destruction for more information.
When an object is destroyed (or disposed), its reference count is decremented. The object is only truly destroyed when the reference count reaches zero. See Reference Counting for more information.
| object | Object (or kNULL). |
Determines whether the object is equal to another object.
By default, objects are compared by reference; objects are considered equal if the given handles refer to the same object instance. However, some classes override the Equals method to provide a more meaningful comparison (e.g. kString).
| object | Object. |
| other | Object for comparison. |
Gets a hash code representing the state of this object.
By default, objects return a hash code based on the object handle value. However, some classes override the HashCode method to provide a more useful hash (e.g. kString).
| object | Object. |
Determines whether this object is an instance of the specified type.
This function compares the type of this object with the given type. An object is considered to be an instance of a given type if a) the type represents a class and this object inherits from (or instantiates) that class, or b) the type represents an interface and this object implements the interface.
| object | Object. |
| type | Type. |
Reports whether the object is currently shared (reference count greater than one).
Objects are initialized with a reference count of one. The kObject_Share method can be used to increment the reference count. The kObject_Destroy and kObject_Dispose methods decrease the reference count, and when the reference count reaches zero, the object is actually destroyed/disposed.
This method can be used to determine if the reference count of an object is currently greater than one.
This method is thread-safe.
| object | Object. |
|
inherited |
Sets the object pool associated with this object.
Object pools can be used to implement custom lifecycle management. If an object has an assigned pool, then the kObjectPool_Reclaim method will be called just prior to destruction, to provide an opportunity for the object to be reclaimed.
| object | Object. |
| pool | Pool object (or kNULL to clear the pool assignment). |
Increments the reference count associated with this object.
This method is thread-safe.
| object | Object. |
Estimates the memory consumed by this object, including any aggregated child elements.
This method can be optionally overridden by kObject-derived classes to report the amount of memory consumed by an object. The default implementation reports only the size of the class instance (additional allocations performed by the class are excluded).
| object | Object. |
Returns the type of the object.
Each object is an instance of a specific class type. The type handle returned by this function can be used to learn about the class.
| object | Object. |