867 if (cpp < 0 || cpp > 15)
885 bool hasTransparency =
false;
887 for(currentColor=0; currentColor < ncols; ++currentColor) {
889 qWarning(
"QImage: XPM color specification missing");
893 index = buf.
left(cpp);
904 qWarning(
"QImage: XPM color specification is missing: %s", buf.constData());
912 qWarning(
"QImage: XPM color value is missing from specification: %s", buf.constData());
917 hasTransparency =
true;
918 int transparentColor = currentColor;
920 image.
setColor(transparentColor, 0);
927 if (((buf.length()-1) % 3) && (buf[0] ==
'#')) {
928 buf.truncate(((buf.length()-1) / 4 * 3) + 1);
936 image.
setColor(currentColor, 0xff000000 | c_rgb);
949 image =
QImage(w, h, format);
956 for(
int y=0; y<h; y++) {
958 qWarning(
"QImage: XPM pixels missing on image line %d", y);
961 if (image.
depth() == 8) {
969 for (x=0; x<w && d<
end; x++) {
976 for (x=0; x<w && d<
end; x++) {
977 memcpy(b, (
char *)d, cpp);
984 qWarning(
"QImage: XPM pixels missing on image line %d (possibly a C++ trigraph).", y);
990 uchar *end = d + buf.length();
994 for (x=0; x<w && d<
end; x++) {
995 memcpy(b, (
char *)d, cpp);
1001 qWarning(
"QImage: XPM pixels missing on image line %d (possibly a C++ trigraph).", y);
1002 memset(p, 0, (w - x)*4);
1009 for (
int i = state.
size() - 1; i >= 0; --i)
1012 while (device->
getChar(&c) && c !=
';') {}
1013 while (device->
getChar(&c) && c !=
'\n') {}
Format
The following image formats are available in Qt.
static bool qt_get_named_xpm_rgb(const char *name_no_space, QRgb *rgb)
void setColor(int i, QRgb c)
Sets the color at the given index in the color table, to the given to colorValue. ...
QByteArray & append(char c)
Appends the character ch to this byte array.
bool isNull() const
Returns true if it is a null image, otherwise returns false.
The QByteArray class provides an array of bytes.
bool getChar(char *c)
Reads one character from the device and stores it in c.
QByteArray toLower() const
Returns a lowercase copy of the byte array.
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
void ungetChar(char c)
Puts the character c back into the device, and decrements the current position unless the position is...
Format format() const
Returns the format of the image.
QByteArray simplified() const
Returns a byte array that has whitespace removed from the start and the end, and which has each seque...
void setColorCount(int)
Resizes the color table to contain colorCount entries.
static bool is_xpm_color_spec_prefix(const QByteArray &prefix)
QByteArray trimmed() const
Returns a byte array that has whitespace removed from the start and the end.
const T & at(int i) const
Returns the item at index position i in the list.
Q_CORE_EXPORT void qWarning(const char *,...)
The QImage class provides a hardware-independent image representation that allows direct access to th...
int depth() const
Returns the depth of the image.
QByteArray left(int len) const
Returns a byte array that contains the leftmost len bytes of this byte array.
QByteArray mid(int index, int len=-1) const
Returns a byte array containing len bytes from this byte array, starting at position pos...
QSize size() const
Returns the size of the image, i.
const char * constData() const
Returns a pointer to the data stored in the byte array.
int indexOf(const T &t, int from=0) const
Returns the index position of the first occurrence of value in the list, searching forward from index...
iterator insert(const Key &key, const T &value)
Inserts a new item with the key key and a value of value.
int size() const
Returns the number of items in the list.
QRgb
An ARGB quadruplet on the format #AARRGGBB, equivalent to an unsigned int.
int size() const
Returns the number of bytes in this byte array.
bool isEmpty() const
Returns true if the byte array has size 0; otherwise returns false.
The QSize class defines the size of a two-dimensional object using integer point precision.
static const KeyPair *const end
static bool read_xpm_string(QByteArray &buf, QIODevice *d, const char *const *source, int &index, QByteArray &state)
bool qt_get_hex_rgb(const char *name, QRgb *rgb)
uchar * scanLine(int)
Returns a pointer to the pixel data at the scanline with index i.
The QMap class is a template class that provides a skip-list-based dictionary.
static quint64 xpmHash(const QString &str)