Git Product home page Git Product logo

blimp's Introduction

Blimp

A dead simple library for handling BMP format images. Great for programs that need fast image generation without the complexity. Support for antiquated bit depths such as 1, 2, 4, 8, 16, as well as modern bit depths: 24 and 32.

Features

  • Exporting and loading with BMPINFOHEADER.
  • Pixel setting and getting.
  • Row filling, column filling, image fill.
  • Low bit depth support (1, 2, 4, 8, 16).
  • Palette swapping / modifying.
  • Row fill, column fill, image fill.
  • Compression support.
  • Exporting and loading with BITMAPV4HEADER & BITMAPV5HEADER.
  • Image scaling: nearest neighbor, linear interpolation.
  • Image crop, reflect, rotate.
  • Multiple image overlaying, merging, stiching, etc.
  • Extra effects like dither fills, filters, etc.
  • GPU acceleration and mutlithreading

Dependencies

  • C standard library, C math library, and C++ standard library.
  • Catch2 for testing.

Installing

  1. Run make in the root directory of the project. This creates the static library in the bin directory.
  2. Include blimp.h
  3. Link against libBlimp.a

Getting Started

Intialize your image. By default a new BMP image is 64 x 64 and has a bit depth of 24.

BMP image;

Optionally, provide contructor arguments to set the size and bit depth.

BMP image(512, 512); // 24 bit depth
BMP image2(300, 200, 16); // 16 bit depth

You can create a BMP object from an existing BMP image with either a constructor overload or the copy(string filename) function.

BMP image3("../greatpicture.bmp");
image2.copy("someimage.bmp");

Resize or change the bit depth with the following functions:

image.set_bit_depth(24);
image.set_size(512, 512);          

Generate your image with generate(string filename).

image.generate("thebestpic.bmp");

Blimp uses 32-bit integers for color but provides a simple alias for readability: color.

color red_24bit = 0xFF0000;
color blue_16bit = 0x001F;

Fill the image with your new color!

image.fill(red_24bit);

Sometimes you need to change just one pixel. Use set_pixel(int x, int y, color c).

image.set_pixel(50, 50, red_24bit);

If you want to get the color of one pixel, use color get_pixel(int x, int y).

image.get_pixel(50, 50);

You can also get and set pixels by index (starting at 0), if you are into that kinda thing:

image.set_pixel(20, red_24bit);

Vapor Lena

blimp's People

Contributors

sagefarrenholz avatar

Stargazers

Sehyun Hwang avatar  avatar  avatar

Forkers

damfil

blimp's Issues

BMP::set_bit_depth() must be called before BMP::set_size()

Calling BMP::set_bit_depth() does not resize the image, this means that if you were to perhaps, up the bit depth from 16 to 32 (2 bytes to 4 bytes). Your image would not have enough memory to account for the increase in bit depth. This will likely lead to a segmentation fault when accessing pixels at the end of the image. Resizing the image after each call to BMP::set_bit_depth() seems like a poor design choice as well because users are likely to call BMP::set_size() after.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.