#ifndef BMP_H_ #define BMP_H_ #include #include #include #include #include #include #include static const unsigned char BMP_SIGNATURE[2] = { 'B', 'M' }; typedef struct { // Raw stream handle ff_stream *raw; uint32_t file_size; // tbh, i actually have no idea why this is needed uint32_t data_offset; uint32_t width; uint32_t height; uint16_t bpp; uint32_t compression; uint32_t image_size; uint32_t x_ppm; // X pixels per meter uint32_t y_ppm; // Y pixels per meter uint32_t colors_used; uint32_t important_colors; uint8_t* palette; uint8_t* pixels; bool valid; ff_result last_error; } ff_bmp_ctx; typedef ff_result (*ff_bmp_section_handler_ptr)(uint8_t *buf, size_t len, ff_bmp_ctx* ctx); typedef struct { // Even though the types in bitmaps are invisible (they don't have labels) // I'll just keep them in for the sake of being in // And I might just handle the section looping a bit differently // And their names will be what I saw in the spec const char* type; ff_bmp_section_handler_ptr handler; } ff_bmp_section_handler; const ff_bmp_section_handler ff_png_chunk_handlers[] = { // TODO: Make handlers {"Header", NULL}, {"InfoHeader", NULL}, {"ColorTable", NULL}, {"RasterData", NULL}, {NULL, NULL} // Terminator }; ff_result ff_bmp_isvalid(ff_stream *stream); ff_result ff_open_bmp(ff_stream *stream, ff_bmp_ctx **out_ctx, ff_flag require_valid); #endif // BMP_H_