My Project
Loading...
Searching...
No Matches
Classes | Macros | Functions | Variables
image.h File Reference

Image handling functions. More...

#include "result.h"
#include <stdint.h>
#include <stdlib.h>

Go to the source code of this file.

Classes

struct  Image
 RGB image. More...
 

Macros

#define pixel_at(img, x, y)   ((img).pixels + (x) + (y) * (img).width)
 Get pixel at index.
 
#define foreach_pixel(img, expression)
 Execute expression for each pixel.
 

Functions

struct __attribute__ ((packed))
 Pixel with 1-byte color depth.
 
 Maybe (Image)
 
size_t calc_image_size (uint32_t width, uint32_t height)
 Return required size for image pixels data.
 
MaybeImage create_image (uint32_t width, uint32_t height)
 Create image structure with pre-allocated data. If memory cannot be allocated, image pixels are NULL.
 
void destroy_image (Image img)
 Free image data.
 

Variables

 Pixel
 

Detailed Description

Image handling functions.

Macro Definition Documentation

◆ foreach_pixel

#define foreach_pixel (   img,
  expression 
)
Value:
for (uint32_t i = 0; i < (img).width; ++i) { \
for (uint32_t j = 0; j < (img).height; ++j) { \
expression; \
} \
}

Execute expression for each pixel.

Function Documentation

◆ __attribute__()

struct __attribute__ ( (packed)  )

Pixel with 1-byte color depth.

< Red, green, and blue color values.

◆ destroy_image()

void destroy_image ( Image  img)

Free image data.

Parameters
imgImage to be destroyed.