//--------------------------------------------------------------------------- // This file is generated by wxPython's SIP generator. Do not edit by hand. // // Copyright: (c) 2018 by Total Control Software // License: wxWindows License // // This file will be included by _core.sip // //--------------------------------------------------------------------------- %ModuleHeaderCode #include typedef wxNativePixelData::Iterator wxNativePixelData_Accessor; typedef wxAlphaPixelData::Iterator wxAlphaPixelData_Accessor; %End //--------------------------------------------------------------------------- class wxPixelDataBase { %Docstring PixelDataBase() %End public: wxPoint GetOrigin() const; %Docstring GetOrigin() -> Point Return the origin of the area this pixel data represents. %End int GetWidth() const; %Docstring GetWidth() -> int Return the width of the area this pixel data represents. %End int GetHeight() const; %Docstring GetHeight() -> int Return the height of the area this pixel data represents. %End wxSize GetSize() const; %Docstring GetSize() -> Size Return the size of the area this pixel data represents. %End int GetRowStride() const; %Docstring GetRowStride() -> int Returns the distance between the start of one row to the start of the next row. %End public: %Property(name=Height, get=GetHeight) %Property(name=Origin, get=GetOrigin) %Property(name=RowStride, get=GetRowStride) %Property(name=Size, get=GetSize) %Property(name=Width, get=GetWidth) protected: wxPixelDataBase(); }; // end of class wxPixelDataBase %Extract(id=pycode_core) def _PixelDataBase___iter__(self): """ Create and return an iterator/generator object for traversing this pixel data object. """ width = self.GetWidth() height = self.GetHeight() pixels = self.GetPixels() # this is the C++ iterator # This class is a facade over the pixels object (using the one # in the enclosing scope) that only allows Get() and Set() to # be called. class PixelFacade(object): def Get(self): return pixels.Get() def Set(self, *args, **kw): return pixels.Set(*args, **kw) def __str__(self): return str(self.Get()) def __repr__(self): return 'pixel(%d,%d): %s' % (x,y,self.Get()) X = property(lambda self: x) Y = property(lambda self: y) import sys rangeFunc = range if sys.version_info >= (3,) else xrange pf = PixelFacade() for y in rangeFunc(height): pixels.MoveTo(self, 0, y) for x in rangeFunc(width): # We always generate the same pf instance, but it # accesses the pixels object which we use to iterate # over the pixel buffer. yield pf pixels.nextPixel() PixelDataBase.__iter__ = _PixelDataBase___iter__ del _PixelDataBase___iter__ %End class wxNativePixelData : wxPixelDataBase { %Docstring NativePixelData(bmp) NativePixelData(bmp, rect) NativePixelData(bmp, pt, sz) A class providing direct access to a :class:`wx.Bitmap`'s internal data without alpha channel (RGB). %End public: wxNativePixelData( wxBitmap& bmp ); wxNativePixelData( wxBitmap& bmp, const wxRect& rect ); wxNativePixelData( wxBitmap& bmp, const wxPoint& pt, const wxSize& sz ); ~wxNativePixelData(); wxNativePixelData_Accessor GetPixels() const; %Docstring GetPixels() -> NativePixelData_Accessor %End int __nonzero__(); %Docstring __nonzero__() -> int %End %MethodCode PyErr_Clear(); Py_BEGIN_ALLOW_THREADS sipRes = _wxNativePixelData___nonzero__(sipCpp); Py_END_ALLOW_THREADS if (PyErr_Occurred()) sipIsErr = 1; %End %TypeCode int _wxNativePixelData___nonzero__(wxNativePixelData* self) { return (int)self->operator bool(); } %End int __bool__(); %Docstring __bool__() -> int %End %MethodCode PyErr_Clear(); Py_BEGIN_ALLOW_THREADS sipRes = _wxNativePixelData___bool__(sipCpp); Py_END_ALLOW_THREADS if (PyErr_Occurred()) sipIsErr = 1; %End %TypeCode int _wxNativePixelData___bool__(wxNativePixelData* self) { return self->operator bool(); } %End public: %Property(name=Pixels, get=GetPixels) }; // end of class wxNativePixelData class wxNativePixelData_Accessor { %Docstring NativePixelData_Accessor(data) NativePixelData_Accessor(bmp, data) NativePixelData_Accessor() %End public: wxNativePixelData_Accessor( wxNativePixelData& data ); wxNativePixelData_Accessor( wxBitmap& bmp, wxNativePixelData& data ); wxNativePixelData_Accessor(); ~wxNativePixelData_Accessor(); void Reset( const wxNativePixelData& data ); %Docstring Reset(data) %End bool IsOk() const; %Docstring IsOk() -> bool %End int __nonzero__(); %Docstring __nonzero__() -> int %End %MethodCode PyErr_Clear(); Py_BEGIN_ALLOW_THREADS sipRes = _wxNativePixelData_Accessor___nonzero__(sipCpp); Py_END_ALLOW_THREADS if (PyErr_Occurred()) sipIsErr = 1; %End %TypeCode int _wxNativePixelData_Accessor___nonzero__(wxNativePixelData_Accessor* self) { return (int)self->IsOk(); } %End int __bool__(); %Docstring __bool__() -> int %End %MethodCode PyErr_Clear(); Py_BEGIN_ALLOW_THREADS sipRes = _wxNativePixelData_Accessor___bool__(sipCpp); Py_END_ALLOW_THREADS if (PyErr_Occurred()) sipIsErr = 1; %End %TypeCode int _wxNativePixelData_Accessor___bool__(wxNativePixelData_Accessor* self) { return self->IsOk(); } %End void Offset( const wxNativePixelData& data, int x, int y ); %Docstring Offset(data, x, y) %End void OffsetX( const wxNativePixelData& data, int x ); %Docstring OffsetX(data, x) %End void OffsetY( const wxNativePixelData& data, int y ); %Docstring OffsetY(data, y) %End void MoveTo( const wxNativePixelData& data, int x, int y ); %Docstring MoveTo(data, x, y) %End void nextPixel(); %Docstring nextPixel() %End %MethodCode PyErr_Clear(); Py_BEGIN_ALLOW_THREADS _wxNativePixelData_Accessor_nextPixel(sipCpp); Py_END_ALLOW_THREADS if (PyErr_Occurred()) sipIsErr = 1; %End %TypeCode void _wxNativePixelData_Accessor_nextPixel(wxNativePixelData_Accessor* self) { ++(*self); } %End void Set(byte red, byte green, byte blue); %Docstring Set(red, green, blue) %End %MethodCode PyErr_Clear(); Py_BEGIN_ALLOW_THREADS _wxNativePixelData_Accessor_Set(sipCpp, red, green, blue); Py_END_ALLOW_THREADS if (PyErr_Occurred()) sipIsErr = 1; %End %TypeCode void _wxNativePixelData_Accessor_Set(wxNativePixelData_Accessor* self, byte red, byte green, byte blue) { self->Red() = red; self->Green() = green; self->Blue() = blue; } %End PyObject* Get(); %Docstring Get() -> PyObject %End %MethodCode PyErr_Clear(); Py_BEGIN_ALLOW_THREADS sipRes = _wxNativePixelData_Accessor_Get(sipCpp); Py_END_ALLOW_THREADS if (PyErr_Occurred()) sipIsErr = 1; %End %TypeCode PyObject* _wxNativePixelData_Accessor_Get(wxNativePixelData_Accessor* self) { wxPyThreadBlocker blocker; PyObject* rv = PyTuple_New(3); PyTuple_SetItem(rv, 0, wxPyInt_FromLong(self->Red())); PyTuple_SetItem(rv, 1, wxPyInt_FromLong(self->Green())); PyTuple_SetItem(rv, 2, wxPyInt_FromLong(self->Blue())); return rv; } %End }; // end of class wxNativePixelData_Accessor class wxAlphaPixelData : wxPixelDataBase { %Docstring AlphaPixelData(bmp) AlphaPixelData(bmp, rect) AlphaPixelData(bmp, pt, sz) A class providing direct access to a :class:`wx.Bitmap`'s internal data including the alpha channel (RGBA). %End public: wxAlphaPixelData( wxBitmap& bmp ); wxAlphaPixelData( wxBitmap& bmp, const wxRect& rect ); wxAlphaPixelData( wxBitmap& bmp, const wxPoint& pt, const wxSize& sz ); ~wxAlphaPixelData(); wxAlphaPixelData_Accessor GetPixels() const; %Docstring GetPixels() -> AlphaPixelData_Accessor %End int __nonzero__(); %Docstring __nonzero__() -> int %End %MethodCode PyErr_Clear(); Py_BEGIN_ALLOW_THREADS sipRes = _wxAlphaPixelData___nonzero__(sipCpp); Py_END_ALLOW_THREADS if (PyErr_Occurred()) sipIsErr = 1; %End %TypeCode int _wxAlphaPixelData___nonzero__(wxAlphaPixelData* self) { return (int)self->operator bool(); } %End int __bool__(); %Docstring __bool__() -> int %End %MethodCode PyErr_Clear(); Py_BEGIN_ALLOW_THREADS sipRes = _wxAlphaPixelData___bool__(sipCpp); Py_END_ALLOW_THREADS if (PyErr_Occurred()) sipIsErr = 1; %End %TypeCode int _wxAlphaPixelData___bool__(wxAlphaPixelData* self) { return self->operator bool(); } %End public: %Property(name=Pixels, get=GetPixels) }; // end of class wxAlphaPixelData class wxAlphaPixelData_Accessor { %Docstring AlphaPixelData_Accessor(data) AlphaPixelData_Accessor(bmp, data) AlphaPixelData_Accessor() %End public: wxAlphaPixelData_Accessor( wxAlphaPixelData& data ); wxAlphaPixelData_Accessor( wxBitmap& bmp, wxAlphaPixelData& data ); wxAlphaPixelData_Accessor(); ~wxAlphaPixelData_Accessor(); void Reset( const wxAlphaPixelData& data ); %Docstring Reset(data) %End bool IsOk() const; %Docstring IsOk() -> bool %End int __nonzero__(); %Docstring __nonzero__() -> int %End %MethodCode PyErr_Clear(); Py_BEGIN_ALLOW_THREADS sipRes = _wxAlphaPixelData_Accessor___nonzero__(sipCpp); Py_END_ALLOW_THREADS if (PyErr_Occurred()) sipIsErr = 1; %End %TypeCode int _wxAlphaPixelData_Accessor___nonzero__(wxAlphaPixelData_Accessor* self) { return (int)self->IsOk(); } %End int __bool__(); %Docstring __bool__() -> int %End %MethodCode PyErr_Clear(); Py_BEGIN_ALLOW_THREADS sipRes = _wxAlphaPixelData_Accessor___bool__(sipCpp); Py_END_ALLOW_THREADS if (PyErr_Occurred()) sipIsErr = 1; %End %TypeCode int _wxAlphaPixelData_Accessor___bool__(wxAlphaPixelData_Accessor* self) { return self->IsOk(); } %End void Offset( const wxAlphaPixelData& data, int x, int y ); %Docstring Offset(data, x, y) %End void OffsetX( const wxAlphaPixelData& data, int x ); %Docstring OffsetX(data, x) %End void OffsetY( const wxAlphaPixelData& data, int y ); %Docstring OffsetY(data, y) %End void MoveTo( const wxAlphaPixelData& data, int x, int y ); %Docstring MoveTo(data, x, y) %End void nextPixel(); %Docstring nextPixel() %End %MethodCode PyErr_Clear(); Py_BEGIN_ALLOW_THREADS _wxAlphaPixelData_Accessor_nextPixel(sipCpp); Py_END_ALLOW_THREADS if (PyErr_Occurred()) sipIsErr = 1; %End %TypeCode void _wxAlphaPixelData_Accessor_nextPixel(wxAlphaPixelData_Accessor* self) { ++(*self); } %End void Set(byte red, byte green, byte blue, byte alpha); %Docstring Set(red, green, blue, alpha) %End %MethodCode PyErr_Clear(); Py_BEGIN_ALLOW_THREADS _wxAlphaPixelData_Accessor_Set(sipCpp, red, green, blue, alpha); Py_END_ALLOW_THREADS if (PyErr_Occurred()) sipIsErr = 1; %End %TypeCode void _wxAlphaPixelData_Accessor_Set(wxAlphaPixelData_Accessor* self, byte red, byte green, byte blue, byte alpha) { self->Red() = wxPy_premultiply(red, alpha); self->Green() = wxPy_premultiply(green, alpha); self->Blue() = wxPy_premultiply(blue, alpha); self->Alpha() = alpha; } %End PyObject* Get(); %Docstring Get() -> PyObject %End %MethodCode PyErr_Clear(); Py_BEGIN_ALLOW_THREADS sipRes = _wxAlphaPixelData_Accessor_Get(sipCpp); Py_END_ALLOW_THREADS if (PyErr_Occurred()) sipIsErr = 1; %End %TypeCode PyObject* _wxAlphaPixelData_Accessor_Get(wxAlphaPixelData_Accessor* self) { wxPyThreadBlocker blocker; PyObject* rv = PyTuple_New(4); int red = self->Red(); int green = self->Green(); int blue = self->Blue(); int alpha = self->Alpha(); PyTuple_SetItem(rv, 0, wxPyInt_FromLong( wxPy_unpremultiply(red, alpha) )); PyTuple_SetItem(rv, 1, wxPyInt_FromLong( wxPy_unpremultiply(green, alpha) )); PyTuple_SetItem(rv, 2, wxPyInt_FromLong( wxPy_unpremultiply(blue, alpha) )); PyTuple_SetItem(rv, 3, wxPyInt_FromLong( alpha )); return rv; } %End }; // end of class wxAlphaPixelData_Accessor //---------------------------------------------------------------------------