| Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/gui/image/qplatformpixmap.cpp |
| Switch to Source code | Preprocessed file |
| Line | Source | Count | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | - | |||||||||||||
| 2 | - | |||||||||||||
| 3 | QPlatformPixmap *QPlatformPixmap::create(int w, int h, PixelType type) | - | ||||||||||||
| 4 | { | - | ||||||||||||
| 5 | QPlatformPixmap *data = QGuiApplicationPrivate::platformIntegration()->createPlatformPixmap(static_cast<QPlatformPixmap::PixelType>(type)); | - | ||||||||||||
| 6 | data->resize(w, h); | - | ||||||||||||
| 7 | return never executed: data;return data;never executed: return data; | 0 | ||||||||||||
| 8 | } | - | ||||||||||||
| 9 | - | |||||||||||||
| 10 | - | |||||||||||||
| 11 | QPlatformPixmap::QPlatformPixmap(PixelType pixelType, int objectId) | - | ||||||||||||
| 12 | : w(0), | - | ||||||||||||
| 13 | h(0), | - | ||||||||||||
| 14 | d(0), | - | ||||||||||||
| 15 | is_null(true), | - | ||||||||||||
| 16 | ref(0), | - | ||||||||||||
| 17 | detach_no(0), | - | ||||||||||||
| 18 | type(pixelType), | - | ||||||||||||
| 19 | id(objectId), | - | ||||||||||||
| 20 | ser_no(0), | - | ||||||||||||
| 21 | is_cached(false) | - | ||||||||||||
| 22 | { | - | ||||||||||||
| 23 | } never executed: end of block | 0 | ||||||||||||
| 24 | - | |||||||||||||
| 25 | QPlatformPixmap::~QPlatformPixmap() | - | ||||||||||||
| 26 | { | - | ||||||||||||
| 27 | - | |||||||||||||
| 28 | - | |||||||||||||
| 29 | - | |||||||||||||
| 30 | - | |||||||||||||
| 31 | - | |||||||||||||
| 32 | - | |||||||||||||
| 33 | if (is_cached
| 0 | ||||||||||||
| 34 | QImagePixmapCleanupHooks::executePlatformPixmapDestructionHooks(this); | - | ||||||||||||
| 35 | is_cached = false; | - | ||||||||||||
| 36 | } never executed: end of block | 0 | ||||||||||||
| 37 | } never executed: end of block | 0 | ||||||||||||
| 38 | - | |||||||||||||
| 39 | QPlatformPixmap *QPlatformPixmap::createCompatiblePlatformPixmap() const | - | ||||||||||||
| 40 | { | - | ||||||||||||
| 41 | QPlatformPixmap *d = QGuiApplicationPrivate::platformIntegration()->createPlatformPixmap(pixelType()); | - | ||||||||||||
| 42 | return never executed: d;return d;never executed: return d; | 0 | ||||||||||||
| 43 | } | - | ||||||||||||
| 44 | - | |||||||||||||
| 45 | static QImage makeBitmapCompliantIfNeeded(QPlatformPixmap *d, const QImage &image, Qt::ImageConversionFlags flags) | - | ||||||||||||
| 46 | { | - | ||||||||||||
| 47 | if (d->pixelType() == QPlatformPixmap::BitmapType
| 0 | ||||||||||||
| 48 | QImage img = image.convertToFormat(QImage::Format_MonoLSB, flags); | - | ||||||||||||
| 49 | - | |||||||||||||
| 50 | - | |||||||||||||
| 51 | - | |||||||||||||
| 52 | const QRgb c0 = QColor(Qt::black).rgb(); | - | ||||||||||||
| 53 | const QRgb c1 = QColor(Qt::white).rgb(); | - | ||||||||||||
| 54 | if (img.color(0) == c0
| 0 | ||||||||||||
| 55 | img.invertPixels(); | - | ||||||||||||
| 56 | img.setColor(0, c1); | - | ||||||||||||
| 57 | img.setColor(1, c0); | - | ||||||||||||
| 58 | } never executed: end of block | 0 | ||||||||||||
| 59 | return never executed: img;return img;never executed: return img; | 0 | ||||||||||||
| 60 | } | - | ||||||||||||
| 61 | - | |||||||||||||
| 62 | return never executed: image;return image;never executed: return image; | 0 | ||||||||||||
| 63 | } | - | ||||||||||||
| 64 | - | |||||||||||||
| 65 | void QPlatformPixmap::fromImageReader(QImageReader *imageReader, | - | ||||||||||||
| 66 | Qt::ImageConversionFlags flags) | - | ||||||||||||
| 67 | { | - | ||||||||||||
| 68 | const QImage image = imageReader->read(); | - | ||||||||||||
| 69 | fromImage(image, flags); | - | ||||||||||||
| 70 | } never executed: end of block | 0 | ||||||||||||
| 71 | - | |||||||||||||
| 72 | bool QPlatformPixmap::fromFile(const QString &fileName, const char *format, | - | ||||||||||||
| 73 | Qt::ImageConversionFlags flags) | - | ||||||||||||
| 74 | { | - | ||||||||||||
| 75 | QImage image = QImageReader(fileName, format).read(); | - | ||||||||||||
| 76 | if (image.isNull()
| 0 | ||||||||||||
| 77 | return never executed: false;return false;never executed: return false; | 0 | ||||||||||||
| 78 | fromImage(makeBitmapCompliantIfNeeded(this, image, flags), flags); | - | ||||||||||||
| 79 | return never executed: !isNull();return !isNull();never executed: return !isNull(); | 0 | ||||||||||||
| 80 | } | - | ||||||||||||
| 81 | - | |||||||||||||
| 82 | bool QPlatformPixmap::fromData(const uchar *buf, uint len, const char *format, Qt::ImageConversionFlags flags) | - | ||||||||||||
| 83 | { | - | ||||||||||||
| 84 | QByteArray a = QByteArray::fromRawData(reinterpret_cast<const char *>(buf), len); | - | ||||||||||||
| 85 | QBuffer b(&a); | - | ||||||||||||
| 86 | b.open(QIODevice::ReadOnly); | - | ||||||||||||
| 87 | QImage image = QImageReader(&b, format).read(); | - | ||||||||||||
| 88 | if (image.isNull()
| 0 | ||||||||||||
| 89 | return never executed: false;return false;never executed: return false; | 0 | ||||||||||||
| 90 | fromImage(makeBitmapCompliantIfNeeded(this, image, flags), flags); | - | ||||||||||||
| 91 | return never executed: !isNull();return !isNull();never executed: return !isNull(); | 0 | ||||||||||||
| 92 | } | - | ||||||||||||
| 93 | - | |||||||||||||
| 94 | void QPlatformPixmap::copy(const QPlatformPixmap *data, const QRect &rect) | - | ||||||||||||
| 95 | { | - | ||||||||||||
| 96 | fromImage(data->toImage(rect), Qt::NoOpaqueDetection); | - | ||||||||||||
| 97 | } never executed: end of block | 0 | ||||||||||||
| 98 | - | |||||||||||||
| 99 | bool QPlatformPixmap::scroll(int dx, int dy, const QRect &rect) | - | ||||||||||||
| 100 | { | - | ||||||||||||
| 101 | (void)dx;; | - | ||||||||||||
| 102 | (void)dy;; | - | ||||||||||||
| 103 | (void)rect;; | - | ||||||||||||
| 104 | return never executed: false;return false;never executed: return false; | 0 | ||||||||||||
| 105 | } | - | ||||||||||||
| 106 | - | |||||||||||||
| 107 | QPixmap QPlatformPixmap::transformed(const QTransform &matrix, | - | ||||||||||||
| 108 | Qt::TransformationMode mode) const | - | ||||||||||||
| 109 | { | - | ||||||||||||
| 110 | return never executed: QPixmap::fromImage(toImage().transformed(matrix, mode));return QPixmap::fromImage(toImage().transformed(matrix, mode));never executed: return QPixmap::fromImage(toImage().transformed(matrix, mode)); | 0 | ||||||||||||
| 111 | } | - | ||||||||||||
| 112 | - | |||||||||||||
| 113 | void QPlatformPixmap::setSerialNumber(int serNo) | - | ||||||||||||
| 114 | { | - | ||||||||||||
| 115 | ser_no = serNo; | - | ||||||||||||
| 116 | } never executed: end of block | 0 | ||||||||||||
| 117 | - | |||||||||||||
| 118 | void QPlatformPixmap::setDetachNumber(int detNo) | - | ||||||||||||
| 119 | { | - | ||||||||||||
| 120 | detach_no = detNo; | - | ||||||||||||
| 121 | } never executed: end of block | 0 | ||||||||||||
| 122 | - | |||||||||||||
| 123 | QImage QPlatformPixmap::toImage(const QRect &rect) const | - | ||||||||||||
| 124 | { | - | ||||||||||||
| 125 | if (rect.contains(QRect(0, 0, w, h))
| 0 | ||||||||||||
| 126 | return never executed: toImage();return toImage();never executed: return toImage(); | 0 | ||||||||||||
| 127 | else | - | ||||||||||||
| 128 | return never executed: toImage().copy(rect);return toImage().copy(rect);never executed: return toImage().copy(rect); | 0 | ||||||||||||
| 129 | } | - | ||||||||||||
| 130 | - | |||||||||||||
| 131 | QImage* QPlatformPixmap::buffer() | - | ||||||||||||
| 132 | { | - | ||||||||||||
| 133 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||
| 134 | } | - | ||||||||||||
| 135 | - | |||||||||||||
| 136 | - | |||||||||||||
| 137 | - | |||||||||||||
| Switch to Source code | Preprocessed file |