# FixImage Documentation

Back to summary

## C API

### Types

`typedef void (*ImageFreeFunc)(void *data);`
  Used for freeing both the pixels (must be referenced in the user data) and the user data associated with the image.
`typedef void (*MulticoreFunc)(int from, int to, void *data);`
  Used for running the code on multiple cores.

### Functions

`Value fiximage_create_from_pixels(Heap *heap, int width, int height, int stride, uint32_t *pixels, ImageFreeFunc free_func, void *user_data, int type);`
  Creates a new image from given pixels. You must deallocate the pixels and the user data in case of a failure. Use -1 as a type if you don't need custom types.
`Value fiximage_create_painter(Heap *heap, Value img, int offset_x, int offset_y);`
  Creates a new painter for given image.
`int fiximage_get_data(Heap *heap, Value img, int *width, int *height, int *stride, uint32_t **pixels, void **user_data, int *type);`
  Returns the data for given image. All output parameters are optional.
`int fiximage_get_painter_data(Heap *heap, Value p, float *tr, int *clip, Value *image);`
  Returns the data for given painter. All output parameters are optional.
`void fiximage_register_functions(Heap *heap);`
  Registers image functions to given heap.
`int fiximage_get_core_count();`
  Returns the number of CPU cores.
`void fiximage_multicore_run(int from, int to, int min_iters, MulticoreFunc func, void *data);`
  Runs the code on multiple CPU cores.