From 645f29c727f33cc9f8b00b8efcb658a050ac6a26 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lind?= Date: Tue, 12 Jan 2010 14:38:18 +0100 Subject: Fix QBlittablePixmapData::fromImage --- src/gui/image/qpixmap_blitter.cpp | 25 ++++++++++++++++++---- .../minimaldfb/qblitter_directfb.cpp | 2 +- 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/src/gui/image/qpixmap_blitter.cpp b/src/gui/image/qpixmap_blitter.cpp index b2bb674..5ce7fc1 100644 --- a/src/gui/image/qpixmap_blitter.cpp +++ b/src/gui/image/qpixmap_blitter.cpp @@ -102,10 +102,27 @@ void QBlittablePixmapData::fromImage(const QImage &image, Qt::ImageConversionFlags flags) { resize(image.width(),image.height()); - QImage *thisImg = blittable()->lock(); - QPainter p(thisImg); - p.setCompositionMode(QPainter::CompositionMode_Source); - p.drawImage(0,0,image,flags); + QImage *thisImg = buffer(); + + QImage correctFormatPic = image; + if (correctFormatPic.format() != thisImg->format()) + correctFormatPic = correctFormatPic.convertToFormat(thisImg->format(), flags); + + //jl: This does not ALWAYS work as expected :( +// QPainter p(thisImg); +// p.setCompositionMode(QPainter::CompositionMode_Source); +// p.drawImage(0,0,image,flags); + + //So just copy strides by hand + uchar *mem = thisImg->bits(); + const uchar *bits = correctFormatPic.bits(); + int bytesCopied = 0; + while (bytesCopied < correctFormatPic.byteCount()) { + memcpy(mem,bits,correctFormatPic.bytesPerLine()); + mem += thisImg->bytesPerLine(); + bits += correctFormatPic.bytesPerLine(); + bytesCopied+=correctFormatPic.bytesPerLine(); + } } QPaintEngine *QBlittablePixmapData::paintEngine() const diff --git a/src/plugins/graphicssystems/minimaldfb/qblitter_directfb.cpp b/src/plugins/graphicssystems/minimaldfb/qblitter_directfb.cpp index 23e3be6..3772131 100644 --- a/src/plugins/graphicssystems/minimaldfb/qblitter_directfb.cpp +++ b/src/plugins/graphicssystems/minimaldfb/qblitter_directfb.cpp @@ -23,7 +23,7 @@ QDirectFbBlitter::QDirectFbBlitter(const QRect &rect, IDirectFBSurface *surface) surfaceDesc.height = rect.height(); surfaceDesc.caps = DSCAPS_PREMULTIPLIED; surfaceDesc.pixelformat = DSPF_ARGB; - surfaceDesc.flags = DFBSurfaceDescriptionFlags(DSDESC_WIDTH | DSDESC_HEIGHT | DSDESC_PIXELFORMAT); + surfaceDesc.flags = DFBSurfaceDescriptionFlags(DSDESC_WIDTH | DSDESC_HEIGHT | DSDESC_CAPS | DSDESC_PIXELFORMAT); IDirectFB *dfb = QDirectFbConvenience::dfbInterface(); dfb->CreateSurface(dfb,&surfaceDesc, &m_surface); -- cgit v0.12