LibGd 2.4.0-dev
GD Graphics library
Loading...
Searching...
No Matches
Data Structures | Enumerations | Functions

QOI image reading and writing support. More...

Collaboration diagram for QOI:

Data Structures

struct  gdQoiInfo
 Information read from a QOI data. More...
 
struct  gdQoiWriteOptions
 Options for writing QOI data. More...
 

Enumerations

enum  { GD_QOI_SRGB = 0 , GD_QOI_LINEAR = 1 }
 QOI colorspace flags written to the QOI header. More...
 

Functions

gdImagePtr gdImageCreateFromQoi (FILE *fd)
 Create an image from a QOI stdio file.
 
gdImagePtr gdImageCreateFromQoiCtx (gdIOCtxPtr in)
 Create an image from QOI data read through a gdIOCtx.
 
gdImagePtr gdImageCreateFromQoiPtr (int size, void *data)
 Create an image from a QOI memory buffer.
 
void gdQoiInfoInit (gdQoiInfo *info)
 Initialize a gdQoiInfo structure to default values.
 
int gdQoiGetInfo (FILE *infile, gdQoiInfo *info)
 Read QOI header information from a stdio file.
 
int gdQoiGetInfoCtx (gdIOCtxPtr infile, gdQoiInfo *info)
 Read QOI header information from a gdIOCtx.
 
int gdQoiGetInfoPtr (int size, const void *data, gdQoiInfo *info)
 Read QOI header information from a memory buffer.
 
void gdQoiWriteOptionsInit (gdQoiWriteOptions *options)
 Initialize a gdQoiWriteOptions structure to default values.
 
int gdImageQoiWithOptions (gdImagePtr im, FILE *out, const gdQoiWriteOptions *options)
 Write an image as QOI data to a stdio file with options.
 
int gdImageQoiCtxWithOptions (gdImagePtr im, gdIOCtxPtr out, const gdQoiWriteOptions *options)
 Write an image as QOI data to a gdIOCtx with options.
 
void * gdImageQoiPtrWithOptions (gdImagePtr im, int *size, const gdQoiWriteOptions *options)
 Write an image as QOI data to a newly allocated memory buffer with options.
 
void * gdImageQoiPtr (gdImagePtr im, int *size)
 Write an image as QOI data to a newly allocated memory buffer.
 
void * gdImageQoiPtrEx (gdImagePtr im, int *size, int colorspace)
 Write an image as QOI data to a memory buffer with an explicit colorspace flag.
 
void gdImageQoi (gdImagePtr im, FILE *out)
 Write an image as QOI data to a memory buffer.
 
void gdImageQoiCtx (gdImagePtr im, gdIOCtxPtr out)
 Write an image as QOI data to a gdIOCtx.
 
void gdImageQoiEx (gdImagePtr im, FILE *out, int colorspace)
 Write an image as QOI data to a stdio file with an explicit colorspace flag.
 
void gdImageQoiCtxEx (gdImagePtr im, gdIOCtxPtr out, int colorspace)
 Write an image as QOI data to a gdIOCtx with an explicit colorspace flag.
 

Detailed Description

QOI image reading and writing support.

QOI support reads images as truecolor RGBA gd images with alpha saving enabled. QOI output writes RGBA data for both truecolor and palette images; palette images are expanded through their color table. The colorspace value controls the QOI header colorspace flag and does not transform pixel data.

