Zen API

- Home
- Topics
- Types
- Files

All Classes Files Functions Variables Typedefs Friends Macros Modules Pages
kImage.h
Go to the documentation of this file.
1
10 #ifndef K_API_IMAGE_H
11 #define K_API_IMAGE_H
12
13 #include <kApi/kApiDef.h>
14 #include <kApi/Data/kImage.x.h>
15
55 //typedef kObject kImage; --forward-declared in kApiDef.x.h
56
68 kFx(kStatus) kImage_Construct(kImage* image, kType pixelType, kSize width, kSize height, kAlloc allocator);
69
82 kFx(kStatus) kImage_ConstructEx(kImage* image, kType pixelType, kSize width, kSize height, kAlloc allocator, kAlloc dataAllocator);
83
95 kFx(kStatus) kImage_Import(kImage* image, const kChar* fileName, kAlloc allocator);
96
107 kFx(kStatus) kImage_Export(kImage image, const kChar* fileName);
108
119 kFx(kStatus) kImage_Allocate(kImage image, kType pixelType, kSize width, kSize height);
120
135 kFx(kStatus) kImage_Attach(kImage image, void* pixels, kType pixelType, kSize width, kSize height, kSize stride);
136
154 #define kImage_AttachT(kImage_image, TPtr_pixels, kType_pixelType, kSize_width, kSize_height, kSize_stride) \
155 xkImage_AttachT(kImage_image, TPtr_pixels, kType_pixelType, kSize_width, kSize_height, kSize_stride, sizeof(*TPtr_pixels))
156
165 kFx(kStatus) kImage_Assign(kImage image, kImage source);
166
174 kFx(kStatus) kImage_Zero(kImage image);
175
184 kInlineFx(kStatus) kImage_SetPixelFormat(kImage image, kPixelFormat format)
185 {
186 kObj(kImage, image);
187
188 obj->format = format;
189
190 return kOK;
191 }
192
200 kInlineFx(kPixelFormat) kImage_PixelFormat(kImage image)
201 {
202 kObj(kImage, image);
203
204 return obj->format;
205 }
206
215 kInlineFx(kStatus) kImage_SetCfa(kImage image, kCfa cfa)
216 {
217 kObj(kImage, image);
218
219 obj->cfa = cfa;
220
221 return kOK;
222 }
223
231 kInlineFx(kCfa) kImage_Cfa(kImage image)
232 {
233 kObj(kImage, image);
234
235 return obj->cfa;
236 }
237
251 kFx(kStatus) kImage_SetPixel(kImage image, kSize x, kSize y, const void* pixel);
252
269 #define kImage_SetPixelT(kImage_image, kSize_x, kSize_y, TPtr_pixel) \
270 xkImage_SetPixelT(kImage_image, kSize_x, kSize_y, TPtr_pixel, sizeof(*TPtr_pixel))
271
285 kFx(kStatus) kImage_Pixel(kImage image, kSize x, kSize y, void* pixel);
286
303 #define kImage_PixelT(kImage_image, kSize_x, kSize_y, TPtr_pixel) \
304 xkImage_PixelT(kImage_image, kSize_x, kSize_y, TPtr_pixel, sizeof(*TPtr_pixel))
305
321 #define kImage_SetAsT(kImage_image, kSize_x, kSize_y, T_value, T) \
322 (kPointer_WriteAs(xkImage_AsT(kImage_image, kSize_x, kSize_y, sizeof(T)), T_value, T), (void)0)
323
338 #define kImage_AsT(kImage_image, kSize_x, kSize_y, T) \
339 kPointer_ReadAs(xkImage_AsT(kImage_image, kSize_x, kSize_y, sizeof(T)), T)
340
348 kInlineFx(void*) kImage_Data(kImage image)
349 {
350 kObj(kImage, image);
351
352 return obj->pixels;
353 }
354
366 #define kImage_DataT(kImage_image, T) \
367 kCast(T*, xkImage_DataT(kImage_image, sizeof(T)))
368
380 kInlineFx(void*) kImage_DataAt(kImage image, kSSize x, kSSize y)
381 {
382 kObj(kImage, image);
383 kSSize byteOffset = y*(kSSize)obj->stride + x*(kSSize)obj->pixelSize;
384
385 return kPointer_ByteOffset(obj->pixels, byteOffset);
386 }
387
403 #define kImage_DataAtT(kImage_image, kSSize_x, kSSize_y, T) \
404 kCast(T*, xkImage_DataAtT(kImage_image, kSSize_x, kSSize_y, sizeof(T)))
405
413 kInlineFx(kSize) kImage_DataSize(kImage image)
414 {
415 kObj(kImage, image);
416
417 return obj->height * obj->stride;
418 }
419
432 kInlineFx(void*) kImage_At(kImage image, kSize x, kSize y)
433 {
434 # if !defined(K_FSS_912_DISABLE_BOUNDS_CHECK)
435 {
436 kAssert(x < kImage_Width(image));
437 kAssert(y < kImage_Height(image));
438 }
439 # endif
440
441 return kImage_DataAt(image, (kSSize)x, (kSSize)y);
442 }
443
458 #define kImage_AtT(kImage_image, kSize_x, kSize_y, T) \
459 kCast(T*, xkImage_AtT(kImage_image, kSize_x, kSize_y, sizeof(T)))
460
472 kInlineFx(void*) kImage_RowAt(kImage image, kSize y)
473 {
474 # if !defined(K_FSS_912_DISABLE_BOUNDS_CHECK)
475 {
476 kAssert(y < kImage_Height(image));
477 }
478 # endif
479
480 return kImage_DataAt(image, (kSSize)0, (kSSize)y);
481 }
482
496 #define kImage_RowAtT(kImage_image, kSize_y, T) \
497 kCast(T*, xkImage_RowAtT(kImage_image, kSize_y, sizeof(T)))
498
506 kInlineFx(kType) kImage_PixelType(kImage image)
507 {
508 kObj(kImage, image);
509
510 return obj->pixelType;
511 }
512
520 kInlineFx(kSize) kImage_PixelSize(kImage image)
521 {
522 kObj(kImage, image);
523
524 return obj->pixelSize;
525 }
526
534 kInlineFx(kSize) kImage_Width(kImage image)
535 {
536 kObj(kImage, image);
537
538 return obj->width;
539 }
540
548 kInlineFx(kSize) kImage_Height(kImage image)
549 {
550 kObj(kImage, image);
551
552 return obj->height;
553 }
554
564 kInlineFx(kSize) kImage_Area(kImage image)
565 {
566 kObj(kImage, image);
567
568 return obj->width * obj->height;
569 }
570
578 kInlineFx(kSize) kImage_Stride(kImage image)
579 {
580 kObj(kImage, image);
581
582 return obj->stride;
583 }
584
592 kInlineFx(kAlloc) kImage_DataAlloc(kImage image)
593 {
594 kObj(kImage, image);
595
596 return obj->dataAlloc;
597 }
598
599 #endif
kImage::kImage_Assign
kStatus kImage_Assign(kImage image, kImage source)
Copies a given source image into this image.
kImage::kImage_SetPixel
kStatus kImage_SetPixel(kImage image, kSize x, kSize y, const void *pixel)
Sets the value of a pixel.
kImage::kImage_Pixel
kStatus kImage_Pixel(kImage image, kSize x, kSize y, void *pixel)
Gets the value of a pixel.
kImage::kImage_RowAt
void * kImage_RowAt(kImage image, kSize y)
Returns a pointer to the specified row in the pixel buffer.
Definition: kImage.h:472
kImage::kImage_PixelFormat
kPixelFormat kImage_PixelFormat(kImage image)
Gets the optional pixel format descriptor associated with this image.
Definition: kImage.h:200
kImage::kImage_DataAlloc
kAlloc kImage_DataAlloc(kImage image)
Reports the data allocator that was optionally provided at construction time.
Definition: kImage.h:592
kImage::kImage_Data
void * kImage_Data(kImage image)
Returns a pointer to the first row in the pixel buffer.
Definition: kImage.h:348
kImage::kImage_Area
kSize kImage_Area(kImage image)
Returns the area of the image, in pixels.
Definition: kImage.h:564
kImage::kImage_PixelSize
kSize kImage_PixelSize(kImage image)
Returns the pixel size.
Definition: kImage.h:520
kSize
Represents an unsigned integer that can store a pointer address.
kAlloc
Abstract base class for memory allocator types.
kImage::kImage_Construct
kStatus kImage_Construct(kImage *image, kType pixelType, kSize width, kSize height, kAlloc allocator)
Constructs a kImage object.
kInlineFx
#define kInlineFx(TYPE)
Inline method declaration helper.
Definition: kApiDef.h:26
kImage::kImage_DataAt
void * kImage_DataAt(kImage image, kSSize x, kSSize y)
Calculates an address relative to the start of the pixel buffer.
Definition: kImage.h:380
kChar
Represents a single unit (byte) in a UTF-8 character.
kImage::kImage_Import
kStatus kImage_Import(kImage *image, const kChar *fileName, kAlloc allocator)
Loads an image from file.
kImage::kImage_Export
kStatus kImage_Export(kImage image, const kChar *fileName)
Saves an image to file.
kImage::kImage_DataSize
kSize kImage_DataSize(kImage image)
Reports the size, in bytes, of the pixel buffer.
Definition: kImage.h:413
kSSize
Represents a signed integer that can store a pointer address.
kImage::kImage_At
void * kImage_At(kImage image, kSize x, kSize y)
Returns a pointer to the specified pixel in the pixel buffer.
Definition: kImage.h:432
kPixelFormat
Pixel format descriptor.
kImage::kImage_Attach
kStatus kImage_Attach(kImage image, void *pixels, kType pixelType, kSize width, kSize height, kSize stride)
Attaches the image to an external pixel buffer.
kImage::kImage_ConstructEx
kStatus kImage_ConstructEx(kImage *image, kType pixelType, kSize width, kSize height, kAlloc allocator, kAlloc dataAllocator)
Constructs a kImage object using a separate allocator for image array memory.
kImage::kImage_SetCfa
kStatus kImage_SetCfa(kImage image, kCfa cfa)
Sets the color filter array type associated with this image.
Definition: kImage.h:215
kObj
#define kObj(TypeName_T, T_object)
Declares a local "obj" (this-pointer) variable and initializes it from a type-checked object handle...
Definition: kApiDef.h:2923
kApiDef.h
Core Zen type declarations.
kPointer::kPointer_ByteOffset
void * kPointer_ByteOffset(const void *pointer, kSSize offset)
Calculates a pointer address from a base address and a byte offset.
Definition: kApiDef.h:280
kImage::kImage_PixelType
kType kImage_PixelType(kImage image)
Returns the pixel type.
Definition: kImage.h:506
kImage::kImage_Allocate
kStatus kImage_Allocate(kImage image, kType pixelType, kSize width, kSize height)
Reallocates the internal pixel buffer.
kImage::kImage_Width
kSize kImage_Width(kImage image)
Returns the width of the image, in pixels.
Definition: kImage.h:534
kType
Represents metadata about a type (class, interface, or value).
kAssert
#define kAssert(EXPRESSION)
Aborts execution if EXPRESSION is kFALSE.
Definition: kApiDef.h:751
kImage
Represents a 2D collection of pixels.
kStatus::kOK
#define kOK
Operation successful.
Definition: kApiDef.h:515
kImage::kImage_Cfa
kCfa kImage_Cfa(kImage image)
Gets the color filter array type associated with this image.
Definition: kImage.h:231
kStatus
Represents an error code.
kImage::kImage_Height
kSize kImage_Height(kImage image)
Returns the height of the image, in pixels.
Definition: kImage.h:548
kCfa
Image color filter array type.
kImage::kImage_Zero
kStatus kImage_Zero(kImage image)
Sets all pixel bits to zero.
kImage::kImage_SetPixelFormat
kStatus kImage_SetPixelFormat(kImage image, kPixelFormat format)
Sets the optional pixel format descriptor associated with this image.
Definition: kImage.h:184
kImage::kImage_Stride
kSize kImage_Stride(kImage image)
Returns the size of an image row, including alignment padding bytes, in bytes.
Definition: kImage.h:578