C/C++ library to blend PNG (including Alpha) with raw ARGB buffer C/C++ library to blend PNG (including Alpha) with raw ARGB buffer linux linux

C/C++ library to blend PNG (including Alpha) with raw ARGB buffer


You can do this with SDL by using SDL_gfx and SDL_Image.

// load images using SDL_ImageSDL_Surface *image1, image2;image1=IMG_Load("front.png");image2=IMG_Load("back.png");// blit images onto a surface using SDL_gfxSDL_gfxBlitRGBA ( image1, rect, screen, rect ); SDL_gfxBlitRGBA ( image2, rect, screen, rect );


You need to pair a file-format library (libPNG or ImageMagick) with a image manipulation library. Boost.GIL would be good here. If you can load the ARGB buffer (4 bytes per pixel) into memory, you can create a GIL image with interleaved_view, and reinterpret_casting your buffer pointer to a boost::gil::argb32_ptr_t


With the ImageMagick it is very easy thing to do by using appendImages function.

Like this :

#include <list>#include <Magick++.h>using namespace std;using namespace Magick;int main(int /*argc*/,char **/*argv*/){   list<Image> imageList;   readImages( &imageList, "test_image_anim.gif" );   Image appended;   appendImages( &appended, imageList.begin(), imageList.end() );   appended.write( "appended_image.miff" );   return 0;}