gdImagePtr im;
int black, white;
FILE *out;
im = gdImageCreateTrueColor(100, 100);
if (im == NULL) {
fprintf(stderr, "Unable to create image\n");
exit(1);
}
white = gdTrueColor(255, 255, 255);
black = gdTrueColor(0, 0, 0);
gdImageFilledRectangle(im, 0, 0, 99, 99, white);
gdImageRectangle(im, 0, 0, 99, 99, black);
out = fopen("rect.qoi", "wb");
if (out == NULL) {
fprintf(stderr, "Unable to open output file\n");
gdImageDestroy(im);
exit(1);
}
gdImageQoi(im, out);
fclose(out);
gdImageDestroy(im);
void gdImageRectangle(gdImagePtr im, int x1, int y1, int x2, int y2, int color)
Draws a rectangle.
Definition gd.c:2239
void gdImageFilledRectangle(gdImagePtr im, int x1, int y1, int x2, int y2, int color)
Draws a filled rectangle.
Definition gd.c:2403
void gdImageQoi(gdImagePtr im, FILE *out)
Write an image as QOI data to a memory buffer.
Definition gd_qoi.c:358
Write an image as JPEG data to a gdIOCtx.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum

QOI colorspace flags written to the QOI header.

Enumerator
GD_QOI_SRGB 

Pixel data is encoded with sRGB transfer characteristics.

GD_QOI_LINEAR 

Pixel data is encoded with linear transfer characteristics.

Function Documentation

◆ gdImageCreateFromQoi()

gdImagePtr gdImageCreateFromQoi ( FILE *  fd)

Create an image from a QOI stdio file.

Parameters
fdPointer to the input FILE stream.
Returns
Returns a gdImagePtr on success, or NULL on failure.

◆ gdImageCreateFromQoiCtx()

gdImagePtr gdImageCreateFromQoiCtx ( gdIOCtxPtr  in)

Create an image from QOI data read through a gdIOCtx.

Parameters
inPointer to the gdIOCtx input context.
Returns
Returns a gdImagePtr on success, or NULL on failure.

◆ gdImageCreateFromQoiPtr()

gdImagePtr gdImageCreateFromQoiPtr ( int  size,
void *  data 
)

Create an image from a QOI memory buffer.

Parameters
sizeSize of the QOI memory buffer in bytes.
dataPointer to the QOI memory buffer.
Returns
Returns a gdImagePtr on success, or NULL on failure.

◆ gdImageQoi()

void gdImageQoi ( gdImagePtr  im,
FILE *  out 
)

Write an image as QOI data to a memory buffer.

Write an image as QOI data to a stdio file with an explicit colorspace flag.

Parameters
imThe image to write.
sizePointer to an integer that receives the returned buffer size.
metadataReserved metadata input parameter; QOI metadata is currently ignored.
Returns
A pointer to the newly allocated QOI data, or NULL on failure.

Write an image as QOI data to a stdio file.

Parameters
imThe image to write.
outThe stdio file to write the QOI data to.
imThe image to write.
outThe stdio file to write the QOI data to.

◆ gdImageQoiCtx()

void gdImageQoiCtx ( gdImagePtr  im,
gdIOCtxPtr  out 
)

Write an image as QOI data to a gdIOCtx.

Write an image as QOI data to a gdIOCtx with an explicit colorspace flag.

Parameters
imThe image to write.
outThe gdIOCtx to write the QOI data to.

◆ gdImageQoiCtxEx()

void gdImageQoiCtxEx ( gdImagePtr  im,
gdIOCtxPtr  out,
int  colorspace 
)

Write an image as QOI data to a gdIOCtx with an explicit colorspace flag.

Parameters
imThe image to write.
outThe gdIOCtx to write the QOI data to.
colorspaceThe QOI colorspace flag, either GD_QOI_SRGB or GD_QOI_LINEAR.

◆ gdImageQoiCtxWithOptions()

int gdImageQoiCtxWithOptions ( gdImagePtr  im,
gdIOCtxPtr  out,
const gdQoiWriteOptions options 
)

Write an image as QOI data to a gdIOCtx with options.

Parameters
imThe image to write.
outThe gdIOCtx to write the QOI data to.
optionsPointer to the gdQoiWriteOptions structure specifying write options.
Returns
Returns 0 on success, or 1 on failure.

◆ gdImageQoiEx()

void gdImageQoiEx ( gdImagePtr  im,
FILE *  out,
int  colorspace 
)

