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#if MFMT_TRACE_RLE_LVL > 0
312 debug_printf( MFMT_TRACE_RLE_LVL,
313 "decompressing RLE into temporary buffer..." );
316 maug_mlock( buffer_out_h, buffer_out );
318 maug_mzero( buffer_out, buffer_out_sz );
321 retval = p_file_in->seek( p_file_in, file_offset + in_byte_cur++ );
322 maug_cleanup_if_not_ok();
323 retval = p_file_in->read_byte( p_file_in, &byte_buffer );
324 maug_cleanup_if_not_ok();
326 debug_printf( MFMT_TRACE_RLE_LVL,
"in byte " OFF_T_FMT
327 ": 0x%02x, out byte " OFF_T_FMT
", line px: %u",
328 in_byte_cur, byte_buffer, out_byte_cur, line_px_written );
330 switch( byte_buffer ) {
332 if( MFMT_RLE_DECODE_RUN == decode_state ) {
333 mfmt_decode_rle_state( MFMT_RLE_DECODE_ESC );
336 }
else if( MFMT_RLE_DECODE_LITERAL_PAD == decode_state ) {
338 assert( 0 == byte_buffer );
339 mfmt_decode_rle_state( MFMT_RLE_DECODE_RUN );
342 }
else if( MFMT_RLE_DECODE_ESC == decode_state ) {
344 debug_printf( MFMT_TRACE_RLE_LVL,
345 "EOL: %u px written", line_px_written );
346 while( line_px_written < line_w ) {
348 assert( 0 == line_px_written % 2 );
349 buffer_out[out_byte_cur++] = 0x00;
350 mfmt_decode_rle_inc_line_w( 2 );
351 debug_printf( MFMT_TRACE_RLE_LVL,
352 "padded line (%u written)", line_px_written );
354 mfmt_decode_rle_reset_line();
357 mfmt_decode_rle_state( MFMT_RLE_DECODE_RUN );
362 if( MFMT_RLE_DECODE_ESC == decode_state ) {
363 debug_printf( MFMT_TRACE_RLE_LVL,
"EOBM" );
366 while( out_byte_cur < buffer_out_sz ) {
368 assert( 0 == line_px_written % 2 );
369 mfmt_decode_rle_check_eol();
370 buffer_out[out_byte_cur++] = 0x00;
371 mfmt_decode_rle_inc_line_w( 2 );
372 debug_printf( MFMT_TRACE_RLE_LVL,
373 "padded file (%u written)", line_px_written );
376 mfmt_decode_rle_state( MFMT_RLE_DECODE_RUN );
381 if( MFMT_RLE_DECODE_ESC == decode_state ) {
382 debug_printf( MFMT_TRACE_RLE_LVL,
"absolute mode: right" );
385 mfmt_decode_rle_state( MFMT_RLE_DECODE_ABS_RIGHT );
390 switch( decode_state ) {
391 case MFMT_RLE_DECODE_LITERAL:
393 mfmt_decode_rle_check_eol();
396 unpadded_written += 2;
397 mfmt_decode_rle_inc_line_w( 2 );
398 debug_printf( MFMT_TRACE_RLE_LVL,
399 "writing literal: 0x%02x (%u left, unpadded run val: %u)",
400 byte_buffer, run_count, unpadded_written );
401 buffer_out[out_byte_cur++] = byte_buffer;
403 if( 0 == run_count ) {
404 if( 0 != unpadded_written % 4 ) {
407 debug_printf( MFMT_TRACE_RLE_LVL,
408 "unpadded: %u, next is pad byte", unpadded_written );
410 mfmt_decode_rle_state( MFMT_RLE_DECODE_LITERAL_PAD );
414 mfmt_decode_rle_state( MFMT_RLE_DECODE_RUN );
419 case MFMT_RLE_DECODE_ESC:
420 run_count = byte_buffer;
421 unpadded_written = 0;
422 debug_printf( MFMT_TRACE_RLE_LVL,
423 "literal mode: %u nibbles", run_count );
424 assert( 0 == run_count % 2 );
425 mfmt_decode_rle_state( MFMT_RLE_DECODE_LITERAL );
428 case MFMT_RLE_DECODE_ABS_RIGHT:
429 debug_printf( MFMT_TRACE_RLE_LVL,
"absolute mode: up" );
432 mfmt_decode_rle_state( MFMT_RLE_DECODE_ABS_DOWN );
435 case MFMT_RLE_DECODE_RUN:
437 mfmt_decode_rle_check_eol();
439 run_count = byte_buffer;
440 debug_printf( MFMT_TRACE_RLE_LVL,
441 "starting run: %u nibbles", run_count );
442 mfmt_decode_rle_state( MFMT_RLE_DECODE_CHAR );
445 case MFMT_RLE_DECODE_CHAR:
446 assert( 0 != run_count );
447 run_char = byte_buffer;
448 debug_printf( MFMT_TRACE_RLE_LVL,
449 "%u-long run of 0x%02x...", run_count, run_char );
452 debug_printf( MFMT_TRACE_RLE_LVL,
453 "writing 0x%02x & 0x%02x #%u (line px #%u)...",
454 run_char, out_mask_cur, run_count, line_px_written );
455 buffer_out[out_byte_cur] |= (run_char & out_mask_cur);
456 mfmt_decode_rle_advance_mask();
457 mfmt_decode_rle_inc_line_w( 1 );
460 }
while( 0 < run_count );
463 mfmt_decode_rle_state( MFMT_RLE_DECODE_RUN );
469 }
while( in_byte_cur < file_sz );
472 MFMT_TRACE_RLE_LVL,
"wrote " OFF_T_FMT
" bytes (%u lines)",
473 out_byte_cur, lines_out );
477 if( NULL != buffer_out ) {
478 maug_munlock( buffer_out_h, buffer_out );
488 off_t file_offset, off_t file_sz, uint8_t* p_flags
493 uint32_t file_hdr_sz = 0;
494 off_t header_offset = 0;
496 mfmt_bmp_check_header();
498 if( NULL != header_bmp_file ) {
501 debug_printf( MFMT_TRACE_BMP_LVL,
502 "reading bitmap file header at " OFF_T_FMT
" bytes...",
506 retval = p_file_in->seek( p_file_in, file_offset + 2 );
507 maug_cleanup_if_not_ok();
508 retval = p_file_in->read_int( p_file_in,
510 maug_cleanup_if_not_ok();
512 retval = p_file_in->seek( p_file_in, file_offset + 10 );
513 maug_cleanup_if_not_ok();
514 retval = p_file_in->read_int( p_file_in,
516 maug_cleanup_if_not_ok();
518 debug_printf( MFMT_TRACE_BMP_LVL,
519 "bitmap file " U32_FMT
" bytes long, px at "
521 header_bmp_file->file_sz,
522 header_bmp_file->px_offset );
526 retval = p_file_in->seek( p_file_in, file_offset + header_offset );
527 maug_cleanup_if_not_ok();
528 retval = p_file_in->read_int( p_file_in,
530 maug_cleanup_if_not_ok();
531 if( 40 != file_hdr_sz ) {
532 error_printf(
"invalid header size: " U32_FMT, file_hdr_sz );
533 retval = MERROR_FILE;
537 MFMT_TRACE_BMP_LVL,
"bitmap header is " U32_FMT
" bytes",
540 if( 40 > file_sz - (file_offset + header_offset) ) {
542 "bitmap header overflow! (only " OFF_T_FMT
" bytes remain!)",
543 file_sz - (file_offset + header_offset) );
544 retval = MERROR_OVERFLOW;
549 retval = p_file_in->seek( p_file_in,
550 file_offset + header_offset + MFMT_BMPINFO_OFS_WIDTH );
551 maug_cleanup_if_not_ok();
552 retval = p_file_in->read_int( p_file_in,
554 maug_cleanup_if_not_ok();
556 retval = p_file_in->seek( p_file_in,
557 file_offset + header_offset + MFMT_BMPINFO_OFS_HEIGHT );
558 maug_cleanup_if_not_ok();
559 retval = p_file_in->read_int( p_file_in,
561 maug_cleanup_if_not_ok();
563 if( 0 > header_bmp_info->
height ) {
565 MFMT_TRACE_BMP_LVL,
"bitmap Y coordinate is inverted..." );
566 *p_flags |= MFMT_PX_FLAG_INVERT_Y;
569 retval = p_file_in->seek( p_file_in,
570 file_offset + header_offset + MFMT_BMPINFO_OFS_SZ );
571 maug_cleanup_if_not_ok();
572 retval = p_file_in->read_int( p_file_in,
574 maug_cleanup_if_not_ok();
577 retval = p_file_in->seek( p_file_in,
578 file_offset + header_offset + MFMT_BMPINFO_OFS_BPP );
579 maug_cleanup_if_not_ok();
580 retval = p_file_in->read_int( p_file_in,
582 maug_cleanup_if_not_ok();
584 if( 8 < header_bmp_info->
bpp ) {
585 error_printf(
"invalid bitmap bpp: %u",
586 header_bmp_info->
bpp );
587 retval = MERROR_FILE;
592 retval = p_file_in->seek( p_file_in,
593 file_offset + header_offset + MFMT_BMPINFO_OFS_COMPRESSION );
594 maug_cleanup_if_not_ok();
595 retval = p_file_in->read_int( p_file_in,
597 maug_cleanup_if_not_ok();
605 error_printf(
"invalid bitmap compression: " U32_FMT,
607 retval = MERROR_FILE;
613 retval = p_file_in->seek( p_file_in,
614 file_offset + header_offset + MFMT_BMPINFO_OFS_PAL_SZ );
615 maug_cleanup_if_not_ok();
616 retval = p_file_in->read_int( p_file_in,
618 maug_cleanup_if_not_ok();
620 debug_printf( 2,
"bitmap is " S32_FMT
" x " S32_FMT
621 ", %u bpp (palette has " U32_FMT
" colors)",
622 header_bmp_info->
width,
624 header_bmp_info->
bpp,
635 struct MFMT_STRUCT* header, uint32_t* palette,
size_t palette_sz,
636 mfile_t* p_file_in, uint32_t file_offset, off_t file_sz, uint8_t flags
643 mfmt_bmp_check_header();
645 retval = p_file_in->seek( p_file_in, file_offset );
646 maug_cleanup_if_not_ok();
648 if( i * 4 > palette_sz ) {
649 error_printf(
"palette overflow!" );
650 retval = MERROR_OVERFLOW;
654 retval = p_file_in->read_int( p_file_in,
656 maug_cleanup_if_not_ok();
658 debug_printf( MFMT_TRACE_BMP_LVL,
659 "set palette entry " OFF_T_FMT
" to " X32_FMT,
672 size_t px_offset, MAUG_MHANDLE* p_px_h
678 if( 0 == header_bmp_info->
height ) {
679 error_printf(
"bitmap height is 0!" );
680 retval = MERROR_FILE;
684 if( 0 == header_bmp_info->
width ) {
685 error_printf(
"bitmap width is 0!" );
686 retval = MERROR_FILE;
690 if( 0 == header_bmp_info->
bpp ) {
691 error_printf(
"bitmap BPP is 0!" );
692 retval = MERROR_FILE;
696 if( 8 < header_bmp_info->
bpp ) {
697 error_printf(
">8BPP bitmaps not supported!" );
698 retval = MERROR_FILE;
705 debug_printf( 1,
"allocating decompression buffer..." );
708 *p_px_h = maug_malloc(
709 header_bmp_info->
width,
710 header_bmp_info->
height );
711 maug_cleanup_if_null_alloc( MAUG_MHANDLE, *p_px_h );
714 p_bmp_in, px_offset, header_bmp_info->
img_sz,
715 header_bmp_info->
width,
718 MFMT_DECOMP_FLAG_4BIT );
719 maug_cleanup_if_not_ok();
731 mfile_t* p_file_in, uint32_t px_offset, off_t file_sz, uint8_t flags,
743 uint8_t byte_buffer = 0,
746 MAUG_MHANDLE decomp_buffer_h = (MAUG_MHANDLE)NULL;
748 mfile_t *p_file_bmp = p_file_in;
750 mfmt_bmp_check_header();
752 maug_mzero( &file_decomp,
sizeof( mfile_t ) );
755 header_bmp_info, p_file_in, px_offset, &decomp_buffer_h );
756 maug_cleanup_if_not_ok();
758 if( (MAUG_MHANDLE)NULL != decomp_buffer_h ) {
760 decomp_buffer_h, NULL,
763 maug_cleanup_if_not_ok();
766 p_file_bmp = &file_decomp;
770 width_mod_4 = header_bmp_info->
width % 4;
771 maug_cleanup_if_ne( (int32_t)0, width_mod_4, S32_FMT, MERROR_GUI );
773 y = header_bmp_info->
height - 1;
776 maug_cleanup_if_not_ok();
777 if( p_file_bmp == p_file_in ) {
781 p_file_bmp->seek( p_file_bmp, px_offset );
787 debug_printf( MFMT_TRACE_BMP_LVL,
788 "byte in: " OFF_T_FMT
" (" OFF_T_FMT
789 "), bit " OFF_T_FMT
", y: " U32_FMT
", x: " U32_FMT
")",
790 byte_in_idx, file_sz, bit_idx, y, x );
794 if( byte_in_idx >= file_sz ) {
797 "input bitmap has insufficient size " OFF_T_FMT
" bytes)!",
805 retval = p_file_bmp->read_byte( p_file_bmp, &byte_buffer );
806 maug_cleanup_if_not_ok();
814 for( i = 0 ; header_bmp_info->
bpp > i ; i++ ) {
823 pixel_buffer |= byte_buffer & byte_mask;
830 (bit_idx - header_bmp_info->
bpp);
831 debug_printf( MFMT_TRACE_BMP_LVL,
832 "byte_mask: 0x%02x, bit_idx: " OFF_T_FMT
833 ", pixel_buffer: 0x%02x",
834 byte_mask, bit_idx, pixel_buffer );
837 retval = px_cb( px_cb_data, pixel_buffer, x, y, header_bmp_info, flags );
838 maug_cleanup_if_not_ok();
843 byte_mask >>= header_bmp_info->
bpp;
844 bit_idx -= header_bmp_info->
bpp;
848 if( x >= header_bmp_info->
width ) {
852 while( byte_in_idx % 4 != 0 ) {
854 p_file_bmp->seek( p_file_bmp, px_offset + byte_in_idx );
859 px_cb_data, 0, x, y, header_bmp_info,
861 maug_cleanup_if_not_ok();
873 if( (MAUG_MHANDLE)NULL != decomp_buffer_h ) {
874 debug_printf( 1,
"freeing decomp buffer %p...", decomp_buffer_h );
875 maug_mfree( decomp_buffer_h );
884 void* data, uint8_t px, int32_t x, int32_t y,
885 void* header_info, uint8_t flags
893 if( p_out->px_sz < p_out->byte_idx ) {
895 "byte " OFF_T_FMT
" outside of " OFF_T_FMT
896 " pixel buffer!", p_out->byte_idx, p_out->px_sz );
897 retval = MERROR_OVERFLOW;
903 debug_printf( MFMT_TRACE_BMP_LVL,
904 "new row starting at byte_out_idx: " OFF_T_FMT,
907 (MFMT_PX_FLAG_INVERT_Y == (MFMT_PX_FLAG_INVERT_Y & flags) ?
908 ((header_bmp_info->
height - y - 1) *
909 header_bmp_info->
width) :
910 ((y) * header_bmp_info->
width));
913 debug_printf( MFMT_TRACE_BMP_LVL,
914 "writing byte " OFF_T_FMT
" (x: " S32_FMT
916 p_out->byte_idx, x, y );
917 p_out->px[p_out->byte_idx] = px;
929 struct MFMT_STRUCT* header, uint8_t SEG_FAR* px, off_t px_sz,
930 mfile_t* p_file_in, uint32_t px_offset, off_t file_sz, uint8_t flags
940 header, p_file_in, px_offset, file_sz, flags,
941 _mfmt_read_bmp_px_cb_px, &out );
uint16_t 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
MERROR_RETVAL mfile_lock_buffer(MAUG_MHANDLE, void *ptr, off_t, mfile_t *p_file)
Lock a buffer and assign it to an mfile_t to read/write.
#define MFILE_READ_FLAG_LSBF
Flag for mfile_read_int_t() indicating integer should always be read least significant byte first.
Definition mfile.h:92
void mfile_close(mfile_t *p_file)
Close a file opened with mfile_open_read().
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