Skip to content

A simple C funtion for saving RGB/RGBA image as uncompressed BMP.

License

Notifications You must be signed in to change notification settings

NyaNekoplus/toybmp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

toybmp

A simple C funtion for saving RGB/RGBA image as uncompressed BMP.

Features

  • RGB or RGBA format. (RGBA format can't be displayed correctly in BMP)
  • Single function
  • No dependency

Usage

Basically, you fopen() a binary file for writing, then call this function with the image data. The pixels are packed linearly from bottom to top, left to right.

For 24-bit RGB, parameter alpha should be set to 0, the R, G, B components are stored as img[(w*y+x)*3], img[(w*y+x)*3+1], img[(w*y+x)*3+2], respectively.

For 32-bit RGBA, parameter alpha should be set to 0, the R, G, B, A components are stored as img[(w*y+x)*4], img[(w*y+x)*4+1], img[(w*y+x)*4+2], respectively.

Example

test.c saves a RGB aand a RGBA BMP.

Output

RGB

RGBA

About

A simple C funtion for saving RGB/RGBA image as uncompressed BMP.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages