You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
449 lines
11 KiB
449 lines
11 KiB
13 years ago
|
// This is the SIP interface definition for TQImage, TQImageIO and
|
||
|
// TQImageTextKeyLang.
|
||
13 years ago
|
//
|
||
|
// Copyright (c) 2007
|
||
|
// Riverbank Computing Limited <info@riverbankcomputing.co.uk>
|
||
|
//
|
||
13 years ago
|
// This file is part of PyTQt.
|
||
13 years ago
|
//
|
||
13 years ago
|
// This copy of PyTQt is free software; you can redistribute it and/or modify it
|
||
13 years ago
|
// 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.
|
||
|
//
|
||
13 years ago
|
// PyTQt is supplied in the hope that it will be useful, but WITHOUT ANY
|
||
13 years ago
|
// 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
|
||
13 years ago
|
// PyTQt; see the file LICENSE. If not, write to the Free Software Foundation,
|
||
13 years ago
|
// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||
|
|
||
|
|
||
|
%ExportedDoc
|
||
13 years ago
|
<Sect2><Title>TQImage</Title>
|
||
13 years ago
|
<Para>
|
||
|
The Python <Literal>==</Literal> and <Literal>!=</Literal> operators are
|
||
|
supported.
|
||
|
</Para>
|
||
|
|
||
|
<FuncSynopsis>
|
||
13 years ago
|
<FuncDef><Function>TQImage</Function></FuncDef>
|
||
13 years ago
|
<ParamDef>const char *<Parameter>xpm</Parameter>[]</ParamDef>
|
||
|
</FuncSynopsis>
|
||
|
<Para>
|
||
|
This takes a list of strings as its parameter.
|
||
|
</Para>
|
||
|
|
||
|
<FuncSynopsis>
|
||
13 years ago
|
<FuncDef><Function>TQImage</Function></FuncDef>
|
||
13 years ago
|
<ParamDef>uchar *<Parameter>data</Parameter></ParamDef>
|
||
|
<ParamDef>int <Parameter>w</Parameter></ParamDef>
|
||
|
<ParamDef>int <Parameter>h</Parameter></ParamDef>
|
||
|
<ParamDef>int <Parameter>depth</Parameter></ParamDef>
|
||
13 years ago
|
<ParamDef>TQRgb *<Parameter>colorTable</Parameter></ParamDef>
|
||
13 years ago
|
<ParamDef>int <Parameter>numColors</Parameter></ParamDef>
|
||
|
<ParamDef>Endian <Parameter>bitOrder</Parameter></ParamDef>
|
||
|
</FuncSynopsis>
|
||
|
<Para>
|
||
13 years ago
|
The <Literal>colorTable</Literal> parameter is a list of TQRgb instances or
|
||
|
None. (TQt v2.1+)
|
||
13 years ago
|
</Para>
|
||
|
|
||
|
<FuncSynopsis>
|
||
|
<FuncDef>uchar *<Function>bits</Function></FuncDef>
|
||
|
<ParamDef></ParamDef>
|
||
|
</FuncSynopsis>
|
||
|
<Para>
|
||
|
The return value is a <Literal>sip.voidptr</Literal> object which is only
|
||
|
useful if passed to another Python module.
|
||
|
</Para>
|
||
|
|
||
|
<FuncSynopsis>
|
||
13 years ago
|
<FuncDef>TQRgb *<Function>colorTable</Function></FuncDef>
|
||
13 years ago
|
<ParamDef></ParamDef>
|
||
|
</FuncSynopsis>
|
||
|
<Para>
|
||
|
The return value is a <Literal>sip.voidptr</Literal> object which is only
|
||
|
useful if passed to another Python module.
|
||
|
</Para>
|
||
|
|
||
|
<FuncSynopsis>
|
||
13 years ago
|
<FuncDef>TQImage <Function>convertDepthWithPalette</Function></FuncDef>
|
||
13 years ago
|
<ParamDef>int</ParamDef>
|
||
13 years ago
|
<ParamDef>TQRgb *<Parameter>p</Parameter></ParamDef>
|
||
13 years ago
|
<ParamDef>int <Parameter>pc</Parameter></ParamDef>
|
||
|
<ParamDef>int <Parameter>cf</Parameter> = 0</ParamDef>
|
||
|
</FuncSynopsis>
|
||
|
<Para>
|
||
|
Not implemented.
|
||
|
</Para>
|
||
|
|
||
|
<FuncSynopsis>
|
||
|
<FuncDef>uchar **<Function>jumpTable</Function></FuncDef>
|
||
|
<ParamDef></ParamDef>
|
||
|
</FuncSynopsis>
|
||
|
<Para>
|
||
|
The return value is a <Literal>sip.voidptr</Literal> object which is only
|
||
|
useful if passed to another Python module.
|
||
|
</Para>
|
||
|
|
||
|
<FuncSynopsis>
|
||
|
<FuncDef>bool <Function>loadFromData</Function></FuncDef>
|
||
|
<ParamDef>const uchar *<Parameter>buf</Parameter></ParamDef>
|
||
|
<ParamDef>uint <Parameter>len</Parameter></ParamDef>
|
||
|
<ParamDef>const char *<Parameter>format</Parameter> = 0</ParamDef>
|
||
|
<ParamDef>ColorMode <Parameter>mode</Parameter> = Auto</ParamDef>
|
||
|
</FuncSynopsis>
|
||
|
<Para>
|
||
|
<Literal>len</Literal> is derived from <Literal>buf</Literal> and not passed as
|
||
|
a parameter.
|
||
|
</Para>
|
||
|
|
||
|
<FuncSynopsis>
|
||
|
<FuncDef>uchar *<Function>scanLine</Function></FuncDef>
|
||
|
<ParamDef>int <Parameter>i</Parameter></ParamDef>
|
||
|
</FuncSynopsis>
|
||
|
<Para>
|
||
|
The return value is a <Literal>sip.voidptr</Literal> object which is only
|
||
|
useful if passed to another Python module.
|
||
|
</Para>
|
||
|
</Sect2>
|
||
|
|
||
13 years ago
|
<Sect2><Title>TQImageIO</Title>
|
||
13 years ago
|
<FuncSynopsis>
|
||
|
<FuncDef>static void <Function>defineIOHandler</Function></FuncDef>
|
||
|
<ParamDef>const char *<Parameter>format</Parameter></ParamDef>
|
||
|
<ParamDef>const char *<Parameter>header</Parameter></ParamDef>
|
||
|
<ParamDef>const char *<Parameter>flags</Parameter></ParamDef>
|
||
|
<ParamDef>image_io_handler <Parameter>read_image</Parameter></ParamDef>
|
||
|
<ParamDef>image_io_handler <Parameter>write_image</Parameter></ParamDef>
|
||
|
</FuncSynopsis>
|
||
|
<Para>
|
||
|
Not implemented.
|
||
|
</Para>
|
||
|
</Sect2>
|
||
|
|
||
13 years ago
|
<Sect2><Title>TQImageTextKeyLang</Title>
|
||
13 years ago
|
<Para>
|
||
13 years ago
|
<Literal>TQImageTextKeyLang</Literal> is fully implemented.
|
||
13 years ago
|
</Para>
|
||
|
</Sect2>
|
||
|
%End
|
||
|
|
||
|
|
||
13 years ago
|
class TQImage
|
||
13 years ago
|
{
|
||
|
%TypeHeaderCode
|
||
13 years ago
|
#include <tqimage.h>
|
||
13 years ago
|
%End
|
||
|
|
||
|
public:
|
||
|
enum Endian {
|
||
|
IgnoreEndian,
|
||
|
BigEndian,
|
||
|
LittleEndian
|
||
|
};
|
||
|
|
||
13 years ago
|
TQImage();
|
||
|
TQImage(int,int,int,int = 0,Endian = IgnoreEndian);
|
||
|
TQImage(const TQSize &,int,int = 0,Endian = IgnoreEndian);
|
||
|
TQImage(const TQString &,char * = 0);
|
||
13 years ago
|
|
||
13 years ago
|
TQImage(SIP_PYLIST) [(const char **)];
|
||
13 years ago
|
%MethodCode
|
||
|
// The Python interface is a list of strings that make up the
|
||
|
// image.
|
||
|
|
||
|
const char **str;
|
||
|
|
||
2 years ago
|
if ((str = PyTQt_tqt_ListToArray(a0)) == NULL)
|
||
13 years ago
|
sipIsErr = 1;
|
||
|
else
|
||
|
{
|
||
13 years ago
|
// There is no wrapper class for TQImage.
|
||
13 years ago
|
|
||
|
Py_BEGIN_ALLOW_THREADS
|
||
13 years ago
|
sipCpp = new TQImage(str);
|
||
13 years ago
|
Py_END_ALLOW_THREADS
|
||
|
|
||
12 years ago
|
sipFree((void *)str);
|
||
13 years ago
|
}
|
||
|
%End
|
||
|
|
||
13 years ago
|
TQImage(const TQByteArray &);
|
||
13 years ago
|
|
||
13 years ago
|
TQImage(uchar *,int,int,int,SIP_PYLIST /AllowNone/,int,Endian) [(uchar *,int,int,int,int,TQRgb *,int,Endian)];
|
||
13 years ago
|
%MethodCode
|
||
13 years ago
|
// The Python interface takes a list of TQRgb instances.
|
||
13 years ago
|
|
||
13 years ago
|
TQRgb *coltab;
|
||
13 years ago
|
|
||
|
if (a4 == Py_None)
|
||
|
coltab = 0;
|
||
|
else
|
||
|
{
|
||
|
int len = PyList_Size(a4);
|
||
|
|
||
|
if (a5 > len)
|
||
|
a5 = len;
|
||
|
|
||
13 years ago
|
coltab = new TQRgb[len];
|
||
13 years ago
|
|
||
|
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)
|
||
|
{
|
||
13 years ago
|
// There is no wrapper class for TQImage.
|
||
13 years ago
|
|
||
|
Py_BEGIN_ALLOW_THREADS
|
||
13 years ago
|
sipCpp = new TQImage(a0,a1,a2,a3,0,a5,(TQImage::Endian)a6);
|
||
13 years ago
|
|
||
|
if (coltab)
|
||
|
{
|
||
13 years ago
|
// Now set the colours using the TQImage's self
|
||
13 years ago
|
// 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
|
||
|
|
||
13 years ago
|
TQImage(const TQImage &);
|
||
13 years ago
|
|
||
13 years ago
|
bool operator==(const TQImage &) const;
|
||
|
bool operator!=(const TQImage &) const;
|
||
13 years ago
|
|
||
|
void detach();
|
||
13 years ago
|
TQImage copy() const;
|
||
|
TQImage copy(int,int,int,int,int = 0) const;
|
||
|
TQImage copy(const TQRect &) const;
|
||
|
static TQImage fromMimeSource(const TQString &);
|
||
13 years ago
|
bool isNull() const;
|
||
|
|
||
|
int width() const;
|
||
|
int height() const;
|
||
13 years ago
|
TQSize size() const;
|
||
|
TQRect rect() const;
|
||
13 years ago
|
int depth() const;
|
||
|
int numColors() const;
|
||
|
Endian bitOrder() const;
|
||
|
|
||
13 years ago
|
TQRgb color(int) const;
|
||
|
void setColor(int,TQRgb);
|
||
13 years ago
|
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;
|
||
13 years ago
|
// Actually returns TQRgb *.
|
||
13 years ago
|
void *colorTable() const;
|
||
|
int numBytes() const;
|
||
|
int bytesPerLine() const;
|
||
|
|
||
|
bool create(int,int,int,int = 0,Endian = IgnoreEndian);
|
||
13 years ago
|
bool create(const TQSize &,int,int = 0,Endian = IgnoreEndian);
|
||
13 years ago
|
void reset();
|
||
|
|
||
|
void fill(uint);
|
||
|
void invertPixels(bool = 1);
|
||
|
|
||
13 years ago
|
TQImage convertDepth(int) const;
|
||
|
// TQImage convertDepthWithPalette(int,TQRgb *,int,int = 0) const;
|
||
|
TQImage convertDepth(int,int) const;
|
||
|
TQImage convertBitOrder(Endian) const;
|
||
13 years ago
|
|
||
|
enum ScaleMode {
|
||
|
ScaleFree,
|
||
|
ScaleMin,
|
||
|
ScaleMax
|
||
|
};
|
||
|
|
||
13 years ago
|
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;
|
||
13 years ago
|
|
||
13 years ago
|
TQImage createAlphaMask(int = 0) const;
|
||
|
TQImage createHeuristicMask(bool = 1) const;
|
||
|
TQImage mirror() const;
|
||
|
TQImage mirror(bool,bool) const;
|
||
|
TQImage swapRGB() const;
|
||
13 years ago
|
|
||
|
static Endian systemBitOrder();
|
||
|
static Endian systemByteOrder();
|
||
|
|
||
13 years ago
|
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);
|
||
13 years ago
|
bool loadFromData(const uchar * /Array/,uint /ArraySize/,
|
||
|
const char * = 0);
|
||
13 years ago
|
bool loadFromData(TQByteArray,char * = 0);
|
||
|
bool save(const TQString &,const char *,int = -1) const;
|
||
|
bool save(TQIODevice *,const char *,int = -1) const;
|
||
13 years ago
|
|
||
|
bool valid(int,int) const;
|
||
|
int pixelIndex(int,int) const;
|
||
13 years ago
|
TQRgb pixel(int,int) const;
|
||
13 years ago
|
void setPixel(int,int,uint);
|
||
|
|
||
|
int dotsPerMeterX() const;
|
||
|
int dotsPerMeterY() const;
|
||
|
void setDotsPerMeterX(int);
|
||
|
void setDotsPerMeterY(int);
|
||
13 years ago
|
TQPoint offset() const;
|
||
|
void setOffset(const TQPoint &);
|
||
|
%If (TQt_IMAGE_TEXT)
|
||
|
TQValueList<TQImageTextKeyLang> 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 &);
|
||
13 years ago
|
%End
|
||
|
};
|
||
|
|
||
|
|
||
13 years ago
|
void bitBlt(TQImage *,int,int,const TQImage *,int = 0,int = 0,int = -1,int = -1,
|
||
13 years ago
|
int = 0);
|
||
|
|
||
|
|
||
13 years ago
|
class TQImageIO
|
||
13 years ago
|
{
|
||
|
%TypeHeaderCode
|
||
13 years ago
|
#include <tqimage.h>
|
||
13 years ago
|
%End
|
||
|
|
||
|
public:
|
||
13 years ago
|
TQImageIO();
|
||
|
TQImageIO(TQIODevice *,const char *);
|
||
|
TQImageIO(const TQString &,const char *);
|
||
13 years ago
|
|
||
13 years ago
|
const TQImage &image() const;
|
||
13 years ago
|
int status() const;
|
||
|
const char *format() const;
|
||
13 years ago
|
TQIODevice *ioDevice() const;
|
||
|
TQString fileName() const;
|
||
13 years ago
|
int quality() const;
|
||
13 years ago
|
TQString description() const;
|
||
13 years ago
|
const char *parameters() const;
|
||
|
float gamma() const;
|
||
|
|
||
13 years ago
|
void setImage(const TQImage &);
|
||
13 years ago
|
void setStatus(int);
|
||
|
void setFormat(const char *);
|
||
13 years ago
|
void setIODevice(TQIODevice *);
|
||
|
void setFileName(const TQString &);
|
||
13 years ago
|
void setQuality(int);
|
||
13 years ago
|
void setDescription(const TQString &);
|
||
13 years ago
|
void setParameters(const char *);
|
||
|
void setGamma(float);
|
||
|
|
||
|
bool read();
|
||
|
bool write();
|
||
|
|
||
13 years ago
|
static const char *imageFormat(const TQString &);
|
||
|
static const char *imageFormat(TQIODevice *);
|
||
|
static TQStrList inputFormats();
|
||
|
static TQStrList outputFormats();
|
||
13 years ago
|
|
||
|
// static void defineIOHandler(const char *,const char *,const char *,
|
||
|
// image_io_handler,image_io_handler);
|
||
|
|
||
|
private:
|
||
13 years ago
|
TQImageIO(const TQImageIO &);
|
||
13 years ago
|
};
|
||
|
|
||
|
|
||
13 years ago
|
%If (TQt_IMAGE_TEXT)
|
||
13 years ago
|
|
||
13 years ago
|
class TQImageTextKeyLang
|
||
13 years ago
|
{
|
||
|
%TypeHeaderCode
|
||
13 years ago
|
#include <tqimage.h>
|
||
13 years ago
|
%End
|
||
|
|
||
|
public:
|
||
13 years ago
|
TQImageTextKeyLang(const char *,const char *);
|
||
|
TQImageTextKeyLang();
|
||
13 years ago
|
|
||
13 years ago
|
TQCString key;
|
||
|
TQCString lang;
|
||
13 years ago
|
};
|
||
|
|
||
|
%End
|
||
|
|
||
|
|
||
|
%ModuleHeaderCode
|
||
2 years ago
|
const char **PyTQt_tqt_ListToArray(PyObject *lst);
|
||
13 years ago
|
%End
|
||
|
|
||
|
|
||
|
%ModuleCode
|
||
|
// Convert a list of strings to an array of strings on the heap. Also used by
|
||
13 years ago
|
// TQPixmap.
|
||
2 years ago
|
const char **PyTQt_tqt_ListToArray(PyObject *lst)
|
||
13 years ago
|
{
|
||
3 years ago
|
SIP_SSIZE_T nstr;
|
||
13 years ago
|
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)
|
||
|
{
|
||
3 years ago
|
PyObject *item = PyList_GetItem(lst, i);
|
||
2 years ago
|
const char *item_utf8 = sipString_AsUTF8String(&item);
|
||
13 years ago
|
|
||
2 years ago
|
if (item_utf8 == NULL)
|
||
13 years ago
|
{
|
||
12 years ago
|
sipFree((void *)str);
|
||
13 years ago
|
return NULL;
|
||
|
}
|
||
|
|
||
2 years ago
|
*sp++ = item_utf8;
|
||
13 years ago
|
}
|
||
|
|
||
|
return str;
|
||
|
}
|
||
|
%End
|