GithubHelp home page GithubHelp logo

ghzx071458 / loadbmp Goto Github PK

View Code? Open in Web Editor NEW

This project forked from vallentin/loadbmp

0.0 0.0 0.0 7 KB

Small and simple single-header C library for loading and saving BMP images

C 100.00%

loadbmp's Introduction

LoadBMP Build Status Release License

LoadBMP is a single-header C library for loading and saving BMP image files.

LoadBMP has no no dependencies besides the standard C libraries stdlib.h, string.h and stdio.h.

Examples

LoadBMP uses raw buffers and support RGB (LOADBMP_RGB) and RGBA (LOADBMP_RGBA) formats. The order is RGBRGBRGB... or RGBARGBARGBA..., from top left to bottom right, without any padding.

The format ultimately only affects the size and layout of the pixel buffer. Thereby when loading a BMP and selecting LOADBMP_RGBA, an alpha value of 255 is added. When saving the BMP the knowledge of an alpha value is only used to be able to skip it and properly index the colors.

Loading BMP

unsigned char *pixels = NULL;
unsigned int width, height;

unsigned int err = loadbmp_decode_file("image.bmp", &pixels, &width, &height, LOADBMP_RGBA);

if (err)
	printf("LoadBMP Load Error: %u\n", err);

// Remember to free the pixel data when it isn't needed anymore.
free(pixels);

Saving BMP

unsigned char *pixels = ...;
unsigned int width, height;

unsigned int err = loadbmp_encode_file("image.bmp", pixels, width, height, LOADBMP_RGBA);

if (err)
	printf("LoadBMP Load Error: %u\n", err);

Reporting Bugs & Requests

Feel free to use the issue tracker, for reporting bugs, submitting patches or requesting features.

Before submitting bugs, make sure that you're using the latest version of LoadBMP.

License

Copyright (c) 2016 Christian Vallentin <[email protected]>

This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.

Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:

1. The origin of this software must not be misrepresented; you must not
   claim that you wrote the original software. If you use this software
   in a product, an acknowledgment in the product documentation would be
   appreciated but is not required.

2. Altered source versions must be plainly marked as such, and must not
   be misrepresented as being the original software.

3. This notice may not be removed or altered from any source
   distribution.

loadbmp's People

Contributors

vallentin avatar

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.