From 7b923d14c0e8d8f84c71e8d636a0632f4566f00a Mon Sep 17 00:00:00 2001 From: aavit Date: Thu, 4 Mar 2010 13:34:27 +0100 Subject: Added QImage::bitPlaneCount(). When the image format contains unused bits (e.g. Format_RGB32), depth() does not give the true number of bits of color information per pixel. This new function does. Task-number: QTBUG-7982 Reviewed-by: Trond --- src/gui/image/qimage.cpp | 55 +++++++++++++++++++++++++++++++++++++++++++----- src/gui/image/qimage.h | 1 + 2 files changed, 51 insertions(+), 5 deletions(-) diff --git a/src/gui/image/qimage.cpp b/src/gui/image/qimage.cpp index 6bcf72b..94307de 100644 --- a/src/gui/image/qimage.cpp +++ b/src/gui/image/qimage.cpp @@ -480,9 +480,12 @@ bool QImageData::checkForAlphaPixels() const \row \o Low-level information \o + The depth() function returns the depth of the image. The supported - depths are 1 (monochrome), 8 and 32 (for more information see the - \l {QImage#Image Formats}{Image Formats} section). + depths are 1 (monochrome), 8, 16, 24 and 32 bits. The + bitPlaneCount() function tells how many of those bits that are + used. For more information see the + \l {QImage#Image Formats}{Image Formats} section. The format(), bytesPerLine(), and byteCount() functions provide low-level information about the data stored in the image. @@ -707,7 +710,7 @@ bool QImageData::checkForAlphaPixels() const packed with the less significant bit (LSB) first. \value Format_Indexed8 The image is stored using 8-bit indexes - into a colormap. + into a colormap. \value Format_RGB32 The image is stored using a 32-bit RGB format (0xffRRGGBB). @@ -1580,12 +1583,12 @@ QRect QImage::rect() const /*! Returns the depth of the image. - The image depth is the number of bits used to encode a single + 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 and 32. - \sa convertToFormat(), {QImage#Image Formats}{Image Formats}, + \sa bitPlaneCount(), convertToFormat(), {QImage#Image Formats}{Image Formats}, {QImage#Image Information}{Image Information} */ @@ -5848,6 +5851,48 @@ bool QImage::hasAlphaChannel() const } +/*! + \since 4.7 + Returns the number of bit planes in the image. + + The number of bit planes is the number of bits of color and + transparency information for each pixel. This is different from + (i.e. smaller than) the depth when the image format contains + unused bits. + + \sa depth(), format(), {QImage#Image Formats}{Image Formats} +*/ +int QImage::bitPlaneCount() const +{ + if (!d) + return 0; + int bpc = 0; + switch (d->format) { + case QImage::Format_Invalid: + break; + case QImage::Format_RGB32: + 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; + default: + bpc = depthForFormat(d->format); + break; + } + return bpc; +} + + #ifdef QT3_SUPPORT #if defined(Q_WS_X11) QT_BEGIN_INCLUDE_NAMESPACE diff --git a/src/gui/image/qimage.h b/src/gui/image/qimage.h index dd13782..896061f 100644 --- a/src/gui/image/qimage.h +++ b/src/gui/image/qimage.h @@ -169,6 +169,7 @@ public: QT_DEPRECATED int numColors() const; #endif int colorCount() const; + int bitPlaneCount() const; QRgb color(int i) const; void setColor(int i, QRgb c); -- cgit v0.12 From 4152244217ab7f34e67f7800cb796d8923061f49 Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Fri, 5 Mar 2010 10:43:50 +0100 Subject: Fixa few warnings on mingw --- examples/multimedia/audioinput/audioinput.cpp | 6 ++++++ src/3rdparty/phonon/ds9/backendnode.cpp | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/examples/multimedia/audioinput/audioinput.cpp b/examples/multimedia/audioinput/audioinput.cpp index b01a396..af72385 100644 --- a/examples/multimedia/audioinput/audioinput.cpp +++ b/examples/multimedia/audioinput/audioinput.cpp @@ -76,6 +76,8 @@ AudioInfo::AudioInfo(const QAudioFormat &format, QObject *parent) case QAudioFormat::SignedInt: m_maxAmplitude = 127; break; + default: + break; } break; case 16: @@ -86,8 +88,12 @@ AudioInfo::AudioInfo(const QAudioFormat &format, QObject *parent) case QAudioFormat::SignedInt: m_maxAmplitude = 32767; break; + default: + break; } break; + default: + break; } } diff --git a/src/3rdparty/phonon/ds9/backendnode.cpp b/src/3rdparty/phonon/ds9/backendnode.cpp index 3afcafa..737ab7b 100644 --- a/src/3rdparty/phonon/ds9/backendnode.cpp +++ b/src/3rdparty/phonon/ds9/backendnode.cpp @@ -67,7 +67,7 @@ namespace Phonon if (info.pGraph) { HRESULT hr = info.pGraph->RemoveFilter(filter); - if (hr == VFW_E_NOT_STOPPED && m_mediaObject) { + if (FAILED(hr) && m_mediaObject) { m_mediaObject->ensureStopped(); hr = info.pGraph->RemoveFilter(filter); -- cgit v0.12 From 512593cb8db6242eda631b8c71d22e2d154abc98 Mon Sep 17 00:00:00 2001 From: aavit Date: Fri, 5 Mar 2010 11:00:49 +0100 Subject: Fixed failure to store certain image formats as jpeg In contrast to other image format handlers, the jpeg handler would not convert a QImage of an "unusual" format to a format it could handle when asked to write it. Now it does. Task-number: QTBUG-7780 Reviewed-by: Trond --- src/plugins/imageformats/jpeg/qjpeghandler.cpp | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/src/plugins/imageformats/jpeg/qjpeghandler.cpp b/src/plugins/imageformats/jpeg/qjpeghandler.cpp index 3555b21..6eed824 100644 --- a/src/plugins/imageformats/jpeg/qjpeghandler.cpp +++ b/src/plugins/imageformats/jpeg/qjpeghandler.cpp @@ -562,11 +562,29 @@ inline my_jpeg_destination_mgr::my_jpeg_destination_mgr(QIODevice *device) free_in_buffer = max_buf; } +static bool can_write_format(QImage::Format fmt) +{ + switch (fmt) { + case QImage::Format_Mono: + case QImage::Format_MonoLSB: + case QImage::Format_Indexed8: + case QImage::Format_RGB888: + case QImage::Format_RGB32: + case QImage::Format_ARGB32: + case QImage::Format_ARGB32_Premultiplied: + return true; + break; + default: + break; + } + return false; +} static bool write_jpeg_image(const QImage &sourceImage, QIODevice *device, int sourceQuality) { bool success = false; - const QImage image = sourceImage; + const QImage image = can_write_format(sourceImage.format()) ? + sourceImage : sourceImage.convertToFormat(QImage::Format_RGB888); const QVector cmap = image.colorTable(); struct jpeg_compress_struct cinfo; -- cgit v0.12 From b101849cafea6bcc793a1bfbbe4861c19e08ac01 Mon Sep 17 00:00:00 2001 From: ninerider Date: Fri, 5 Mar 2010 13:45:39 +0100 Subject: Compile fix for Windows Mobile and OpenGLES2 The native device is now the default screen device. --- src/gui/egl/qegl_wince.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/gui/egl/qegl_wince.cpp b/src/gui/egl/qegl_wince.cpp index c07b20b..2d08805 100644 --- a/src/gui/egl/qegl_wince.cpp +++ b/src/gui/egl/qegl_wince.cpp @@ -53,8 +53,7 @@ QT_BEGIN_NAMESPACE EGLNativeDisplayType QEgl::nativeDisplay() { - HWND win = (static_cast(device))->winId(); - HDC myDc = GetDC(win); + HDC myDc = GetDC(0); if (!myDc) { qWarning("QEglContext::nativeDisplay(): WinCE display is not open"); return EGL_DEFAULT_DISPLAY; -- cgit v0.12 From 647b3395e41827c232fa9203ee0590da2b6d257a Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Fri, 5 Mar 2010 15:48:10 +0100 Subject: Fix for torn off menus that were way too big --- src/gui/widgets/qmenu.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/gui/widgets/qmenu.cpp b/src/gui/widgets/qmenu.cpp index 9a4916e..ebc05d9 100644 --- a/src/gui/widgets/qmenu.cpp +++ b/src/gui/widgets/qmenu.cpp @@ -260,9 +260,6 @@ void QMenuPrivate::updateActionRects() const icone = style->pixelMetric(QStyle::PM_SmallIconSize, &opt, q); const int fw = style->pixelMetric(QStyle::PM_MenuPanelWidth, &opt, q); const int deskFw = style->pixelMetric(QStyle::PM_MenuDesktopFrameWidth, &opt, q); - - const int sfcMargin = style->sizeFromContents(QStyle::CT_Menu, &opt, QApplication::globalStrut(), q).width() - QApplication::globalStrut().width(); - const int min_column_width = q->minimumWidth() - (sfcMargin + leftmargin + rightmargin + 2 * (fw + hmargin)); const int tearoffHeight = tearoff ? style->pixelMetric(QStyle::PM_MenuTearoffHeight, &opt, q) : 0; //for compatability now - will have to refactor this away.. @@ -336,7 +333,7 @@ void QMenuPrivate::updateActionRects() const if (!sz.isEmpty()) { - max_column_width = qMax(min_column_width, qMax(max_column_width, sz.width())); + max_column_width = qMax(max_column_width, sz.width()); //wrapping if (!scroll && y+sz.height()+vmargin > dh - (deskFw * 2)) { @@ -350,6 +347,10 @@ void QMenuPrivate::updateActionRects() const } max_column_width += tabWidth; //finally add in the tab width + const int sfcMargin = style->sizeFromContents(QStyle::CT_Menu, &opt, QApplication::globalStrut(), q).width() - QApplication::globalStrut().width(); + const int min_column_width = q->minimumWidth() - (sfcMargin + leftmargin + rightmargin + 2 * (fw + hmargin)); + max_column_width = qMax(min_column_width, max_column_width); + //calculate position const int base_y = vmargin + fw + topmargin + -- cgit v0.12