// This is the SIP interface definition for QImage, QImageIO and // QImageTextKeyLang. // // Copyright (c) 2007 // Riverbank Computing Limited // // This file is part of PyQt. // // This copy of PyQt 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. // // PyQt 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 // PyQt; see the file LICENSE. If not, write to the Free Software Foundation, // Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. %ExportedDoc QImage The Python == and != operators are supported. QImage const char *xpm[] This takes a list of strings as its parameter. QImage uchar *data int w int h int depth QRgb *colorTable int numColors Endian bitOrder The colorTable parameter is a list of QRgb instances or None. (Qt v2.1+) uchar *bits The return value is a sip.voidptr object which is only useful if passed to another Python module. QRgb *colorTable The return value is a sip.voidptr object which is only useful if passed to another Python module. QImage convertDepthWithPalette int QRgb *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. QImageIO static void defineIOHandler const char *format const char *header const char *flags image_io_handler read_image image_io_handler write_image Not implemented. QImageTextKeyLang QImageTextKeyLang is fully implemented. %End class QImage { %TypeHeaderCode #include %End public: enum Endian { IgnoreEndian, BigEndian, LittleEndian }; QImage(); QImage(int,int,int,int = 0,Endian = IgnoreEndian); QImage(const QSize &,int,int = 0,Endian = IgnoreEndian); %If (- Qt_2_00) QImage(const char *,char * = 0); %End %If (Qt_2_00 -) QImage(const QString &,char * = 0); %End QImage(SIP_PYLIST) [(const char **)]; %MethodCode // The Python interface is a list of strings that make up the // image. const char **str; if ((str = PyQt_qt_ListToArray(a0)) == NULL) sipIsErr = 1; else { // There is no wrapper class for QImage. Py_BEGIN_ALLOW_THREADS sipCpp = new QImage(str); Py_END_ALLOW_THREADS sipFree((ANY *)str); } %End %If (Qt_2_00 -) QImage(const QByteArray &); %End %If (Qt_2_1_0 -) QImage(uchar *,int,int,int,SIP_PYLIST /AllowNone/,int,Endian) [(uchar *,int,int,int,int,QRgb *,int,Endian)]; %MethodCode // The Python interface takes a list of QRgb instances. QRgb *coltab; if (a4 == Py_None) coltab = 0; else { int len = PyList_Size(a4); if (a5 > len) a5 = len; coltab = new QRgb[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 QImage. Py_BEGIN_ALLOW_THREADS sipCpp = new QImage(a0,a1,a2,a3,0,a5,(QImage::Endian)a6); if (coltab) { // Now set the colours using the QImage'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 %End QImage(const QImage &); bool operator==(const QImage &) const; bool operator!=(const QImage &) const; void detach(); QImage copy() const; QImage copy(int,int,int,int,int = 0) const; %If (- Qt_3_0_0) QImage copy(QRect &) const; %End %If (Qt_3_0_0 -) QImage copy(const QRect &) const; %End %If (Qt_3_1_0 -) static QImage fromMimeSource(const QString &); %End bool isNull() const; int width() const; int height() const; QSize size() const; QRect rect() const; int depth() const; int numColors() const; Endian bitOrder() const; QRgb color(int) const; void setColor(int,QRgb); 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 QRgb *. void *colorTable() const; int numBytes() const; int bytesPerLine() const; bool create(int,int,int,int = 0,Endian = IgnoreEndian); bool create(const QSize &,int,int = 0,Endian = IgnoreEndian); void reset(); void fill(uint); %If (Qt_2_00 -) void invertPixels(bool = 1); %End QImage convertDepth(int) const; // QImage convertDepthWithPalette(int,QRgb *,int,int = 0) const; QImage convertDepth(int,int) const; QImage convertBitOrder(Endian) const; %If (- Qt_3_0_0) QImage smoothScale(int,int) const; %End %If (Qt_3_0_0 -) enum ScaleMode { ScaleFree, ScaleMin, ScaleMax }; QImage smoothScale(int,int,ScaleMode = ScaleFree) const; QImage smoothScale(const QSize &,ScaleMode = ScaleFree) const; QImage scale(int,int,ScaleMode = ScaleFree) const; QImage scale(const QSize &,ScaleMode = ScaleFree) const; QImage scaleWidth(int) const; QImage scaleHeight(int) const; QImage xForm(const QWMatrix &) const; %End %If (- Qt_2_00) QImage createAlphaMask(bool = 0) const; QImage createAlphaMask(int) const; %End %If (Qt_2_00 -) QImage createAlphaMask(int = 0) const; %End QImage createHeuristicMask(bool = 1) const; %If (Qt_2_00 -) QImage mirror() const; %End %If (Qt_2_1_0 -) QImage mirror(bool,bool) const; %End %If (Qt_2_00 -) QImage swapRGB() const; %End static Endian systemBitOrder(); static Endian systemByteOrder(); %If (- Qt_2_00) static const char *imageFormat(const char *); %End %If (Qt_2_00 -) static const char *imageFormat(const QString &); %End static QStrList inputFormats(); static QStrList outputFormats(); %If (Qt_2_1_0 -) static QStringList inputFormatList(); static QStringList outputFormatList(); %End %If (- Qt_2_00) bool load(const char *,const char * = 0); %End %If (Qt_2_00 -) bool load(const QString &,const char * = 0); %End bool loadFromData(const uchar * /Array/,uint /ArraySize/, const char * = 0); bool loadFromData(QByteArray,char * = 0); %If (- Qt_2_00) bool save(const char *,const char *) const; %End %If (Qt_2_00 - Qt_3_0_0) bool save(const QString &,const char *) const; %End %If (Qt_2_2_0 - Qt_3_0_0) bool save(const QString &,const char *,int) const; %End %If (Qt_3_0_0 -) bool save(const QString &,const char *,int = -1) const; %End %If (Qt_3_2_0 -) bool save(QIODevice *,const char *,int = -1) const; %End bool valid(int,int) const; int pixelIndex(int,int) const; QRgb pixel(int,int) const; void setPixel(int,int,uint); %If (Qt_2_1_0 -) int dotsPerMeterX() const; int dotsPerMeterY() const; void setDotsPerMeterX(int); void setDotsPerMeterY(int); QPoint offset() const; void setOffset(const QPoint &); %If (Qt_IMAGE_TEXT) QValueList textList() const; QStringList textLanguages() const; QStringList textKeys() const; QString text(const char *,const char * = 0) const; QString text(const QImageTextKeyLang &) const; void setText(const char *,const char *,const QString &); %End %End }; void bitBlt(QImage *,int,int,const QImage *,int = 0,int = 0,int = -1,int = -1, int = 0); class QImageIO { %TypeHeaderCode #include %End public: QImageIO(); QImageIO(QIODevice *,const char *); %If (Qt_2_00 -) QImageIO(const QString &,const char *); %End %If (- Qt_2_00) QImageIO(const char *,const char *); %End const QImage &image() const; int status() const; const char *format() const; QIODevice *ioDevice() const; %If (Qt_2_00 -) QString fileName() const; %End %If (- Qt_2_00) const char *fileName() const; %End %If (Qt_3_0_0 -) int quality() const; %End %If (Qt_2_00 -) QString description() const; %End %If (- Qt_2_00) const char *description() const; %End const char *parameters() const; %If (Qt_3_0_0 -) float gamma() const; %End void setImage(const QImage &); void setStatus(int); void setFormat(const char *); void setIODevice(QIODevice *); %If (Qt_2_00 -) void setFileName(const QString &); %End %If (- Qt_2_00) void setFileName(const char *); %End %If (Qt_3_0_0 -) void setQuality(int); %End %If (Qt_2_00 -) void setDescription(const QString &); %End %If (- Qt_2_00) void setDescription(const char *); %End void setParameters(const char *); %If (Qt_3_0_0 -) void setGamma(float); %End bool read(); bool write(); static const char *imageFormat(const QString &); static const char *imageFormat(QIODevice *); static QStrList inputFormats(); static QStrList outputFormats(); // static void defineIOHandler(const char *,const char *,const char *, // image_io_handler,image_io_handler); private: QImageIO(const QImageIO &); }; %If (Qt_2_1_0 -) %If (Qt_IMAGE_TEXT) class QImageTextKeyLang { %TypeHeaderCode #include %End public: QImageTextKeyLang(const char *,const char *); QImageTextKeyLang(); QCString key; QCString lang; }; %End %End %ModuleHeaderCode const char **PyQt_qt_ListToArray(PyObject *lst); %End %ModuleCode // Convert a list of strings to an array of strings on the heap. Also used by // QPixmap. const char **PyQt_qt_ListToArray(PyObject *lst) { int 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) { char *s; if ((s = PyString_AsString(PyList_GetItem(lst,i))) == NULL) { sipFree((ANY *)str); return NULL; } *sp++ = s; } return str; } %End