X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/bf7df69ef66934a877dbec910b02029bd8706590..f89238b9fe8396c67b3a12a469a930c9eb6e4be6:/wxPython/src/_image.i diff --git a/wxPython/src/_image.i b/wxPython/src/_image.i index 43e9f24626..6b315bc824 100644 --- a/wxPython/src/_image.i +++ b/wxPython/src/_image.i @@ -28,6 +28,13 @@ enum { }; +// Constants for wxImage::Scale() for determining the level of quality +enum +{ + wxIMAGE_QUALITY_NORMAL = 0, + wxIMAGE_QUALITY_HIGH = 1 +}; + //--------------------------------------------------------------------------- %newgroup @@ -54,6 +61,11 @@ public: void SetExtension(const wxString& extension); void SetType(long type); void SetMimeType(const wxString& mimetype); + + %property(Extension, GetExtension, SetExtension, doc="See `GetExtension` and `SetExtension`"); + %property(MimeType, GetMimeType, SetMimeType, doc="See `GetMimeType` and `SetMimeType`"); + %property(Name, GetName, SetName, doc="See `GetName` and `SetName`"); + %property(Type, GetType, SetType, doc="See `GetType` and `SetType`"); }; @@ -220,6 +232,7 @@ public: }; + class wxImage : public wxObject { public: %typemap(out) wxImage*; // turn off this typemap @@ -394,19 +407,60 @@ initialized to black. Otherwise, the image data will be uninitialized.", ""); DocDeclStr( - wxImage , Scale( int width, int height ), + wxImage , Scale( int width, int height, int quality = wxIMAGE_QUALITY_NORMAL ), "Returns a scaled version of the image. This is also useful for scaling bitmaps in general as the only other way to scale bitmaps is to blit a -`wx.MemoryDC` into another `wx.MemoryDC`.", " +`wx.MemoryDC` into another `wx.MemoryDC`. The ``quality`` parameter +specifies what method to use for resampling the image. It can be +either wx.IMAGE_QUALITY_NORMAL, which uses the normal default scaling +method of pixel replication, or wx.IMAGE_QUALITY_HIGH which uses +bicubic and box averaging resampling methods for upsampling and +downsampling respectively.", " + +It should be noted that although using wx.IMAGE_QUALITY_HIGH produces +much nicer looking results it is a slower method. Downsampling will +use the box averaging method which seems to operate very fast. If you +are upsampling larger images using this method you will most likely +notice that it is a bit slower and in extreme cases it will be quite +substantially slower as the bicubic algorithm has to process a lot of +data. + +It should also be noted that the high quality scaling may not work as +expected when using a single mask colour for transparency, as the +scaling will blur the image and will therefore remove the mask +partially. Using the alpha channel will work. :see: `Rescale`"); + + + wxImage ResampleBox(int width, int height) const; + wxImage ResampleBicubic(int width, int height) const; + + DocDeclStr( + wxImage , Blur(int radius), + "Blurs the image in both horizontal and vertical directions by the +specified pixel ``radius``. This should not be used when using a +single mask colour for transparency.", ""); + + DocDeclStr( + wxImage , BlurHorizontal(int radius), + "Blurs the image in the horizontal direction only. This should not be +used when using a single mask colour for transparency. +", ""); + + DocDeclStr( + wxImage , BlurVertical(int radius), + "Blurs the image in the vertical direction only. This should not be +used when using a single mask colour for transparency.", ""); + + DocDeclStr( wxImage , ShrinkBy( int xFactor , int yFactor ) const , "Return a version of the image scaled smaller by the given factors.", ""); DocDeclStr( - wxImage& , Rescale(int width, int height), + wxImage& , Rescale(int width, int height, int quality = wxIMAGE_QUALITY_NORMAL), "Changes the size of the image in-place by scaling it: after a call to this function, the image will have the given width and height. @@ -615,8 +669,9 @@ object, using a MIME type string to specify the image file format.", "", DocDeclStr( - bool , Ok(), + bool , IsOk(), "Returns true if image data is present.", ""); + %pythoncode { Ok = IsOk } DocDeclStr( int , GetWidth(), @@ -982,7 +1037,18 @@ range -1.0..1.0 where -1.0 is -360 degrees and 1.0 is 360 degrees", ""); "Converts a color in HSV color space to RGB color space.", ""); - %pythoncode { def __nonzero__(self): return self.Ok() } + %pythoncode { def __nonzero__(self): return self.IsOk() } + + %property(AlphaBuffer, GetAlphaBuffer, SetAlphaBuffer, doc="See `GetAlphaBuffer` and `SetAlphaBuffer`"); + %property(AlphaData, GetAlphaData, SetAlphaData, doc="See `GetAlphaData` and `SetAlphaData`"); + %property(Data, GetData, SetData, doc="See `GetData` and `SetData`"); + %property(DataBuffer, GetDataBuffer, SetDataBuffer, doc="See `GetDataBuffer` and `SetDataBuffer`"); + %property(Height, GetHeight, doc="See `GetHeight`"); + %property(MaskBlue, GetMaskBlue, doc="See `GetMaskBlue`"); + %property(MaskGreen, GetMaskGreen, doc="See `GetMaskGreen`"); + %property(MaskRed, GetMaskRed, doc="See `GetMaskRed`"); + %property(Width, GetWidth, doc="See `GetWidth`"); + }; @@ -1017,12 +1083,11 @@ range -1.0..1.0 where -1.0 is -360 degrees and 1.0 is 360 degrees", ""); def ImageFromBuffer(width, height, dataBuffer, alphaBuffer=None): """ Creates a `wx.Image` from the data in dataBuffer. The dataBuffer - parameter must be a Python object that implements the buffer interface, or - is convertable to a buffer object, such as a string, array, etc. The - dataBuffer object is expected to contain a series of RGB bytes and be - width*height*3 bytes long. A buffer object can optionally be supplied for - the image's alpha channel data, and it is expected to be width*height - bytes long. + parameter must be a Python object that implements the buffer interface, + such as a string, array, etc. The dataBuffer object is expected to + contain a series of RGB bytes and be width*height*3 bytes long. A buffer + object can optionally be supplied for the image's alpha channel data, and + it is expected to be width*height bytes long. The wx.Image will be created with its data and alpha pointers initialized to the memory address pointed to by the buffer objects, thus saving the @@ -1040,10 +1105,6 @@ def ImageFromBuffer(width, height, dataBuffer, alphaBuffer=None): the objects used for the data and alpha buffers in a way that would cause them to change size. """ - if not isinstance(dataBuffer, buffer): - dataBuffer = buffer(dataBuffer) - if alphaBuffer is not None and not isinstance(alphaBuffer, buffer): - alphaBuffer = buffer(alphaBuffer) image = _core_._ImageFromBuffer(width, height, dataBuffer, alphaBuffer) image._buffer = dataBuffer image._alpha = alphaBuffer @@ -1202,7 +1263,12 @@ public: }; -#if wxUSE_IFF + +#if 0 +%{ +#include +%} + DocStr(wxIFFHandler, "A `wx.ImageHandler` for IFF image files.", ""); class wxIFFHandler : public wxImageHandler { @@ -1211,6 +1277,19 @@ public: }; #endif + +%{ +#include +%} + +DocStr(wxTGAHandler, +"A `wx.ImageHandler` for TGA image files.", ""); +class wxTGAHandler : public wxImageHandler { +public: + wxTGAHandler(); +}; + + //--------------------------------------------------------------------------- %{