1.QString text(const QString &key = QString()) const;
/*!
Returns the image text associated with the given \a key. If the
specified \a key is an empty string, the whole image text is
returned, with each key-text pair separated by a newline.
\sa setText(), textKeys()
*/
QString QImage::text(const QString &key) const
{
if (!d)
return QString();
if (!key.isEmpty())
return d->text.value(key);
QString tmp;
for (auto it = d->text.begin(), end = d->text.end(); it != end; ++it)
tmp += it.key() + QLatin1String(": ") + it.value().simplified() + QLatin1String("\n\n");
if (!tmp.isEmpty())
tmp.chop(2); // remove final \n\n
return tmp;
}
d->text是QMap类型,根据key获取value。
2.QStringList textKeys() const;
QStringList QImage::textKeys() const
{
return d ? QStringList(d->text.keys()) : QStringList();
}
3. void setText(const QString &key, const QString &value);
void QImage::setText(const QString &key, const QString &value)
{
if (!d)
return;
detach();
if (d)
d->text.insert(key, value);
}
添加key和value到QMap里。
4.int depth() const;
/*!
Returns the depth of the image.
The image depth is the number of bits used to store a single
pixel, also called bits per pixel (bpp).
The supported depths are 1, 8, 16, 24, 32 and 64.
\sa bitPlaneCount(), convertToFormat(), {QImage#Image Formats}{Image Formats},
{QImage#Image Information}{Image Information}
*/
int QImage::depth() const
{
return d ? d->depth : 0;
}
5.int bitPlaneCount() const;
int QImage::bitPlaneCount() const
{
if (!d)
return 0;
int bpc = 0;
switch (d->format) {
case QImage::Format_Invalid:
break;
case QImage::Format_BGR30:
case QImage::Format_RGB30:
bpc = 30;
break;
case QImage::Format_RGB32:
case QImage::Format_RGBX8888:
bpc = 24;
break;
case QImage::Format_RGB666:
bpc = 18;
break;
case QImage::Format_RGB555:
bpc = 15;
break;
case QImage::Format_ARGB8555_Premultiplied:
bpc = 23;
break;
case QImage::Format_RGB444:
bpc = 12;
break;
case QImage::Format_RGBX64:
bpc = 48;
break;
default:
bpc = qt_depthForFormat(d->format);
break;
}
return bpc;
}
位平面的数量是颜色的位数(bit).
QImage::Format QImage::format() const
{
return d ? d->format : Format_Invalid;
}
7.qsizetype bytesPerLine() const;
qsizetype QImage::bytesPerLine() const
{
return d ? d->bytes_per_line : 0;
}
8.qsizetype sizeInBytes() const;
qsizetype QImage::sizeInBytes() const
{
return d ? d->nbytes : 0;
}
/*!
Returns a number that identifies the contents of this QImage
object. Distinct QImage objects can only have the same key if they
refer to the same contents.
The key will change when the image is altered.
*/
qint64 QImage::cacheKey() const
{
if (!d)
return 0;
else
return (((qint64) d->ser_no) << 32) | ((qint64) d->detach_no);
}