Source

watches / lunar / image.h

#ifndef _image_h_
#define _image_h_
/** \file
 * Image drawing routines
 */

#include "resources.h"
#include "spiflash.h"
#include "pulse_os.h"
#include "pulse_types.h"


static inline void
image_resource(
	PulseResource id,
	image_resource_t * const resource
)
{
	spiflash_read(
		SPIFLASH_BASE + id * sizeof(*resource),
		resource,
		sizeof(*resource)
	);
}


/** Return the absolute address of the image in the flash */
static inline uint32_t
image_offset(
	PulseResource id
)
{
	image_resource_t resource;
	image_resource(id, &resource);
	return resource.offset;
}


/** Draw a grayscale image that is packed into an RGB bitmap. */
extern void
image_draw_gray(
	PulseResource id,
	int32_t x,
	int32_t y
);


#endif