Write an image as QOI data to a stdio file with an explicit colorspace flag.

Parameters
imThe image to write.
outThe stdio file to write the QOI data to.
colorspaceThe QOI colorspace flag, either GD_QOI_SRGB or GD_QOI_LINEAR.

◆ gdImageQoiPtr()

void * gdImageQoiPtr ( gdImagePtr  im,
int *  size 
)

Write an image as QOI data to a newly allocated memory buffer.

Parameters
imThe image to write.
sizePointer to an integer that receives the returned buffer size.
Returns
A pointer to the newly allocated QOI data, or NULL on failure.

◆ gdImageQoiPtrEx()

void * gdImageQoiPtrEx ( gdImagePtr  im,
int *  size,
int  colorspace 
)

Write an image as QOI data to a memory buffer with an explicit colorspace flag.

Parameters
imThe image to write.
sizePointer to an integer that receives the returned buffer size.
colorspaceThe QOI colorspace flag, either GD_QOI_SRGB or GD_QOI_LINEAR.
Returns
A pointer to the newly allocated QOI data, or NULL on failure.

◆ gdImageQoiPtrWithOptions()

void * gdImageQoiPtrWithOptions ( gdImagePtr  im,
int *  size,
const gdQoiWriteOptions options 
)

Write an image as QOI data to a newly allocated memory buffer with options.

Parameters
imThe image to write.
sizePointer to an integer that receives the returned buffer size.
optionsPointer to the gdQoiWriteOptions structure specifying write options.
Returns
A pointer to the newly allocated QOI data, or NULL on failure.

◆ gdImageQoiWithOptions()

int gdImageQoiWithOptions ( gdImagePtr  im,
FILE *  out,
const gdQoiWriteOptions options 
)

Write an image as QOI data to a stdio file with options.

Parameters
imThe image to write.
outThe stdio file to write the QOI data to.
optionsPointer to the gdQoiWriteOptions structure specifying write options.
Returns
Returns 0 on success, or 1 on failure.

◆ gdQoiGetInfo()

int gdQoiGetInfo ( FILE *  infile,
gdQoiInfo info 
)

Read QOI header information from a stdio file.

Parameters
infilePointer to the input FILE stream.
infoPointer to the gdQoiInfo structure to populate.
Returns
Returns 0 on success, or 1 on failure.

◆ gdQoiGetInfoCtx()

int gdQoiGetInfoCtx ( gdIOCtxPtr  infile,
gdQoiInfo info 
)

Read QOI header information from a gdIOCtx.

Parameters
infilePointer to the gdIOCtx input context.
infoPointer to the gdQoiInfo structure to populate.
Returns
Returns 0 on success, or 1 on failure.

◆ gdQoiGetInfoPtr()

int gdQoiGetInfoPtr ( int  size,
const void *  data,
gdQoiInfo info 
)

Read QOI header information from a memory buffer.

Parameters
sizeSize of the QOI memory buffer in bytes.
dataPointer to the QOI memory buffer.
infoPointer to the gdQoiInfo structure to populate.
Returns
Returns 0 on success, or 1 on failure.

◆ gdQoiInfoInit()

void gdQoiInfoInit ( gdQoiInfo info)

Initialize a gdQoiInfo structure to default values.

The default may change in future versions, so it is recommended to call this function before using the structure. Default values update is not considered a breaking change, but it is still recommended to call this function to ensure proper initialization.

Parameters
infoPointer to the gdQoiInfo structure to initialize.

◆ gdQoiWriteOptionsInit()

void gdQoiWriteOptionsInit ( gdQoiWriteOptions options)

Initialize a gdQoiWriteOptions structure to default values.

The default may change in future versions, so it is recommended to call this function before using the structure. Default values update is not considered a breaking change, but it is still recommended to call this function to ensure proper initialization.

Parameters
optionsPointer to the gdQoiWriteOptions structure to initialize.