[libcamera-devel,v2,3/3] qcam: viewfinder_qt: Support X RGB variants
diff mbox series

Message ID 20220706090642.2750987-4-kieran.bingham@ideasonboard.com
State Accepted
Commit ef77e2637985b61dc99669b4396647ad13acb204
Headers show
Series
  • qcam: Support 'X'RGB formats
Related show

Commit Message

Kieran Bingham July 6, 2022, 9:06 a.m. UTC
Support the X variants of the RGB pixel formats
along side the equivalent Alpha component based versions.

The Alpha channel is ignored by both QImage::Format_RGB32, and
QImage::Format_RGBX8888.

The existing use of QImage::Format_RGBA8888 is updated to use the
QImage::Format_RGBX8888 variant to ensure that the image data is
visible.

Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
---

v2:
 - Update to use QImage::Format_RGBX8888 over QImage::Format_RGBA8888

 src/qcam/viewfinder_qt.cpp | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Comments

Laurent Pinchart July 6, 2022, 9:21 a.m. UTC | #1
Hi Kieran,

Thank you for the patch.

On Wed, Jul 06, 2022 at 10:06:42AM +0100, Kieran Bingham via libcamera-devel wrote:
> Support the X variants of the RGB pixel formats
> along side the equivalent Alpha component based versions.

s/along side/alongside/

(you can reflow the text too)

> The Alpha channel is ignored by both QImage::Format_RGB32, and
> QImage::Format_RGBX8888.

That's not guaranteed by the Qt documentation as far as I understand.
I'd write

The QImage::Format_RGB32 and QImage::Format_RGBX8888 formats only
specify that the alpha component must be 0xff. While the Qt
documentation doesn't guarantee that the alpha value will be ignored by
consumers, this seems to be the implemented behaviour, at least when
rendering with QPainter::drawImage().

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

> The existing use of QImage::Format_RGBA8888 is updated to use the
> QImage::Format_RGBX8888 variant to ensure that the image data is
> visible.
> 
> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
> ---
> 
> v2:
>  - Update to use QImage::Format_RGBX8888 over QImage::Format_RGBA8888
> 
>  src/qcam/viewfinder_qt.cpp | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/src/qcam/viewfinder_qt.cpp b/src/qcam/viewfinder_qt.cpp
> index 27955e3f9593..7a6a60c96393 100644
> --- a/src/qcam/viewfinder_qt.cpp
> +++ b/src/qcam/viewfinder_qt.cpp
> @@ -27,9 +27,11 @@
>  static const QMap<libcamera::PixelFormat, QImage::Format> nativeFormats
>  {
>  #if QT_VERSION >= QT_VERSION_CHECK(5, 2, 0)
> -	{ libcamera::formats::ABGR8888, QImage::Format_RGBA8888 },
> +	{ libcamera::formats::ABGR8888, QImage::Format_RGBX8888 },
> +	{ libcamera::formats::XBGR8888, QImage::Format_RGBX8888 },
>  #endif
>  	{ libcamera::formats::ARGB8888, QImage::Format_RGB32 },
> +	{ libcamera::formats::XRGB8888, QImage::Format_RGB32 },
>  #if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
>  	{ libcamera::formats::RGB888, QImage::Format_BGR888 },
>  #endif

Patch
diff mbox series

diff --git a/src/qcam/viewfinder_qt.cpp b/src/qcam/viewfinder_qt.cpp
index 27955e3f9593..7a6a60c96393 100644
--- a/src/qcam/viewfinder_qt.cpp
+++ b/src/qcam/viewfinder_qt.cpp
@@ -27,9 +27,11 @@ 
 static const QMap<libcamera::PixelFormat, QImage::Format> nativeFormats
 {
 #if QT_VERSION >= QT_VERSION_CHECK(5, 2, 0)
-	{ libcamera::formats::ABGR8888, QImage::Format_RGBA8888 },
+	{ libcamera::formats::ABGR8888, QImage::Format_RGBX8888 },
+	{ libcamera::formats::XBGR8888, QImage::Format_RGBX8888 },
 #endif
 	{ libcamera::formats::ARGB8888, QImage::Format_RGB32 },
+	{ libcamera::formats::XRGB8888, QImage::Format_RGB32 },
 #if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
 	{ libcamera::formats::RGB888, QImage::Format_BGR888 },
 #endif