Home

Awesome

nimBMP

BMP Encoder and Decoder written in Nim

Build Status (Travis) Windows build status (Appveyor) nimble license Github action

supported standard color mode:

both inverted(top-down) and non inverted mode supported

Supported color conversions:

Basic Usage

import nimBMP

let bmp24 = loadBMP24("image24.bmp") #load bmp as RGB 24 bit
let bmp32 = loadBMP32("image32.bmp") #load bmp as RGBX 32 bit

# the default container is string,
# if you want the output container is seq[uint8],
# you can specify it as second param
let bmp24seq = loadBMP24("image24.bmp", seq[uint8]) #load bmp as RGB 24 bit into seq[uint8]
let bmp32seq = loadBMP32("image32.bmp", seq[uint8]) #load bmp as RGBX 32 bit into seq[uint8]

the returned object from loadBMP24 or loadBMP32 have fields:

Create BMP from raw pixels

import nimBMP

saveBMP32("image32.bmp", rgbx_pixels, width, height)
saveBMP24("image24.bmp", rgb_pixels, width, height)
saveBMP8("image8.bmp", gray_pixels, width, height)

The second param to saveBMPxx is raw input pixel. The input pixels can be a sequence of bytes in string container or seq[uint8] container

The internal algorithm of saveBMP will choose the best target format after it analyze the image's content.

Installation via nimble

nimble install nimBMP