Skip to content

Commit

Permalink
DVD: Fix dvd button background handling.
Browse files Browse the repository at this point in the history
Refs #9860

Signed-off-by: Mark Kendall <mkendall@mythtv.org>
  • Loading branch information
martin authored and Mark Kendall committed Jun 23, 2011
1 parent 801aebf commit 005276f
Showing 1 changed file with 21 additions and 26 deletions.
47 changes: 21 additions & 26 deletions mythtv/libs/libmythtv/subtitlescreen.cpp
Expand Up @@ -536,32 +536,13 @@ void SubtitleScreen::DisplayDVDButton(AVSubtitle* dvdButton, QRect &buttonPos)
QImage bg_image(hl_button->pict.data[0], w, h, w, QImage::Format_Indexed8);
uint32_t *bgpalette = (uint32_t *)(hl_button->pict.data[1]);

bool blank = true;
for (uint x = 0; (x < w) && bgpalette; x++)
{
for (uint y = 0; y < h; y++)
{
if (qAlpha(bgpalette[bg_image.pixelIndex(x, y)]) > 0)
{
blank = false;
break;
}
}
}

if (!blank)
{
QVector<unsigned int> bg_palette;
for (int i = 0; i < AVPALETTE_COUNT; i++)
bg_palette.push_back(bgpalette[i]);
bg_image.setColorTable(bg_palette);
bg_image = bg_image.convertToFormat(QImage::Format_ARGB32);
AddScaledImage(bg_image, rect);
VERBOSE(VB_PLAYBACK, LOC + "Added DVD button background");
}
QVector<unsigned int> bg_palette;
for (int i = 0; i < AVPALETTE_COUNT; i++)
bg_palette.push_back(bgpalette[i]);
bg_image.setColorTable(bg_palette);

// copy button region of background image
QRect fg_rect(buttonPos.translated(-hl_button->x, -hl_button->y));
const QRect fg_rect(buttonPos.translated(-hl_button->x, -hl_button->y));
QImage fg_image = bg_image.copy(fg_rect);
QVector<unsigned int> fg_palette;
uint32_t *fgpalette = (uint32_t *)(dvdButton->rects[1]->pict.data[1]);
Expand All @@ -572,9 +553,23 @@ void SubtitleScreen::DisplayDVDButton(AVSubtitle* dvdButton, QRect &buttonPos)
fg_image.setColorTable(fg_palette);
}

// scale highlight image to match OSD size, if required
bg_image = bg_image.convertToFormat(QImage::Format_ARGB32);
fg_image = fg_image.convertToFormat(QImage::Format_ARGB32);
AddScaledImage(fg_image, buttonPos);

// set pixel of highlight area to highlight color
for (int x=fg_rect.x(); x < fg_rect.x()+fg_rect.width(); ++x)
{
if ((x < 0) || (x > hl_button->w))
continue;
for (int y=fg_rect.y(); y < fg_rect.y()+fg_rect.height(); ++y)
{
if ((y < 0) || (y > hl_button->h))
continue;
bg_image.setPixel(x, y, fg_image.pixel(x-fg_rect.x(),y-fg_rect.y()));
}
}

AddScaledImage(bg_image, rect);
}

void SubtitleScreen::DisplayCC608Subtitles(void)
Expand Down

0 comments on commit 005276f

Please sign in to comment.