• 12138阅读
  • 0回复

QPixmap::loadFromData [复制链接]

上一主题 下一主题
离线keisuo
 

只看楼主 倒序阅读 楼主  发表于: 2007-05-11
— 本帖被 XChinux 执行加亮操作(2008-07-19) —
/.QPixmap::loadFromData 里面的 QByteArray & data 是个什么东西呢
bool QPixmap::loadFromData ( const QByteArray & data, const char * format = 0, Qt::ImageConver sionFlags flags = Qt::AutoColor )

我在Qt程序里读入了一个Qt不支持的图片,pics格式。现在已经可以用程序读入内存。用QImage的setPixel 的时候,读入图片的速度比较慢。所以在寻求其他的方法。

看到前面大家讨论说可以直接读buffer, 我想这个方法可能可以吧。

所以想问问这个QByteArray & data是什么呢,该怎么用阿。
2.Ups:  The loadFromData function has a problem with my type:

  File "radar.py", line 116, in rxUpdatePicture
    x.loadFromData( str(data), int(count) )
TypeError: Argument 2 of QPixmap.loadFromData() has an invalid type

loadFromData is an overloaded member
bool loadFromData ( const uchar * buf, uint len, const char * format = 0, ColorMode mode = Auto )
bool loadFromData ( const uchar * buf, uint len, const char * format, int conversion_flags )
bool loadFromData ( const QByteArray & buf, const char * format = 0, int conversion_flags = 0 )

I would like to use the (const uchar*, uint, 0, Auto) one. How can I do
proper type conversion with pyQt or do I have to write my own interface
to perform this job ?

BYE INGO
3.bool loadFromData (self, str buf, str format = None, Qt.ImageConversionFlags flags = Qt.AutoColor)
bool loadFromData (self, QByteArray buf, str format = None, Qt.ImageConversionFlags flags = Qt.AutoColor)
bool QPixmap.loadFromData (self, str buf, str format = None, Qt.ImageConversionFlags flags = Qt.AutoColor)
Loads a pixmap from the len first bytes of the given binary data. Returns true if the pixmap was loaded successfully; otherwise returns false.

The loader attempts to read the pixmap using the specified format. If the format is not specified (which is the default), the loader probes the file for a header to guess the file format.

If the data needs to be modified to fit in a lower-resolution result (e.g. converting from 32-bit to 8-bit), use the flags to control the conversion.

See also load() and Reading and Writing Image Files.

bool QPixmap.loadFromData (self, QByteArray buf, str format = None, Qt.ImageConversionFlags flags = Qt.AutoColor)
This is an overloaded member function, provided for convenience.

Use the loadFromData() function that takes a Qt.ImageConversionFlag instead.
4.bool QPixmap::loadFromData ( const uchar * buf, uint len, const char * format, int conversion_flags )
Loads a pixmap from the binary data in buf (len bytes). Returns TRUE if successful; otherwise returns FALSE.
If format is specified, the loader attempts to read the pixmap using the specified format. If format is not specified (default), the loader reads a few bytes from the header to guess the file's format.
See the convertFromImage() documentation for a description of the conversion_flags argument.
The QImageIO documentation lists the supported image formats and explains how to add extra formats.
See also load(), save(), imageFormat(), QImage::loadFromData(), and QImageIO.
bool QPixmap::loadFromData ( const uchar * buf, uint len, const char * format = 0, ColorMode mode = Auto )
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
Loads a pixmap from the binary data in buf (len bytes) using color mode mode. Returns TRUE if successful; otherwise returns FALSE.
If format is specified, the loader attempts to read the pixmap using the specified format. If format is not specified (default), the loader reads a few bytes from the header to guess the file's format.
See also QPixmap::ColorMode.
bool QPixmap::loadFromData ( const QByteArray & buf, const char * format = 0, int conversion_flags = 0 )
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
[ 此贴被XChinux在2008-07-19 20:17重新编辑 ]
快速回复
限100 字节
 
上一个 下一个