42 #include <qplatformdefs.h> 43 #include "private/qxbmhandler_p.h" 45 #ifndef QT_NO_IMAGEFORMAT_XBM 62 return ((isdigit((
uchar) *p) ? *p -
'0' : toupper((
uchar) *p) -
'A' + 10) << 4) |
63 (isdigit((
uchar) *(p+1)) ? *(p+1) -
'0' : toupper((
uchar) *(p+1)) -
'A' + 10);
68 const int buflen = 300;
69 const int maxlen = 4096;
80 while (buf[0] !=
'#') {
81 readBytes = device->
readLine(buf, buflen);
84 if (readBytes <= 0 || readBytes >= buflen -1)
89 totalReadBytes += readBytes;
90 if (totalReadBytes >= maxlen)
94 buf[readBytes - 1] =
'\0';
104 readBytes = device->
readLine(buf, buflen);
107 buf[readBytes - 1] =
'\0';
116 if (w <= 0 || w > 32767 || h <= 0 || h > 32767)
124 const int buflen = 300;
125 char buf[buflen + 1];
131 if ((readBytes = device->
readLine(buf, buflen)) <= 0) {
136 buf[readBytes] =
'\0';
160 if (++x == w && ++y < h) {
166 if ((readBytes = device->
readLine(buf,buflen)) <= 0)
185 QImage image = sourceImage;
186 int w = image.
width();
190 int msize = s.
length() + 100;
191 char *buf =
new char[msize];
207 for (i=10; i<16; i++)
208 hexrep[i] =
'a' -10 + i;
211 for (i=0; i<8; i++) {
213 hexrep[15-i] = hexrep[i];
218 register char *p = buf;
220 for (
int y = 0; y < h; ++y) {
222 for (i = 0; i < bpl; ++i) {
223 *p++ =
'0'; *p++ =
'x';
224 *p++ = hexrep[*b >> 4];
225 *p++ = hexrep[*b++ & 0xf];
227 if (i < bpl - 1 || y < h - 1) {
243 #if defined(_MSC_VER) && _MSC_VER >= 1400 244 strcpy_s(p,
sizeof(
" };\n"),
" };\n");
296 device->
seek(oldPos);
327 return option ==
Name 334 if (option ==
Name) {
336 }
else if (option ==
Size) {
361 #endif // QT_NO_IMAGEFORMAT_XBM The QVariant class acts like a union for the most common Qt data types.
void setFormat(const QByteArray &format)
Sets the format of the QImageIOHandler to format.
void setColor(int i, QRgb c)
Sets the color at the given index in the color table, to the given to colorValue. ...
#define QT_END_NAMESPACE
This macro expands to.
char * data()
Returns a pointer to the data stored in the byte array.
The QRegExp class provides pattern matching using regular expressions.
int toInt(bool *ok=0, int base=10) const
Returns the string converted to an int using base base, which is 10 by default and must be between 2 ...
static int hex2byte(register char *p)
bool isNull() const
Returns true if it is a null image, otherwise returns false.
The QByteArray class provides an array of bytes.
int length() const
Returns the number of characters in this string.
virtual qint64 pos() const
For random-access devices, this function returns the position that data is written to or read from...
QString toString() const
Returns the variant as a QString if the variant has type() String , Bool , ByteArray ...
int matchedLength() const
Returns the length of the last matched string, or -1 if there was no match.
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
The QString class provides a Unicode character string.
static bool read_xbm_body(QIODevice *device, int w, int h, QImage *outImage)
void setOption(ImageOption option, const QVariant &value)
Sets the option option with the value value.
Format format() const
Returns the format of the image.
static bool read_xbm_image(QIODevice *device, QImage *outImage)
bool write(const QImage &image)
Writes the image image to the assigned device.
static bool read_xbm_header(QIODevice *device, int &w, int &h)
void setColorCount(int)
Resizes the color table to contain colorCount entries.
#define QT_BEGIN_NAMESPACE
This macro expands to.
int indexIn(const QString &str, int offset=0, CaretMode caretMode=CaretAtZero) const
Attempts to find a match in str from position offset (0 by default).
ImageOption
This enum describes the different options supported by QImageIOHandler.
static QByteArray fromRawData(const char *, int size)
Constructs a QByteArray that uses the first size bytes of the data array.
The QImage class provides a hardware-independent image representation that allows direct access to th...
int qGray(int r, int g, int b)
QVariant option(ImageOption option) const
Returns the value assigned to option as a QVariant.
bool supportsOption(ImageOption option) const
Returns true if the QImageIOHandler supports the option option; otherwise returns false...
int indexOf(char c, int from=0) const
Returns the index position of the first occurrence of the character ch in the byte array...
static bool write_xbm_image(const QImage &sourceImage, QIODevice *device, const QString &fileName)
virtual bool isSequential() const
Returns true if this device is sequential; otherwise returns false.
QSize size() const
Returns the size of the image, i.
QRgb qRgb(int r, int g, int b)
Returns the ARGB quadruplet (255, {r}, {g}, {b}).
int width() const
Returns the width of the image.
QImage convertToFormat(Format f, Qt::ImageConversionFlags flags=Qt::AutoColor) const Q_REQUIRED_RESULT
Returns a copy of the image in the given format.
QString trimmed(QString source)
qint64 readLine(char *data, qint64 maxlen)
This function reads a line of ASCII characters from the device, up to a maximum of maxSize - 1 bytes...
static QString fromLatin1(const char *, int size=-1)
Returns a QString initialized with the first size characters of the Latin-1 string str...
uint qstrlen(const char *str)
QByteArray toAscii() const Q_REQUIRED_RESULT
Returns an 8-bit representation of the string as a QByteArray.
QIODevice * device() const
Returns the device currently assigned to the QImageIOHandler.
int qsnprintf(char *str, size_t n, const char *fmt,...)
A portable snprintf() function, calls qvsnprintf.
int height() const
Returns the height of the image.
The QSize class defines the size of a two-dimensional object using integer point precision.
QByteArray name() const
Use format() instead.
qint64 write(const char *data, qint64 len)
Writes at most maxSize bytes of data from data to the device.
bool canRead() const
Returns true if an image can be read from the device (i.
The QIODevice class is the base interface class of all I/O devices in Qt.
virtual bool seek(qint64 pos)
For random-access devices, this function sets the current position to pos, returning true on success...
static QString fileName(const QString &fileUrl)
QRgb color(int i) const
Returns the color in the color table at index i.
uchar * scanLine(int)
Returns a pointer to the pixel data at the scanline with index i.
QBool contains(char c) const
Returns true if the byte array contains the character ch; otherwise returns false.
bool read(QImage *image)
Read an image from the device, and stores it in image.