NvDialog 0.10.1
A cross-platform modal dialogs library for C/C++ that uses the native OS theme.
Loading...
Searching...
No Matches
nvdialog_image.h File Reference
#include <stddef.h>
#include <stdint.h>
#include "nvdialog_platform.h"
#include "nvdialog_types.h"

Go to the source code of this file.

Macros

#define __nvdialog_image_h__   1

Typedefs

typedef struct _NvdImage NvdImage
 Data that can be interpeted as an image.

Functions

NVD_API const uint8_t * nvd_image_from_filename (const char *filename, int *width, int *height)
NVD_API NvdImagenvd_create_image (const uint8_t *data, int width, int height)
 Creates an NvdImage from the given buffer (data). Although recommended, it is not necessary to use nvd_image_from_filename since other libraries can also provide RGBA data.
NVD_API void nvd_destroy_image (NvdImage *image)
 Destroys an NvdImage.
NVD_API uint8_t * nvd_image_to_bytes (NvdImage *image)
 Returns the raw image bytes that the given image contains.

Macro Definition Documentation

◆ __nvdialog_image_h__

#define __nvdialog_image_h__   1

Typedef Documentation

◆ NvdImage

typedef struct _NvdImage NvdImage

Data that can be interpeted as an image.

The data format is RGBA for library-wide compatibility across various operating systems. Other formats are supported and automatically converted.

Note
Using image functionality does not require nvd_init, although doing anything useful with the image probably does. This may come in handy if you wish to load images early on and use them later, possibly caching them in memory.
Since
v0.9.0

Function Documentation

◆ nvd_create_image()

NVD_API NvdImage * nvd_create_image ( const uint8_t * data,
int width,
int height )

Creates an NvdImage from the given buffer (data). Although recommended, it is not necessary to use nvd_image_from_filename since other libraries can also provide RGBA data.

Warning
As described in the NvdImage documentation, the pointer provided in data MUST be in RGBA format. Not using nvd_image_from_filename carries the additional burden of ensuring this manually.
Parameters
dataThe data to use as the image
widthThe width of the image
heightThe height of the image
Returns
NvdImage* A pointer to an NvdImage object.

◆ nvd_destroy_image()

NVD_API void nvd_destroy_image ( NvdImage * image)

Destroys an NvdImage.

Parameters
imageThe image to destroy
Since
v0.9.0

◆ nvd_image_from_filename()

NVD_API const uint8_t * nvd_image_from_filename ( const char * filename,
int * width,
int * height )
Parameters
filenameThe path to the file to be loaded. For best compatibility, provide a full path or use NvdFileDialog
widthA pointer to a variable to hold the width of the image
heightA pointer to a variable to hold the height of the image
Since
v0.9.0
Returns
A pointer to dynamically allocated image data. The returned pointer must not be freed manually; Instead use nvd_destroy_image.

◆ nvd_image_to_bytes()

NVD_API uint8_t * nvd_image_to_bytes ( NvdImage * image)

Returns the raw image bytes that the given image contains.

Note
Format, as with every NvdImage, is always RGBA.
Parameters
imageThe image to get the bytes from
Since
v0.10.1