2 %module
(package
="gfxprim.core") c_core
5 #include
"core/GP_Core.h"
9 * Basic types and common methods
14 %include
"GP_Transform.h"
15 %include
"GP_GetSetBits.h"
16 %include
"GP_Transform.h"
19 * Make members of GP_DebugMsg structure immutable
21 %immutable GP_DebugMsg
::level
;
22 %immutable GP_DebugMsg
::file
;
23 %immutable GP_DebugMsg
::fn
;
24 %immutable GP_DebugMsg
::line
;
25 %immutable GP_DebugMsg
::msg
;
26 %ignore GP_DebugPrint
;
34 %include
"GP_Pixel.gen.h" /* Includes enum GP_PixelType definition
*/
35 %include
"GP_Convert.h"
36 %import
"GP_Convert.gen.h"
37 %import
"GP_Convert_Scale.gen.h"
39 %import
"GP_FnPerBpp.h"
40 %import
"GP_FnPerBpp.gen.h"
43 const GP_PixelTypeDescription
*GP_PixelTypes_access
(GP_PixelType no
)
45 if
((signed
)no
< 0 || no
>= GP_PIXEL_MAX
) no
= GP_PIXEL_UNKNOWN
;
46 return
&GP_PixelTypes[no];
54 /* Make some members RO
*/
55 %immutable GP_Context
::w
;
56 %immutable GP_Context
::h
;
57 %immutable GP_Context
::pixel_type
;
58 %immutable GP_Context
::bpp
;
59 %immutable GP_Context
::bytes_per_row
;
60 /* Rename
"internal" GP_Context
*/
61 %rename
("_%s") "GP_Context::pixels";
62 %rename
("_%s") "GP_Context::offset";
63 %rename
("_%s") "GP_Context::axes_swap";
64 %rename
("_%s") "GP_Context::x_swap";
65 %rename
("_%s") "GP_Context::y_swap";
66 %rename
("_%s") "GP_Context::bit_endian";
67 %rename
("_%s") "GP_Context::free_pixels";
70 PyObject
*GP_ContextToByteArray
(GP_Context
*self
)
72 return PyByteArray_FromStringAndSize
((char
*)self-
>pixels
,
73 self-
>bytes_per_row
* self-
>h
);
77 %feature
("autodoc", "Proxy of C GP_Context struct
79 You can pass this class to wrapped GP_DrawSomething(...) as GP_Context.
80 All attributes of GP_Context are accessible directly as _attribute
81 (self._w etc.), but it is reccomended to use redefined properties:
83 self.w: Context width (transformed)
84 self.h: Context height (transformed)
85 self.pixel_type: Context pixel type (number)
87 Some context-related methods are provided as class members for convenience.
89 GP_Context memory allocation is handled by gfxprim, deallocation by GP_ContextFree().
90 The wrapper can be used without owning the GP_Context struct by setting self.this
91 and self.thisown.") GP_Context
;
95 GP_DEBUG
(2, "[wrapper] GP_ContextFree (%dx%d raw, %dbpp, free_pixels:%d)",
96 $self-
>w
, $self-
>h
, $self-
>bpp
, $self-
>free_pixels
);
97 GP_ContextFree
($self
);
99 GP_Context
(GP_Coord w
, GP_Coord h
, GP_PixelType typeno
) {
100 return GP_ContextAlloc
(w
, h
, typeno
);
106 ERROR_ON_NONZERO
(GP_ContextResize
);
107 ERROR_ON_NULL
(GP_ContextAlloc
);
108 ERROR_ON_NULL
(GP_ContextCopy
);
109 ERROR_ON_NULL
(GP_ContextConvertAlloc
);
110 ERROR_ON_NULL
(GP_SubContextAlloc
);
112 /* Indicate new wrapper-owned GP_Context
*/
113 %newobject GP_ContextAlloc
;
114 %newobject GP_ContextCopy
;
115 %newobject GP_ContextConvertAlloc
;
116 %newobject GP_SubContextAlloc
;
118 %include
"GP_Context.h"
121 * Context manipulation
123 %include
"GP_GetPutPixel.h"
124 %import
"GP_GetPutPixel.gen.h"
125 %include
"GP_WritePixel.h"