libsxbp  v0.27
Experimental generation of 2D spiralling lines based on input binary data.
Data Structures | Typedefs | Functions
render.h File Reference

This compilation unit provides functions for rendering a spiral to a bitmap. More...

#include <stdbool.h>
#include <stdint.h>
#include "saxbospiral.h"
Include dependency graph for render.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  sxbp_bitmap_t
 Used to represent a basic 1-bit, pure black/white bitmap image. More...
 

Typedefs

typedef struct sxbp_bitmap_t sxbp_bitmap_t
 Used to represent a basic 1-bit, pure black/white bitmap image. More...
 

Functions

sxbp_status_t sxbp_render_spiral_raw (sxbp_spiral_t spiral, sxbp_bitmap_t *image)
 Renders the line of a spiral to a bitmap. More...
 
sxbp_status_t sxbp_render_spiral_image (sxbp_spiral_t spiral, sxbp_buffer_t *buffer, sxbp_status_t(*image_writer_callback)(sxbp_bitmap_t image, sxbp_buffer_t *buffer))
 Renders the line of a spiral to an image format. More...
 

Detailed Description

This compilation unit provides functions for rendering a spiral to a bitmap.

Author
Joshua Saxby <joshua.a.saxby+TNOPLuc8vM==.com
Date
2016, 2017

Typedef Documentation

typedef struct sxbp_bitmap_t sxbp_bitmap_t

Used to represent a basic 1-bit, pure black/white bitmap image.

The image has integer height and width, and a 2-dimensional array of 1-bit pixels which are either black or white.

Function Documentation

sxbp_status_t sxbp_render_spiral_image ( sxbp_spiral_t  spiral,
sxbp_buffer_t *  buffer,
sxbp_status_t(*)(sxbp_bitmap_t image, sxbp_buffer_t *buffer)  image_writer_callback 
)

Renders the line of a spiral to an image format.

The lines of the spiral are plotted on a white background and the pixel data representing the resulting shape is written as data in a given image file format, using the callback function to achieve this conversion. The callback function should inspect the pixels of the bitmap passed to it and write the file data representing the bitmap in it's respective file format out to the buffer.

The function signature of the callback is the same as that of the image rendering functions provided by the library: sxbp_render_backend_pbm and sxbp_render_backend_png. This allows one of these to be provided as the callback function, a convenient use of function chaining can achieve this like so:

1 sxbp_render_spiral_image(spiral, buffer, sxbp_render_backend_pbm);
Parameters
spiralThe spiral which should be rendered.
[out]bufferThe data buffer to which the bytes of the image file should be written.
image_writer_callbackA function pointer with the following signature:
1 sxbp_status_t callback_name(sxbp_bitmap_t image, sxbp_buffer_t* buffer)
Returns
SXBP_OPERATION_OK on success.
Any other valid value of the enumeration sxbp_status_t on error.
Note
Asserts:
  • That spiral.lines is not NULL
  • That buffer->bytes is NULL
  • That the function pointer is not NULL
sxbp_status_t sxbp_render_spiral_raw ( sxbp_spiral_t  spiral,
sxbp_bitmap_t *  image 
)

Renders the line of a spiral to a bitmap.

The lines of the spiral are plotted on a white background and the pixel data representing the resulting shape is written to the given image.

Parameters
spiralThe spiral which should be rendered.
[out]imageThe bitmap to write the pixel data out to.
Returns
SXBP_OPERATION_OK on success.
SXBP_MALLOC_REFUSED on memory allocation failure.
Note
Asserts:
  • That image->pixels is NULL
  • That spiral.lines is not NULL