From 26b5a01d5592f488af3f6d056c546032bd016ebd Mon Sep 17 00:00:00 2001
From: Lawrence Rust <lvr@softsystem.co.uk>
Date: Mon, 18 Jul 2011 20:32:19 +0200
Subject: [PATCH 5/9] freemheg: Support JPEG bitmaps
Signed-off-by: Lawrence Rust <lvr@softsystem.co.uk>
---
mythtv/libs/libmythfreemheg/Bitmap.cpp | 5 ++++-
mythtv/libs/libmythfreemheg/freemheg.h | 1 +
mythtv/libs/libmythtv/mhi.cpp | 16 ++++++++++++++++
mythtv/libs/libmythtv/mhi.h | 3 +++
4 files changed, 24 insertions(+), 1 deletions(-)
diff --git a/mythtv/libs/libmythfreemheg/Bitmap.cpp b/mythtv/libs/libmythfreemheg/Bitmap.cpp
index 6e6bbc4..522175d 100644
|
a
|
b
|
void MHBitmap::CreateContent(const unsigned char *data, int length, MHEngine *en
|
| 169 | 169 | { |
| 170 | 170 | m_pContent->CreateFromMPEG(data, length); |
| 171 | 171 | } |
| 172 | | |
| | 172 | else if (nCHook == 6) // JPEG ISO/IEC 10918-1, JFIF file |
| | 173 | { |
| | 174 | m_pContent->CreateFromJPEG(data, length); |
| | 175 | } |
| 173 | 176 | else |
| 174 | 177 | { |
| 175 | 178 | // 1,3,5,8 are reserved. 7= H.264 Intra Frame |
diff --git a/mythtv/libs/libmythfreemheg/freemheg.h b/mythtv/libs/libmythfreemheg/freemheg.h
index 0b61f65..327818a 100644
|
a
|
b
|
class MHBitmapDisplay
|
| 191 | 191 | // Creation functions |
| 192 | 192 | virtual void CreateFromPNG(const unsigned char *data, int length) = 0; |
| 193 | 193 | virtual void CreateFromMPEG(const unsigned char *data, int length) = 0; |
| | 194 | virtual void CreateFromJPEG(const unsigned char *data, int length) = 0; |
| 194 | 195 | // Scale the bitmap. Only used for image derived from MPEG I-frames. |
| 195 | 196 | virtual void ScaleImage(int newWidth, int newHeight) = 0; |
| 196 | 197 | // Information about the image. |
diff --git a/mythtv/libs/libmythtv/mhi.cpp b/mythtv/libs/libmythtv/mhi.cpp
index 1631495..d268fb4 100644
|
a
|
b
|
void MHIBitmap::CreateFromPNG(const unsigned char *data, int length)
|
| 1493 | 1493 | m_opaque = ! m_image.hasAlphaChannel(); |
| 1494 | 1494 | } |
| 1495 | 1495 | |
| | 1496 | // Create a bitmap from JPEG. |
| | 1497 | //virtual |
| | 1498 | void MHIBitmap::CreateFromJPEG(const unsigned char *data, int length) |
| | 1499 | { |
| | 1500 | m_image = QImage(); |
| | 1501 | |
| | 1502 | if (!m_image.loadFromData(data, length, "JPG")) |
| | 1503 | { |
| | 1504 | m_image = QImage(); |
| | 1505 | return; |
| | 1506 | } |
| | 1507 | |
| | 1508 | // Assume that if it has an alpha buffer then it's partly transparent. |
| | 1509 | m_opaque = ! m_image.hasAlphaChannel(); |
| | 1510 | } |
| | 1511 | |
| 1496 | 1512 | // Convert an MPEG I-frame into a bitmap. This is used as the way of |
| 1497 | 1513 | // sending still pictures. We convert the image to a QImage even |
| 1498 | 1514 | // though that actually means converting it from YUV and eventually |
diff --git a/mythtv/libs/libmythtv/mhi.h b/mythtv/libs/libmythtv/mhi.h
index 2b10c8b..5174cc7 100644
|
a
|
b
|
class MHIBitmap : public MHBitmapDisplay
|
| 231 | 231 | /// Create bitmap from single I frame MPEG |
| 232 | 232 | virtual void CreateFromMPEG(const unsigned char *data, int length); |
| 233 | 233 | |
| | 234 | /// Create bitmap from JPEG |
| | 235 | virtual void CreateFromJPEG(const unsigned char *data, int length); |
| | 236 | |
| 234 | 237 | /** \fn MHIBitmap::Draw(int,int,QRect,bool) |
| 235 | 238 | * \brief Draw the completed drawing onto the display. |
| 236 | 239 | * |