Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

I have a PNG with an encoded alpha channel that I want to blend with a raw ARGB image in memory that is stored interleaved. The PNG is of a different resolution to the image buffer and needs to be resized accordingly (preferably with interpolation).

Whilst I appreciate it's not particularly difficult to do this by hand (once the PNG image is loaded into an appropriate structure), I was hoping to find a good open source image processing library to do the work for me.

I've looked at a few including:

  • libGD
  • libPNG
  • openCV
  • ImageMagick
  • CxImage
  • Intel Integrated Performance Primitives (IPP)

But none of seem to handle all the requirements of loading PNGs, resizing the PNG image, alpha blending into the image data and handling the ARGB format (as opposed to RGBA).

Performance is a concern so reducing the passes over the image data would be beneficial, especially being able to hold the ARGB data in place rather than having to copy it to a different data structure to perform the blending.

Does anyone know of any libraries that may be able to help or whether I've missed something in one of the above?

like image 380
TheJuice Avatar asked Jun 01 '11 10:06

TheJuice


1 Answers

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

// load images using SDL_Image
SDL_Surface *image1, image2;
image1=IMG_Load("front.png");
image2=IMG_Load("back.png");

// blit images onto a surface using SDL_gfx
SDL_gfxBlitRGBA ( image1, rect, screen, rect ); 
SDL_gfxBlitRGBA ( image2, rect, screen, rect );
like image 138
IanNorton Avatar answered Oct 06 '22 14:10

IanNorton