BSB Developer Docs
Loading...
Searching...
No Matches
image.h File Reference

A widget that displays a static image. More...

#include <gui/widget.h>

Go to the source code of this file.

Typedefs

typedef struct Image Image
 Image opaque structure.
 

Enumerations

enum  ImageColorFormat {
  ImageColorFormatL8 , ImageColorFormatLA88 , ImageColorFormatBGR888 , ImageColorFormatBGRA8888 ,
  ImageColorFormatsCount
}
 Pixel format of raw image data passed to image_set_source_raw(). More...
 

Functions

Image * image_alloc (Widget *parent)
 Create a new Image instance.
 
void image_free (Image *instance)
 Delete an Image instance.
 
Widget * image_get_base (Image *instance)
 Get a pointer to the base class instance.
 
bool image_set_source (Image *instance, const char *file_path)
 Load and show an image from a file.
 
bool image_set_source_no_cache (Image *instance, const char *file_path)
 Load and show an image from a file with invalidating previously cached one.
 
void image_set_source_raw (Image *instance, ImageColorFormat format, size_t width, size_t height, const void *data, size_t data_size)
 Show an image from a raw pixel buffer.
 
void image_set_opacity (Image *instance, uint8_t opacity)
 Set the opacity of an Image instance.
 

Detailed Description

A widget that displays a static image.

Enumeration Type Documentation

◆ ImageColorFormat

Pixel format of raw image data passed to image_set_source_raw().

Enumerator
ImageColorFormatL8 

1 byte per pixel: luma.

ImageColorFormatLA88 

2 bytes per pixel: luma, alpha.

ImageColorFormatBGR888 

3 bytes per pixel: B, G, R.

ImageColorFormatBGRA8888 

4 bytes per pixel: B, G, R, A.

Function Documentation

◆ image_alloc()

Image * image_alloc ( Widget * parent)

Create a new Image instance.

Parameters
[in,out]parentpointer to the parent Widget instance
Returns
pointer to the newly created Image instance

◆ image_free()

void image_free ( Image * instance)

Delete an Image instance.

Parameters
[in,out]instancepointer to the Image instance to be deleted

◆ image_get_base()

Widget * image_get_base ( Image * instance)

Get a pointer to the base class instance.

The return value can be used in all Widget methods.

Parameters
[in,out]instancepointer to the Image instance to be queried
Returns
pointer to the base class instance

◆ image_set_opacity()

void image_set_opacity ( Image * instance,
uint8_t opacity )

Set the opacity of an Image instance.

Parameters
[in,out]instancepointer to the Image instance to be modified
[in]opacitynew opacity value (0-255)

◆ image_set_source()

bool image_set_source ( Image * instance,
const char * file_path )

Load and show an image from a file.

Parameters
[in,out]instancepointer to the Image instance to be modified
[in]file_pathzero-terminated string containing the full path to image file
Returns
true if the source was successfully set, false otherwise

◆ image_set_source_no_cache()

bool image_set_source_no_cache ( Image * instance,
const char * file_path )

Load and show an image from a file with invalidating previously cached one.

Parameters
[in,out]instancepointer to the Image instance to be modified
[in]file_pathzero-terminated string containing the full path to image file
Returns
true if the source was successfully set, false otherwise

◆ image_set_source_raw()

void image_set_source_raw ( Image * instance,
ImageColorFormat format,
size_t width,
size_t height,
const void * data,
size_t data_size )

Show an image from a raw pixel buffer.

The data is copied internally; the caller's buffer does not need to outlive the call. Switching to a file source by image_set_source() or calling this function again frees the previous buffer automatically.

Parameters
[in,out]instancepointer to the Image instance to be modified
[in]formatpixel format of the data
[in]widthimage width in pixels
[in]heightimage height in pixels
[in]dataraw pixel data of size data_size
[in]data_sizeraw pixel data size