Skip to content

Commit 005276f

Browse files
martinMark Kendall
authored andcommitted
DVD: Fix dvd button background handling.
Refs #9860 Signed-off-by: Mark Kendall <mkendall@mythtv.org>
1 parent 801aebf commit 005276f

File tree

1 file changed

+21
-26
lines changed

1 file changed

+21
-26
lines changed

mythtv/libs/libmythtv/subtitlescreen.cpp

Lines changed: 21 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -536,32 +536,13 @@ void SubtitleScreen::DisplayDVDButton(AVSubtitle* dvdButton, QRect &buttonPos)
536536
QImage bg_image(hl_button->pict.data[0], w, h, w, QImage::Format_Indexed8);
537537
uint32_t *bgpalette = (uint32_t *)(hl_button->pict.data[1]);
538538

539-
bool blank = true;
540-
for (uint x = 0; (x < w) && bgpalette; x++)
541-
{
542-
for (uint y = 0; y < h; y++)
543-
{
544-
if (qAlpha(bgpalette[bg_image.pixelIndex(x, y)]) > 0)
545-
{
546-
blank = false;
547-
break;
548-
}
549-
}
550-
}
551-
552-
if (!blank)
553-
{
554-
QVector<unsigned int> bg_palette;
555-
for (int i = 0; i < AVPALETTE_COUNT; i++)
556-
bg_palette.push_back(bgpalette[i]);
557-
bg_image.setColorTable(bg_palette);
558-
bg_image = bg_image.convertToFormat(QImage::Format_ARGB32);
559-
AddScaledImage(bg_image, rect);
560-
VERBOSE(VB_PLAYBACK, LOC + "Added DVD button background");
561-
}
539+
QVector<unsigned int> bg_palette;
540+
for (int i = 0; i < AVPALETTE_COUNT; i++)
541+
bg_palette.push_back(bgpalette[i]);
542+
bg_image.setColorTable(bg_palette);
562543

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

575-
// scale highlight image to match OSD size, if required
556+
bg_image = bg_image.convertToFormat(QImage::Format_ARGB32);
576557
fg_image = fg_image.convertToFormat(QImage::Format_ARGB32);
577-
AddScaledImage(fg_image, buttonPos);
558+
559+
// set pixel of highlight area to highlight color
560+
for (int x=fg_rect.x(); x < fg_rect.x()+fg_rect.width(); ++x)
561+
{
562+
if ((x < 0) || (x > hl_button->w))
563+
continue;
564+
for (int y=fg_rect.y(); y < fg_rect.y()+fg_rect.height(); ++y)
565+
{
566+
if ((y < 0) || (y > hl_button->h))
567+
continue;
568+
bg_image.setPixel(x, y, fg_image.pixel(x-fg_rect.x(),y-fg_rect.y()));
569+
}
570+
}
571+
572+
AddScaledImage(bg_image, rect);
578573
}
579574

580575
void SubtitleScreen::DisplayCC608Subtitles(void)

0 commit comments

Comments
 (0)