Skip to content

Latest commit

 

History

History
42 lines (30 loc) · 1.67 KB

Install Image Decoder.md

File metadata and controls

42 lines (30 loc) · 1.67 KB

How to: install new image decoder

Decoder in repository

ImMedia repository contains the following decoders:

support format
GIFLIB gif
libjpeg-turbo jpeg
libpng png
libwebp webp
qoi qoi
stb bmp, jpg, pic, png, pnm, psd, tga

Install your owne decoder

To install an image decoder for immedia, you need to set up this struct:

struct ImageDecoder
{
    void* (*CreateContextFromFile)(void* f, size_t file_size);
    void* (*CreateContextFromData)(const uint8_t* data, size_t data_size);
    void  (*DeleteContext)(void* context);

    void  (*GetInfo)(void* context, int* width, int* height, PixelFormat* format, int* frame_count);

    bool  (*BeginReadFrame)(void* context, uint8_t** pixels, int* delay);
    void  (*EndReadFrame)(void* context);
};

For the functionality of each method, refer to comments.


Then, install decoder by ImMedia::InstallImageDecoder

ImMedia::InstallImageDecoder("format", your_decoder);