X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/a72f4631fe5ab7ebeefdacf8ec9c826ea962133f..b519803b436486ca933d750c990ef64a29551221:/wxPython/src/_image.i diff --git a/wxPython/src/_image.i b/wxPython/src/_image.i index 7c3ea50467..ea4cca9f10 100644 --- a/wxPython/src/_image.i +++ b/wxPython/src/_image.i @@ -106,6 +106,24 @@ public: memcpy(copy, data, width*height*3); return new wxImage(width, height, copy, false); } + %name(ImageFromDataWithAlpha) wxImage(int width, int height, + unsigned char* data, unsigned char* alpha) { + // Copy the source data so the wxImage can clean it up later + unsigned char* dcopy = (unsigned char*)malloc(width*height*3); + if (dcopy == NULL) { + PyErr_NoMemory(); + return NULL; + } + memcpy(dcopy, data, width*height*3); + unsigned char* acopy = (unsigned char*)malloc(width*height); + if (acopy == NULL) { + PyErr_NoMemory(); + return NULL; + } + memcpy(acopy, alpha, width*height); + + return new wxImage(width, height, dcopy, acopy, false); + } } void Create( int width, int height ); @@ -146,6 +164,17 @@ If the image image doesn't have alpha channel, ConvertAlphaToMask does nothing.", ""); + DocDeclStr( + bool , ConvertColourToAlpha( unsigned char r, unsigned char g, unsigned char b ), + "This method converts an image where the original alpha information is +only available as a shades of a colour (actually shades of grey) +typically when you draw anti-aliased text into a bitmap. The DC +drawing routines draw grey values on the black background although +they actually mean to draw white with differnt alpha values. This +method reverses it, assuming a black (!) background and white text. +The method will then fill up the whole image with the colour given.", ""); + + // Set image's mask to the area of 'mask' that has colour bool SetMaskFromImage(const wxImage & mask,