22#define MFMT_BMPINFO_OFS_WIDTH 4
23#define MFMT_BMPINFO_OFS_HEIGHT 8
24#define MFMT_BMPINFO_OFS_COLOR_PLANES 12
25#define MFMT_BMPINFO_OFS_BPP 14
26#define MFMT_BMPINFO_OFS_COMPRESSION 16
27#define MFMT_BMPINFO_OFS_SZ 20
28#define MFMT_BMPINFO_OFS_HRES 24
29#define MFMT_BMPINFO_OFS_VRES 28
30#define MFMT_BMPINFO_OFS_PAL_SZ 32
31#define MFMT_BMPINFO_OFS_IMP_COLORS 36
34#define MFMT_BMP_COMPRESSION_NONE (0)
36#define MFMT_BMP_COMPRESSION_RLE8 (1)
38#define MFMT_BMP_COMPRESSION_RLE4 (2)
42#define MFMT_DECOMP_FLAG_4BIT 0x01
43#define MFMT_DECOMP_FLAG_8BIT 0x02
45#define MFMT_PX_FLAG_INVERT_Y 0x01
52#define MFMT_PX_FLAG_NEW_LINE 0x02
54#ifndef MFMT_TRACE_BMP_LVL
55# define MFMT_TRACE_BMP_LVL 0
58#ifndef MFMT_TRACE_RLE_LVL
59# define MFMT_TRACE_RLE_LVL 0
79#define mfmt_bmp_check_header() \
80 debug_printf( MFMT_TRACE_BMP_LVL, \
81 "bmp file sz: " U32_FMT ", magic: %c%c", \
82 header->sz, (((char*)header)[0]), (((char*)header)[1]) ); \
83 if( 40 == header->sz ) { \
84 debug_printf( MFMT_TRACE_BMP_LVL, "bmp info header detected by sz" ); \
85 header_bmp_info = (struct MFMT_STRUCT_BMPINFO*)header; \
87 'B' == (((char*)header)[0]) && 'M' == (((char*)header)[1]) \
89 debug_printf( MFMT_TRACE_BMP_LVL, "bmp file header detected by sig" ); \
90 header_bmp_file = (struct MFMT_STRUCT_BMPFILE*)header; \
91 header_bmp_info = &(header_bmp_file->info); \
93 error_printf( "unable to select read header!" ); \
94 retval = MERROR_FILE; \
155 mfile_t* p_file_in, off_t file_offset, off_t file_sz,
size_t line_w,
156 MAUG_MHANDLE buffer_out, off_t buffer_out_sz, uint8_t flags );
163 uint32_t file_offset, off_t file_sz, uint8_t* p_flags );
169 struct MFMT_STRUCT* header, uint32_t* palette,
size_t palette_sz,
170 mfile_t* p_file_in, uint32_t file_offset, off_t file_sz,
177 struct MFMT_STRUCT* header, uint8_t SEG_FAR* px, off_t px_sz,
178 mfile_t* p_file_in, uint32_t file_offset, off_t file_sz,
186 void* data, uint8_t px, int32_t x, int32_t y,
187 void* header_info, uint8_t flags );
193 mfile_t* p_file_in, off_t file_offset, off_t file_sz,
size_t line_w,
194 MAUG_MHANDLE buffer_out, off_t buffer_out_sz, uint8_t flags );
198 off_t file_offset, off_t file_sz, uint8_t* p_flags );
201 struct MFMT_STRUCT* header, uint32_t* palette,
size_t palette_sz,
202 mfile_t* p_file_in, uint32_t file_offset, off_t file_sz,
211 size_t px_offset, MAUG_MHANDLE* p_px_h );
218 mfile_t* p_file_in, uint32_t px_offset, off_t file_sz, uint8_t flags,
225 struct MFMT_STRUCT* header, uint8_t SEG_FAR* px, off_t px_sz,
226 mfile_t* p_file_in, uint32_t file_offset, off_t file_sz,
232 mfile_t* p_file_in, off_t file_offset, off_t file_sz,
size_t line_w,
233 MAUG_MHANDLE buffer_out_h, off_t buffer_out_sz, uint8_t flags
236 uint8_t* buffer_out = NULL;
237 off_t in_byte_cur = 0,
239 uint8_t out_mask_cur = 0xf0,
243 unpadded_written = 0,
248 #define MFMT_RLE_DECODE_RUN 0
249 #define MFMT_RLE_DECODE_CHAR 1
250 #define MFMT_RLE_DECODE_ABS_RIGHT 2
251 #define MFMT_RLE_DECODE_ABS_DOWN 3
252 #define MFMT_RLE_DECODE_ESC 4
253 #define MFMT_RLE_DECODE_LITERAL 5
254 #define MFMT_RLE_DECODE_LITERAL_PAD 6
256 assert( flags == MFMT_DECOMP_FLAG_4BIT );
258 #define mfmt_decode_rle_state( new_state ) \
259 debug_printf( MFMT_TRACE_RLE_LVL, "new state: %s", #new_state ); \
260 decode_state = new_state;
262 #define mfmt_decode_rle_check_eol() \
263 if( line_px_written >= line_w ) { \
264 debug_printf( MFMT_TRACE_RLE_LVL, \
265 "EOL: %u px written (between runs)", \
267 mfmt_decode_rle_reset_line(); \
271 #define mfmt_decode_rle_advance_mask() \
272 out_mask_cur >>= 4; \
273 if( 0 == out_mask_cur ) { \
275 if( out_byte_cur > buffer_out_sz ) { \
277 "out byte " OFF_T_FMT " outside of " OFF_T_FMT \
278 " pixel buffer!", out_byte_cur, buffer_out_sz ); \
279 retval = MERROR_OVERFLOW; \
281 } else if( out_byte_cur < buffer_out_sz ) { \
283 buffer_out[out_byte_cur] = 0; \
285 out_mask_cur = 0xf0; \
288 #define mfmt_decode_rle_reset_line() \
289 if( line_w != line_px_written ) { \
291 "line written pixels %u does not match line width " SIZE_T_FMT, \
292 line_px_written, line_w ); \
293 retval = MERROR_OVERFLOW; \
296 line_px_written = 0; \
297 out_mask_cur = 0xf0; \
299 debug_printf( MFMT_TRACE_RLE_LVL, "now on line: %u", lines_out );
301 #define mfmt_decode_rle_inc_line_w( incr ) \
302 line_px_written += incr; \
303 if( line_w < line_px_written ) { \
305 "line byte %u outside of " SIZE_T_FMT \
306 " line width!", line_px_written, line_w ); \
307 retval = MERROR_OVERFLOW; \
311 debug_printf( 1,
"decompressing RLE into temporary buffer..." );
313 maug_mlock( buffer_out_h, buffer_out );
315 maug_mzero( buffer_out, buffer_out_sz );
318 retval = p_file_in->seek( p_file_in, file_offset + in_byte_cur++ );
319 maug_cleanup_if_not_ok();
320 retval = p_file_in->read_byte( p_file_in, &byte_buffer );
321 maug_cleanup_if_not_ok();
323 debug_printf( MFMT_TRACE_RLE_LVL,
"in byte " OFF_T_FMT
324 ": 0x%02x, out byte " OFF_T_FMT
", line px: %u",
325 in_byte_cur, byte_buffer, out_byte_cur, line_px_written );
327 switch( byte_buffer ) {
329 if( MFMT_RLE_DECODE_RUN == decode_state ) {
330 mfmt_decode_rle_state( MFMT_RLE_DECODE_ESC );
333 }
else if( MFMT_RLE_DECODE_LITERAL_PAD == decode_state ) {
335 assert( 0 == byte_buffer );
336 mfmt_decode_rle_state( MFMT_RLE_DECODE_RUN );
339 }
else if( MFMT_RLE_DECODE_ESC == decode_state ) {
341 debug_printf( MFMT_TRACE_RLE_LVL,
342 "EOL: %u px written", line_px_written );
343 while( line_px_written < line_w ) {
345 assert( 0 == line_px_written % 2 );
346 buffer_out[out_byte_cur++] = 0x00;
347 mfmt_decode_rle_inc_line_w( 2 );
348 debug_printf( MFMT_TRACE_RLE_LVL,
349 "padded line (%u written)", line_px_written );
351 mfmt_decode_rle_reset_line();
354 mfmt_decode_rle_state( MFMT_RLE_DECODE_RUN );
359 if( MFMT_RLE_DECODE_ESC == decode_state ) {
360 debug_printf( MFMT_TRACE_RLE_LVL,
"EOBM" );
363 while( out_byte_cur < buffer_out_sz ) {
365 assert( 0 == line_px_written % 2 );
366 mfmt_decode_rle_check_eol();
367 buffer_out[out_byte_cur++] = 0x00;
368 mfmt_decode_rle_inc_line_w( 2 );
369 debug_printf( MFMT_TRACE_RLE_LVL,
370 "padded file (%u written)", line_px_written );
373 mfmt_decode_rle_state( MFMT_RLE_DECODE_RUN );
378 if( MFMT_RLE_DECODE_ESC == decode_state ) {
379 debug_printf( MFMT_TRACE_RLE_LVL,
"absolute mode: right" );
382 mfmt_decode_rle_state( MFMT_RLE_DECODE_ABS_RIGHT );
387 switch( decode_state ) {
388 case MFMT_RLE_DECODE_LITERAL:
390 mfmt_decode_rle_check_eol();
393 unpadded_written += 2;
394 mfmt_decode_rle_inc_line_w( 2 );
395 debug_printf( MFMT_TRACE_RLE_LVL,
396 "writing literal: 0x%02x (%u left, unpadded run val: %u)",
397 byte_buffer, run_count, unpadded_written );
398 buffer_out[out_byte_cur++] = byte_buffer;
400 if( 0 == run_count ) {
401 if( 0 != unpadded_written % 4 ) {
404 debug_printf( MFMT_TRACE_RLE_LVL,
405 "unpadded: %u, next is pad byte", unpadded_written );
407 mfmt_decode_rle_state( MFMT_RLE_DECODE_LITERAL_PAD );
411 mfmt_decode_rle_state( MFMT_RLE_DECODE_RUN );
416 case MFMT_RLE_DECODE_ESC:
417 run_count = byte_buffer;
418 unpadded_written = 0;
419 debug_printf( MFMT_TRACE_RLE_LVL,
420 "literal mode: %u nibbles", run_count );
421 assert( 0 == run_count % 2 );
422 mfmt_decode_rle_state( MFMT_RLE_DECODE_LITERAL );
425 case MFMT_RLE_DECODE_ABS_RIGHT:
426 debug_printf( MFMT_TRACE_RLE_LVL,
"absolute mode: up" );
429 mfmt_decode_rle_state( MFMT_RLE_DECODE_ABS_DOWN );
432 case MFMT_RLE_DECODE_RUN:
434 mfmt_decode_rle_check_eol();
436 run_count = byte_buffer;
437 debug_printf( MFMT_TRACE_RLE_LVL,
438 "starting run: %u nibbles", run_count );
439 mfmt_decode_rle_state( MFMT_RLE_DECODE_CHAR );
442 case MFMT_RLE_DECODE_CHAR:
443 assert( 0 != run_count );
444 run_char = byte_buffer;
445 debug_printf( MFMT_TRACE_RLE_LVL,
446 "%u-long run of 0x%02x...", run_count, run_char );
449 debug_printf( MFMT_TRACE_RLE_LVL,
450 "writing 0x%02x & 0x%02x #%u (line px #%u)...",
451 run_char, out_mask_cur, run_count, line_px_written );
452 buffer_out[out_byte_cur] |= (run_char & out_mask_cur);
453 mfmt_decode_rle_advance_mask();
454 mfmt_decode_rle_inc_line_w( 1 );
457 }
while( 0 < run_count );
460 mfmt_decode_rle_state( MFMT_RLE_DECODE_RUN );
466 }
while( in_byte_cur < file_sz );
469 MFMT_TRACE_RLE_LVL,
"wrote " OFF_T_FMT
" bytes (%u lines)",
470 out_byte_cur, lines_out );
474 if( NULL != buffer_out ) {
475 maug_munlock( buffer_out_h, buffer_out );
485 off_t file_offset, off_t file_sz, uint8_t* p_flags
490 uint32_t file_hdr_sz = 0;
491 off_t header_offset = 0;
493 mfmt_bmp_check_header();
495 if( NULL != header_bmp_file ) {
498 debug_printf( MFMT_TRACE_BMP_LVL,
499 "reading bitmap file header at " OFF_T_FMT
" bytes...",
503 retval = p_file_in->seek( p_file_in, file_offset + 2 );
504 maug_cleanup_if_not_ok();
505 retval = p_file_in->read_int( p_file_in,
507 maug_cleanup_if_not_ok();
509 retval = p_file_in->seek( p_file_in, file_offset + 10 );
510 maug_cleanup_if_not_ok();
511 retval = p_file_in->read_int( p_file_in,
513 maug_cleanup_if_not_ok();
515 debug_printf( MFMT_TRACE_BMP_LVL,
516 "bitmap file " U32_FMT
" bytes long, px at "
518 header_bmp_file->file_sz,
519 header_bmp_file->px_offset );
523 retval = p_file_in->seek( p_file_in, file_offset + header_offset );
524 maug_cleanup_if_not_ok();
525 retval = p_file_in->read_int( p_file_in,
527 maug_cleanup_if_not_ok();
528 if( 40 != file_hdr_sz ) {
529 error_printf(
"invalid header size: " U32_FMT, file_hdr_sz );
530 retval = MERROR_FILE;
534 MFMT_TRACE_BMP_LVL,
"bitmap header is " U32_FMT
" bytes",
537 if( 40 > file_sz - (file_offset + header_offset) ) {
539 "bitmap header overflow! (only " OFF_T_FMT
" bytes remain!)",
540 file_sz - (file_offset + header_offset) );
541 retval = MERROR_OVERFLOW;
546 retval = p_file_in->seek( p_file_in,
547 file_offset + header_offset + MFMT_BMPINFO_OFS_WIDTH );
548 maug_cleanup_if_not_ok();
549 retval = p_file_in->read_int( p_file_in,
551 maug_cleanup_if_not_ok();
553 retval = p_file_in->seek( p_file_in,
554 file_offset + header_offset + MFMT_BMPINFO_OFS_HEIGHT );
555 maug_cleanup_if_not_ok();
556 retval = p_file_in->read_int( p_file_in,
558 maug_cleanup_if_not_ok();
560 if( 0 > header_bmp_info->
height ) {
562 MFMT_TRACE_BMP_LVL,
"bitmap Y coordinate is inverted..." );
563 *p_flags |= MFMT_PX_FLAG_INVERT_Y;
566 retval = p_file_in->seek( p_file_in,
567 file_offset + header_offset + MFMT_BMPINFO_OFS_SZ );
568 maug_cleanup_if_not_ok();
569 retval = p_file_in->read_int( p_file_in,
571 maug_cleanup_if_not_ok();
574 retval = p_file_in->seek( p_file_in,
575 file_offset + header_offset + MFMT_BMPINFO_OFS_BPP );
576 maug_cleanup_if_not_ok();
577 retval = p_file_in->read_int( p_file_in,
579 maug_cleanup_if_not_ok();
581 if( 8 < header_bmp_info->
bpp ) {
582 error_printf(
"invalid bitmap bpp: %u",
583 header_bmp_info->
bpp );
584 retval = MERROR_FILE;
589 retval = p_file_in->seek( p_file_in,
590 file_offset + header_offset + MFMT_BMPINFO_OFS_COMPRESSION );
591 maug_cleanup_if_not_ok();
592 retval = p_file_in->read_int( p_file_in,
594 maug_cleanup_if_not_ok();
602 error_printf(
"invalid bitmap compression: " U32_FMT,
604 retval = MERROR_FILE;
610 retval = p_file_in->seek( p_file_in,
611 file_offset + header_offset + MFMT_BMPINFO_OFS_PAL_SZ );
612 maug_cleanup_if_not_ok();
613 retval = p_file_in->read_int( p_file_in,
615 maug_cleanup_if_not_ok();
617 debug_printf( 2,
"bitmap is " S32_FMT
" x " S32_FMT
618 ", %u bpp (palette has " U32_FMT
" colors)",
619 header_bmp_info->
width,
621 header_bmp_info->
bpp,
632 struct MFMT_STRUCT* header, uint32_t* palette,
size_t palette_sz,
633 mfile_t* p_file_in, uint32_t file_offset, off_t file_sz, uint8_t flags
640 mfmt_bmp_check_header();
642 retval = p_file_in->seek( p_file_in, file_offset );
643 maug_cleanup_if_not_ok();
645 if( i * 4 > palette_sz ) {
646 error_printf(
"palette overflow!" );
647 retval = MERROR_OVERFLOW;
651 retval = p_file_in->read_int( p_file_in,
653 maug_cleanup_if_not_ok();
655 debug_printf( MFMT_TRACE_BMP_LVL,
656 "set palette entry " OFF_T_FMT
" to " X32_FMT,
669 size_t px_offset, MAUG_MHANDLE* p_px_h
675 if( 0 == header_bmp_info->
height ) {
676 error_printf(
"bitmap height is 0!" );
677 retval = MERROR_FILE;
681 if( 0 == header_bmp_info->
width ) {
682 error_printf(
"bitmap width is 0!" );
683 retval = MERROR_FILE;
687 if( 0 == header_bmp_info->
bpp ) {
688 error_printf(
"bitmap BPP is 0!" );
689 retval = MERROR_FILE;
693 if( 8 < header_bmp_info->
bpp ) {
694 error_printf(
">8BPP bitmaps not supported!" );
695 retval = MERROR_FILE;
702 debug_printf( 1,
"allocating decompression buffer..." );
705 *p_px_h = maug_malloc(
706 header_bmp_info->
width,
707 header_bmp_info->
height );
708 maug_cleanup_if_null_alloc( MAUG_MHANDLE, *p_px_h );
711 p_bmp_in, px_offset, header_bmp_info->
img_sz,
712 header_bmp_info->
width,
715 MFMT_DECOMP_FLAG_4BIT );
716 maug_cleanup_if_not_ok();
728 mfile_t* p_file_in, uint32_t px_offset, off_t file_sz, uint8_t flags,
740 uint8_t byte_buffer = 0,
743 MAUG_MHANDLE decomp_buffer_h = (MAUG_MHANDLE)NULL;
745 mfile_t *p_file_bmp = p_file_in;
747 mfmt_bmp_check_header();
749 maug_mzero( &file_decomp,
sizeof( mfile_t ) );
752 header_bmp_info, p_file_in, px_offset, &decomp_buffer_h );
753 maug_cleanup_if_not_ok();
755 if( (MAUG_MHANDLE)NULL != decomp_buffer_h ) {
760 maug_cleanup_if_not_ok();
763 p_file_bmp = &file_decomp;
767 width_mod_4 = header_bmp_info->
width % 4;
768 maug_cleanup_if_ne( (int32_t)0, width_mod_4, S32_FMT, MERROR_GUI );
770 y = header_bmp_info->
height - 1;
773 maug_cleanup_if_not_ok();
774 if( p_file_bmp == p_file_in ) {
778 p_file_bmp->seek( p_file_bmp, px_offset );
784 debug_printf( MFMT_TRACE_BMP_LVL,
785 "byte in: " OFF_T_FMT
" (" OFF_T_FMT
786 "), bit " OFF_T_FMT
", y: " U32_FMT
", x: " U32_FMT
")",
787 byte_in_idx, file_sz, bit_idx, y, x );
791 if( byte_in_idx >= file_sz ) {
794 "input bitmap has insufficient size " OFF_T_FMT
" bytes)!",
802 retval = p_file_bmp->read_byte( p_file_bmp, &byte_buffer );
803 maug_cleanup_if_not_ok();
811 for( i = 0 ; header_bmp_info->
bpp > i ; i++ ) {
820 pixel_buffer |= byte_buffer & byte_mask;
827 (bit_idx - header_bmp_info->
bpp);
828 debug_printf( MFMT_TRACE_BMP_LVL,
829 "byte_mask: 0x%02x, bit_idx: " OFF_T_FMT
830 ", pixel_buffer: 0x%02x",
831 byte_mask, bit_idx, pixel_buffer );
834 retval = px_cb( px_cb_data, pixel_buffer, x, y, header_bmp_info, flags );
835 maug_cleanup_if_not_ok();
840 byte_mask >>= header_bmp_info->
bpp;
841 bit_idx -= header_bmp_info->
bpp;
845 if( x >= header_bmp_info->
width ) {
849 while( byte_in_idx % 4 != 0 ) {
851 p_file_bmp->seek( p_file_bmp, px_offset + byte_in_idx );
856 px_cb_data, 0, x, y, header_bmp_info,
858 maug_cleanup_if_not_ok();
870 if( (MAUG_MHANDLE)NULL != decomp_buffer_h ) {
871 debug_printf( 1,
"freeing decomp buffer %p...", decomp_buffer_h );
872 maug_mfree( decomp_buffer_h );
881 void* data, uint8_t px, int32_t x, int32_t y,
882 void* header_info, uint8_t flags
890 if( p_out->px_sz < p_out->byte_idx ) {
892 "byte " OFF_T_FMT
" outside of " OFF_T_FMT
893 " pixel buffer!", p_out->byte_idx, p_out->px_sz );
894 retval = MERROR_OVERFLOW;
900 debug_printf( MFMT_TRACE_BMP_LVL,
901 "new row starting at byte_out_idx: " OFF_T_FMT,
904 (MFMT_PX_FLAG_INVERT_Y == (MFMT_PX_FLAG_INVERT_Y & flags) ?
905 ((header_bmp_info->
height - y - 1) *
906 header_bmp_info->
width) :
907 ((y) * header_bmp_info->
width));
910 debug_printf( MFMT_TRACE_BMP_LVL,
911 "writing byte " OFF_T_FMT
" (x: " S32_FMT
913 p_out->byte_idx, x, y );
914 p_out->px[p_out->byte_idx] = px;
926 struct MFMT_STRUCT* header, uint8_t SEG_FAR* px, off_t px_sz,
927 mfile_t* p_file_in, uint32_t px_offset, off_t file_sz, uint8_t flags
937 header, p_file_in, px_offset, file_sz, flags,
938 _mfmt_read_bmp_px_cb_px, &out );
int MERROR_RETVAL
Return type indicating function returns a value from this list.
Definition merror.h:19
#define MFMT_BMP_COMPRESSION_NONE
MFMT_STRUCT_BMPINFO::compression value indicating none.
Definition mfmt.h:34
#define MFMT_BMP_COMPRESSION_RLE4
MFMT_STRUCT_BMPINFO::compression value indicating 4-bit RLE.
Definition mfmt.h:38
MERROR_RETVAL(* mfmt_read_1px_cb)(void *data, uint8_t px, int32_t x, int32_t y, void *header_info, uint8_t flags)
Parameter for mfmt_read_px_cb() functions to process individual pixel data.
Definition mfmt.h:185
MERROR_RETVAL mfmt_read_bmp_px(struct MFMT_STRUCT *header, uint8_t SEG_FAR *px, off_t px_sz, mfile_t *p_file_in, uint32_t file_offset, off_t file_sz, uint8_t flags)
Read mfmt_bitmap pixels into an 8-bit memory bitmap.
MERROR_RETVAL mfmt_get_px_ptr(struct MFMT_STRUCT_BMPINFO *header_bmp_info, mfile_t *p_bmp_in, size_t px_offset, MAUG_MHANDLE *p_px_h)
Read mfmt_bitmap header and return a handle to the bitmap's decompressed pixel data if it is compress...
MERROR_RETVAL(* mfmt_read_header_cb)(struct MFMT_STRUCT *header, mfile_t *p_file_in, uint32_t file_offset, off_t file_sz, uint8_t *p_flags)
Callback to read image header and get properties.
Definition mfmt.h:161
MERROR_RETVAL mfmt_decode_rle(mfile_t *p_file_in, off_t file_offset, off_t file_sz, size_t line_w, MAUG_MHANDLE buffer_out, off_t buffer_out_sz, uint8_t flags)
Decode RLE-encoded data from an input file into a memory buffer.
MERROR_RETVAL(* mfmt_read_px_cb)(struct MFMT_STRUCT *header, uint8_t SEG_FAR *px, off_t px_sz, mfile_t *p_file_in, uint32_t file_offset, off_t file_sz, uint8_t flags)
Callback to read image pixels into 8-bit values.
Definition mfmt.h:176
MERROR_RETVAL(* mfmt_read_palette_cb)(struct MFMT_STRUCT *header, uint32_t *palette, size_t palette_sz, mfile_t *p_file_in, uint32_t file_offset, off_t file_sz, uint8_t flags)
Callback to read image palette into 24-bit RGB values.
Definition mfmt.h:168
MERROR_RETVAL(* mfmt_decode)(mfile_t *p_file_in, off_t file_offset, off_t file_sz, size_t line_w, MAUG_MHANDLE buffer_out, off_t buffer_out_sz, uint8_t flags)
Callback to decode compressed data.
Definition mfmt.h:154
MERROR_RETVAL mfmt_read_bmp_px_cb(struct MFMT_STRUCT *header, mfile_t *p_file_in, uint32_t px_offset, off_t file_sz, uint8_t flags, mfmt_read_1px_cb px_cb, void *px_cb_data)
Read mfmt_bitmap pixels and process them using a callback.
#define MFMT_PX_FLAG_NEW_LINE
Flag for mfmt_read_bmp_px_t() indicating a new line has started.
Definition mfmt.h:52
#define MFILE_READ_FLAG_LSBF
Flag for mfile_read_int_t() indicating integer should always be read least significant byte first.
Definition mfile.h:74
void mfile_close(mfile_t *p_file)
Close a file opened with mfile_open_read().
MERROR_RETVAL mfile_lock_buffer(MAUG_MHANDLE, off_t, mfile_t *p_file)
Lock a buffer and assign it to an mfile_t to read/write.
Utility struct for mfmt_read_bmp_px() to keep track out of output bitmap info.
Definition mfmt.h:137
BITMAPINFO struct that comes before Windows bitmap data.
Definition mfmt.h:99
uint32_t compression
Type of compression used.
Definition mfmt.h:111
uint32_t vres
Vertical resolution in pixels per inch (unsupported).
Definition mfmt.h:117
uint16_t bpp
Number of bits per pixel (only =<8 are supported).
Definition mfmt.h:109
uint16_t color_planes
Number of color planes (only 0 or 1 are supported).
Definition mfmt.h:107
uint32_t sz
Size of this struct in bytes (only 40 is supported).
Definition mfmt.h:101
uint32_t imp_colors
Definition mfmt.h:121
uint32_t img_sz
Size of pixel data in bytes.
Definition mfmt.h:113
uint32_t hres
Horizontal resolution in pixels per inch (unsupported).
Definition mfmt.h:115
uint32_t palette_ncolors
Number of palette colors in this bitmap (<256 supported).
Definition mfmt.h:119
int32_t width
Width of the bitmap in pixels.
Definition mfmt.h:103
int32_t height
Height of the bitmap in pixels.
Definition mfmt.h:105
Generic image description struct.
Definition mfmt.h:69
uint32_t sz
Size of this struct (use to tell apart).
Definition mfmt.h:71