// This is the SIP interface definition for TQImage, TQImageIO and // TQImageTextKeyLang. // // Copyright (c) 2007 // Riverbank Computing Limited // // This file is part of PyTQt. // // This copy of PyTQt is free software; you can redistribute it and/or modify it // under the terms of the GNU General Public License as published by the Free // Software Foundation; either version 2, or (at your option) any later // version. // // PyTQt is supplied in the hope that it will be useful, but WITHOUT ANY // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS // FOR A PARTICULAR PURPOSE. See the GNU General Public License for more // details. // // You should have received a copy of the GNU General Public License along with // PyTQt; see the file LICENSE. If not, write to the Free Software Foundation, // Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. %ExportedDoc TQImage The Python == and != operators are supported. TQImage const char *xpm[] This takes a list of strings as its parameter. TQImage uchar *data int w int h int depth TQRgb *colorTable int numColors Endian bitOrder The colorTable parameter is a list of TQRgb instances or None. (TQt v2.1+) uchar *bits The return value is a sip.voidptr object which is only useful if passed to another Python module. TQRgb *colorTable The return value is a sip.voidptr object which is only useful if passed to another Python module. TQImage convertDepthWithPalette int TQRgb *p int pc int cf = 0 Not implemented. uchar **jumpTable The return value is a sip.voidptr object which is only useful if passed to another Python module. bool loadFromData const uchar *buf uint len const char *format = 0 ColorMode mode = Auto len is derived from buf and not passed as a parameter. uchar *scanLine int i The return value is a sip.voidptr object which is only useful if passed to another Python module. TQImageIO static void defineIOHandler const char *format const char *header const char *flags image_io_handler read_image image_io_handler write_image Not implemented. TQImageTextKeyLang TQImageTextKeyLang is fully implemented. %End class TQImage { %TypeHeaderCode #include %End public: enum Endian { IgnoreEndian, BigEndian, LittleEndian }; TQImage(); TQImage(int,int,int,int = 0,Endian = IgnoreEndian); TQImage(const TQSize &,int,int = 0,Endian = IgnoreEndian); TQImage(const TQString &,char * = 0); TQImage(SIP_PYLIST) [(const char **)]; %MethodCode // The Python interface is a list of strings that make up the // image. const char **str; if ((str = PyTQt_tqt_ListToArray(a0)) == NULL) sipIsErr = 1; else { // There is no wrapper class for TQImage. Py_BEGIN_ALLOW_THREADS sipCpp = new TQImage(str); Py_END_ALLOW_THREADS sipFree((void *)str); } %End TQImage(const TQByteArray &); TQImage(uchar *,int,int,int,SIP_PYLIST /AllowNone/,int,Endian) [(uchar *,int,int,int,int,TQRgb *,int,Endian)]; %MethodCode // The Python interface takes a list of TQRgb instances. TQRgb *coltab; if (a4 == Py_None) coltab = 0; else { int len = PyList_Size(a4); if (a5 > len) a5 = len; coltab = new TQRgb[len]; PyErr_Clear(); for (int i = 0; i < a5; ++i) { coltab[i] = PyLong_AsUnsignedLong(PyList_GetItem(a4,i)); if (PyErr_Occurred()) { delete[] coltab; sipIsErr = 1; break; } } } if (!sipIsErr) { // There is no wrapper class for TQImage. Py_BEGIN_ALLOW_THREADS sipCpp = new TQImage(a0,a1,a2,a3,0,a5,(TQImage::Endian)a6); if (coltab) { // Now set the colours using the TQImage's self // allocated colour table. If we had passed in // coltab as the colour table then we couldn't // have freed it and it would leak. for (int i = 0; i < a5; ++i) sipCpp -> setColor(i,coltab[i]); delete[] coltab; } Py_END_ALLOW_THREADS } %End TQImage(const TQImage &); bool operator==(const TQImage &) const; bool operator!=(const TQImage &) const; void detach(); TQImage copy() const; TQImage copy(int,int,int,int,int = 0) const; TQImage copy(const TQRect &) const; static TQImage fromMimeSource(const TQString &); bool isNull() const; int width() const; int height() const; TQSize size() const; TQRect rect() const; int depth() const; int numColors() const; Endian bitOrder() const; TQRgb color(int) const; void setColor(int,TQRgb); void setNumColors(int); bool hasAlphaBuffer() const; void setAlphaBuffer(bool); bool allGray() const; bool isGrayscale() const; // Actually returns uchar *. void *bits() const; // Actually returns uchar *. void *scanLine(int) const; // Actually returns uchar **. void *jumpTable() const; // Actually returns TQRgb *. void *colorTable() const; int numBytes() const; int bytesPerLine() const; bool create(int,int,int,int = 0,Endian = IgnoreEndian); bool create(const TQSize &,int,int = 0,Endian = IgnoreEndian); void reset(); void fill(uint); void invertPixels(bool = 1); TQImage convertDepth(int) const; // TQImage convertDepthWithPalette(int,TQRgb *,int,int = 0) const; TQImage convertDepth(int,int) const; TQImage convertBitOrder(Endian) const; enum ScaleMode { ScaleFree, ScaleMin, ScaleMax }; TQImage smoothScale(int,int,ScaleMode = ScaleFree) const; TQImage smoothScale(const TQSize &,ScaleMode = ScaleFree) const; TQImage scale(int,int,ScaleMode = ScaleFree) const; TQImage scale(const TQSize &,ScaleMode = ScaleFree) const; TQImage scaleWidth(int) const; TQImage scaleHeight(int) const; TQImage xForm(const TQWMatrix &) const; TQImage createAlphaMask(int = 0) const; TQImage createHeuristicMask(bool = 1) const; TQImage mirror() const; TQImage mirror(bool,bool) const; TQImage swapRGB() const; static Endian systemBitOrder(); static Endian systemByteOrder(); static const char *imageFormat(const TQString &); static TQStrList inputFormats(); static TQStrList outputFormats(); static TQStringList inputFormatList(); static TQStringList outputFormatList(); bool load(const TQString &,const char * = 0); bool loadFromData(const uchar * /Array/,uint /ArraySize/, const char * = 0); bool loadFromData(TQByteArray,char * = 0); bool save(const TQString &,const char *,int = -1) const; bool save(TQIODevice *,const char *,int = -1) const; bool valid(int,int) const; int pixelIndex(int,int) const; TQRgb pixel(int,int) const; void setPixel(int,int,uint); int dotsPerMeterX() const; int dotsPerMeterY() const; void setDotsPerMeterX(int); void setDotsPerMeterY(int); TQPoint offset() const; void setOffset(const TQPoint &); %If (TQt_IMAGE_TEXT) TQValueList textList() const; TQStringList textLanguages() const; TQStringList textKeys() const; TQString text(const char *,const char * = 0) const; TQString text(const TQImageTextKeyLang &) const; void setText(const char *,const char *,const TQString &); %End }; void bitBlt(TQImage *,int,int,const TQImage *,int = 0,int = 0,int = -1,int = -1, int = 0); class TQImageIO { %TypeHeaderCode #include %End public: TQImageIO(); TQImageIO(TQIODevice *,const char *); TQImageIO(const TQString &,const char *); const TQImage &image() const; int status() const; const char *format() const; TQIODevice *ioDevice() const; TQString fileName() const; int quality() const; TQString description() const; const char *parameters() const; float gamma() const; void setImage(const TQImage &); void setStatus(int); void setFormat(const char *); void setIODevice(TQIODevice *); void setFileName(const TQString &); void setQuality(int); void setDescription(const TQString &); void setParameters(const char *); void setGamma(float); bool read(); bool write(); static const char *imageFormat(const TQString &); static const char *imageFormat(TQIODevice *); static TQStrList inputFormats(); static TQStrList outputFormats(); // static void defineIOHandler(const char *,const char *,const char *, // image_io_handler,image_io_handler); private: TQImageIO(const TQImageIO &); }; %If (TQt_IMAGE_TEXT) class TQImageTextKeyLang { %TypeHeaderCode #include %End public: TQImageTextKeyLang(const char *,const char *); TQImageTextKeyLang(); TQCString key; TQCString lang; }; %End %ModuleHeaderCode const char **PyTQt_tqt_ListToArray(PyObject *lst); %End %ModuleCode // Convert a list of strings to an array of strings on the heap. Also used by // TQPixmap. const char **PyTQt_tqt_ListToArray(PyObject *lst) { SIP_SSIZE_T nstr; const char **str, **sp; nstr = PyList_Size(lst); if ((str = (const char **)sipMalloc(nstr * sizeof (char *))) == NULL) return NULL; // Convert the list. sp = str; for (int i = 0; i < nstr; ++i) { PyObject *item = PyList_GetItem(lst, i); const char *item_utf8 = sipString_AsUTF8String(&item); if (item_utf8 == NULL) { sipFree((void *)str); return NULL; } *sp++ = item_utf8; } return str; } %End