friend class QSpanData;
friend class QPngHandler;
friend class QKatHandler;
+ friend class QX11Data;
#if !defined(QT_NO_DATASTREAM)
friend Q_GUI_EXPORT QDataStream &operator<<(QDataStream &, const QImage &);
friend Q_GUI_EXPORT QDataStream &operator>>(QDataStream &, QImage &);
if (image.depth() == 1) {
image.setColorTable(monoColorTable());
}
- QX11Data::copyXImageToQImage(ximage, image);
- XDestroyImage(ximage);
+ bool freedata = false;
+ QX11Data::copyXImageToQImage(ximage, image, &freedata);
+ QX11Data::destroyXImage(ximage, freedata);
return QPixmap::fromImage(image);
}
#include "qcolor.h"
#include "qimage.h"
+#include "qimage_p.h"
#include "qdrawhelper_p.h"
#include "qt_x11_p.h"
#include "qx11info_x11.h"
}
}
-void QX11Data::destroyXImage(XImage *ximage, const bool freedata)
-{
- if (!freedata) {
- ximage->data = nullptr;
- }
- XDestroyImage(ximage);
-}
-
-void QX11Data::copyXImageToQImage(XImage *ximage, QImage &image)
+void QX11Data::copyXImageToQImage(XImage *ximage, QImage &image, bool *freedata)
{
Q_ASSERT(ximage);
Q_ASSERT(ximage->width == image.width());
if (samedepth && samebyteorder) {
switch (image.format()) {
case QImage::Format_RGB32: {
+ *freedata = true;
uchar *imagedata = image.bits();
const int imagebpl = image.bytesPerLine();
for (int h = 0; h < ximage->height; h++) {
case QImage::Format_ARGB32:
case QImage::Format_ARGB32_Premultiplied:
case QImage::Format_RGB16: {
- ::memcpy(image.bits(), ximage->data, image.byteCount());
+ *freedata = false;
+ image.d->data = (uchar*)ximage->data;
return;
}
default: {
}
}
+ *freedata = true;
if (image.depth() == 1) {
for (int h = 0; h < ximage->height; h++) {
for (int w = 0; w < ximage->width; w++) {
}
}
+void QX11Data::destroyXImage(XImage *ximage, const bool freedata)
+{
+ if (!freedata) {
+ ximage->data = nullptr;
+ }
+ XDestroyImage(ximage);
+}
+
uint QX11Data::XColorPixel(const int screen, const QColor &color)
{
Display* x11display = QX11Info::display();
Colormap colormap;
static void copyQImageToXImage(const QImage &image, XImage *ximage, bool *freedata);
+ static void copyXImageToQImage(XImage *ximage, QImage &image, bool *freedata);
static void destroyXImage(XImage *ximage, const bool freedata);
- static void copyXImageToQImage(XImage *ximage, QImage &image);
static uint XColorPixel(const int screen, const QColor &color);