Skip to content

Commit

Permalink
freemheg: Support JPEG bitmaps
Browse files Browse the repository at this point in the history
Signed-off-by: Lawrence Rust <lvr@softsystem.co.uk>
Signed-off-by: Stuart Morgan <smorgan@mythtv.org>
  • Loading branch information
Lawrence Rust authored and stuartm committed Jul 6, 2012
1 parent 0a864fd commit abc52ed
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 1 deletion.
5 changes: 4 additions & 1 deletion mythtv/libs/libmythfreemheg/Bitmap.cpp
Expand Up @@ -169,7 +169,10 @@ void MHBitmap::CreateContent(const unsigned char *data, int length, MHEngine *en
{
m_pContent->CreateFromMPEG(data, length);
}

else if (nCHook == 6) // JPEG ISO/IEC 10918-1, JFIF file
{
m_pContent->CreateFromJPEG(data, length);
}
else
{
// 1,3,5,8 are reserved. 7= H.264 Intra Frame
Expand Down
1 change: 1 addition & 0 deletions mythtv/libs/libmythfreemheg/freemheg.h
Expand Up @@ -191,6 +191,7 @@ class MHBitmapDisplay
// Creation functions
virtual void CreateFromPNG(const unsigned char *data, int length) = 0;
virtual void CreateFromMPEG(const unsigned char *data, int length) = 0;
virtual void CreateFromJPEG(const unsigned char *data, int length) = 0;
// Scale the bitmap. Only used for image derived from MPEG I-frames.
virtual void ScaleImage(int newWidth, int newHeight) = 0;
// Information about the image.
Expand Down
16 changes: 16 additions & 0 deletions mythtv/libs/libmythtv/mhi.cpp
Expand Up @@ -1495,6 +1495,22 @@ void MHIBitmap::CreateFromPNG(const unsigned char *data, int length)
m_opaque = ! m_image.hasAlphaChannel();
}

// Create a bitmap from JPEG.
//virtual
void MHIBitmap::CreateFromJPEG(const unsigned char *data, int length)
{
m_image = QImage();

if (!m_image.loadFromData(data, length, "JPG"))
{
m_image = QImage();
return;
}

// Assume that if it has an alpha buffer then it's partly transparent.
m_opaque = ! m_image.hasAlphaChannel();
}

// Convert an MPEG I-frame into a bitmap. This is used as the way of
// sending still pictures. We convert the image to a QImage even
// though that actually means converting it from YUV and eventually
Expand Down
3 changes: 3 additions & 0 deletions mythtv/libs/libmythtv/mhi.h
Expand Up @@ -231,6 +231,9 @@ class MHIBitmap : public MHBitmapDisplay
/// Create bitmap from single I frame MPEG
virtual void CreateFromMPEG(const unsigned char *data, int length);

/// Create bitmap from JPEG
virtual void CreateFromJPEG(const unsigned char *data, int length);

/** \fn MHIBitmap::Draw(int,int,QRect,bool)
* \brief Draw the completed drawing onto the display.
*
Expand Down

0 comments on commit abc52ed

Please sign in to comment.