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