summaryrefslogtreecommitdiffstats
path: root/src/3rdparty/phonon/mmf/utils.cpp
diff options
context:
space:
mode:
authorGareth Stockwell <gareth.stockwell@sosco.com>2009-09-16 17:08:58 (GMT)
committerFrans Englich <frans.englich@nokia.com>2009-09-23 12:36:29 (GMT)
commit6700a53676265787ab46106602234448e0174e55 (patch)
tree245cf82b5a5152b6f34a505434f4ed6249fffb1f /src/3rdparty/phonon/mmf/utils.cpp
parent61161589376a3bb2dffaf898ca50449774b48565 (diff)
downloadQt-6700a53676265787ab46106602234448e0174e55.zip
Qt-6700a53676265787ab46106602234448e0174e55.tar.gz
Qt-6700a53676265787ab46106602234448e0174e55.tar.bz2
Added a utility function for reading color of individual pixels from the screen
Diffstat (limited to 'src/3rdparty/phonon/mmf/utils.cpp')
-rw-r--r--src/3rdparty/phonon/mmf/utils.cpp75
1 files changed, 75 insertions, 0 deletions
diff --git a/src/3rdparty/phonon/mmf/utils.cpp b/src/3rdparty/phonon/mmf/utils.cpp
index cebc32e..3d674fd 100644
--- a/src/3rdparty/phonon/mmf/utils.cpp
+++ b/src/3rdparty/phonon/mmf/utils.cpp
@@ -50,5 +50,80 @@ MMF::MediaType MMF::Utils::mimeTypeToMediaType(const TDesC& mimeType)
}
+#ifdef _DEBUG
+
+#include <hal.h>
+#include <hal_data.h>
+#include <gdi.h>
+#include <eikenv.h>
+
+struct TScreenInfo
+{
+ int width;
+ int height;
+ int bpp;
+ const char* address;
+ int initialOffset;
+ int lineOffset;
+ TDisplayMode displayMode;
+};
+
+void getScreenInfoL(TScreenInfo& info)
+{
+ info.displayMode = CEikonEnv::Static()->ScreenDevice()->DisplayMode();
+
+ // Then we must set these as the input parameter
+ info.width = info.displayMode;
+ info.height = info.displayMode;
+ info.initialOffset = info.displayMode;
+ info.lineOffset = info.displayMode;
+ info.bpp = info.displayMode;
+
+ User::LeaveIfError( HAL::Get(HALData::EDisplayXPixels, info.width) );
+ User::LeaveIfError( HAL::Get(HALData::EDisplayYPixels, info.width) );
+
+ int address;
+ User::LeaveIfError( HAL::Get(HALData::EDisplayMemoryAddress, address) );
+ info.address = reinterpret_cast<const char*>(address);
+
+ User::LeaveIfError( HAL::Get(HALData::EDisplayOffsetToFirstPixel, info.initialOffset) );
+
+ User::LeaveIfError( HAL::Get(HALData::EDisplayOffsetBetweenLines, info.lineOffset) );
+
+ User::LeaveIfError( HAL::Get(HALData::EDisplayBitsPerPixel, info.bpp) );
+}
+
+
+QColor MMF::Utils::getScreenPixel(const QPoint& pos)
+{
+ TScreenInfo info;
+ TRAPD(err, getScreenInfoL(info));
+ QColor pixel;
+ if(err == KErrNone and pos.x() < info.width and pos.y() < info.height)
+ {
+ const int bytesPerPixel = info.bpp / 8;
+ Q_ASSERT(bytesPerPixel >= 3);
+
+ const int stride = (info.width * bytesPerPixel) + info.lineOffset;
+
+ const char* ptr =
+ info.address
+ + info.initialOffset
+ + pos.y() * stride
+ + pos.x() * bytesPerPixel;
+
+ // BGRA
+ pixel.setBlue(*ptr++);
+ pixel.setGreen(*ptr++);
+ pixel.setRed(*ptr++);
+
+ if(bytesPerPixel == 4)
+ pixel.setAlpha(*ptr++);
+ }
+ return pixel;
+}
+
+#endif // _DEBUG
+
QT_END_NAMESPACE