GFXprim
2D bitmap graphics library with emphasis on speed and correctness
Loading...
Searching...
No Matches
gp_bmp.h File Reference

BMP image loader. More...

Go to the source code of this file.

Data Structures

struct  gp_bmp_info_header
 A BMP header. More...
 

Enumerations

enum  gp_bmp_compress {
  COMPRESS_RGB = 0 , COMPRESS_RLE8 = 1 , COMPRESS_RLE4 = 2 , COMPRESS_BITFIELDS = 3 ,
  COMPRESS_JPEG = 4 , COMPRESS_PNG = 5 , COMPRESS_ALPHABITFIELDS = 6 , COMPRESS_MAX = COMPRESS_ALPHABITFIELDS
}
 BMP compression type. More...
 
enum  gp_bmp_info_header_size {
  BITMAPCOREHEADER = 12 , BITMAPCOREHEADER2 = 64 , BITMAPINFOHEADER = 40 , BITMAPINFOHEADER2 = 52 ,
  BITMAPINFOHEADER3 = 56 , BITMAPINFOHEADER4 = 108 , BITMAPINFOHEADER5 = 124
}
 BMP header size. More...
 

Functions

int gp_bmp_read_info_header (gp_io *io, struct gp_bmp_info_header *header)
 Attempts to parse BMP info header at current offset in the file IO.
 
gp_pixel_type gp_bmp_pixel_type (struct gp_bmp_info_header *header)
 Returns a pixel type suitable for a BMP info header.
 
uint32_t gp_bmp_palette_size (struct gp_bmp_info_header *header)
 Returns palette size in bytes.
 
int gp_bmp_read_pixels (gp_io *io, struct gp_bmp_info_header *header, gp_pixmap *pixmap, gp_progress_cb *callback)
 Reads a pixel data.
 

Detailed Description

BMP image loader.

Internal BMP loader functions, you shouldn't need to touch these unless you need to parse file formats that embedds a BMP images with incomplete header such as ICO file format.

Definition in file gp_bmp.h.

Enumeration Type Documentation

◆ gp_bmp_compress

BMP compression type.

Enumerator
COMPRESS_RGB 

Uncompressed.

COMPRESS_RLE8 

Run-length encoded bitmap.

COMPRESS_RLE4 

Run-length encoded bitmap.

COMPRESS_BITFIELDS 

Bitfield for each channel.

COMPRESS_JPEG 

Only for printers.

COMPRESS_PNG 

Only for printers.

COMPRESS_ALPHABITFIELDS 

Bitfields for each channel with alpha.

COMPRESS_MAX 

Terminating entry.

Definition at line 65 of file gp_bmp.h.

◆ gp_bmp_info_header_size

BMP header size.

Enumerator
BITMAPCOREHEADER 

Old OS/2 format + win 3.0.

BITMAPCOREHEADER2 

OS/2.

BITMAPINFOHEADER 

Most common.

BITMAPINFOHEADER2 

Undocummented.

BITMAPINFOHEADER3 

Undocummented.

BITMAPINFOHEADER4 

Adds color space + gamma - win 95/NT4.

BITMAPINFOHEADER5 

Adds ICC color profiles win 98+.

Definition at line 87 of file gp_bmp.h.

Function Documentation

◆ gp_bmp_palette_size()

uint32_t gp_bmp_palette_size ( struct gp_bmp_info_header * header)

Returns palette size in bytes.

Parameters
headerBMP info header structure.
Returns
Palette size in bytes.

◆ gp_bmp_pixel_type()

gp_pixel_type gp_bmp_pixel_type ( struct gp_bmp_info_header * header)

Returns a pixel type suitable for a BMP info header.

Returns a pixel type suitable for an pixmap that could be later passed to the gp_bmp_read_pixels().

Parameters
headerBMP info header.
Returns
A pixel type.

◆ gp_bmp_read_info_header()

int gp_bmp_read_info_header ( gp_io * io,
struct gp_bmp_info_header * header )

Attempts to parse BMP info header at current offset in the file IO.

Note that pixel_offset is not set by this function since the offset to the pixels is stored in the bitmap file header. This offset must be filled in by the called before the header is passed to gp_bmp_read_pixels() function.

Parameters
ioAn io stream with an BMP info header at current offset.
headerBMP info header to be filled in.
Returns
Zero on success and errno on a failure.

◆ gp_bmp_read_pixels()

int gp_bmp_read_pixels ( gp_io * io,
struct gp_bmp_info_header * header,
gp_pixmap * pixmap,
gp_progress_cb * callback )

Reads a pixel data.

Parameters
ioAn io stream.
headerBMP info header.
pixmapPre-allocated pixmap of correct size and pixel type.
callbackA progress callback.
Returns
Zero on success and errno on a failure.