1 //-------------------------------------------------------------------------- 2 // Name: src/bitmap_ex.h 3 // Purpose: Helper functions and etc. for copying bitmap data to/from 4 // buffer objects. 5 // 6 // Author: Robin Dunn 7 // 8 // Created: 27-Apr-2012 9 // Copyright: (c) 2012-2018 by Total Control Software 10 // Licence: wxWindows license 11 //-------------------------------------------------------------------------- 12 13 14 #ifndef BITMAP_EX_H 15 #define BITMAP_EX_H 16 17 18 enum wxBitmapBufferFormat { 19 wxBitmapBufferFormat_RGB, 20 wxBitmapBufferFormat_RGBA, 21 wxBitmapBufferFormat_RGB32, 22 wxBitmapBufferFormat_ARGB32, 23 }; 24 25 26 // See http://tinyurl.com/e5adr for what premultiplying alpha means. wxMSW and 27 // wxMac want to have the values premultiplied by the alpha value, but the 28 // other platforms don't. These macros help keep the code clean. 29 #if defined(__WXMSW__) || defined(__WXMAC__) 30 #define wxPy_premultiply(p, a) ((p) * (a) / 0xff) 31 #define wxPy_unpremultiply(p, a) ((a) ? ((p) * 0xff / (a)) : (p)) 32 #else 33 #define wxPy_premultiply(p, a) (p) 34 #define wxPy_unpremultiply(p, a) (p) 35 #endif 36 37 38 void wxPyCopyBitmapFromBuffer(wxBitmap* bmp, 39 buffer data, Py_ssize_t DATASIZE, 40 wxBitmapBufferFormat format, int stride=-1); 41 42 void wxPyCopyBitmapToBuffer(wxBitmap* bmp, 43 buffer data, Py_ssize_t DATASIZE, 44 wxBitmapBufferFormat format, int stride=-1); 45 46 #endif 47