本文整理汇总了C++中VideoOutput::GetOSDBounds方法的典型用法代码示例。如果您正苦于以下问题:C++ VideoOutput::GetOSDBounds方法的具体用法?C++ VideoOutput::GetOSDBounds怎么用?C++ VideoOutput::GetOSDBounds使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类VideoOutput
的用法示例。
在下文中一共展示了VideoOutput::GetOSDBounds方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: DisplayDVDButton
void SubtitleScreen::DisplayDVDButton(AVSubtitle* dvdButton, QRect &buttonPos)
{
if (!dvdButton || !m_player)
return;
VideoOutput *vo = m_player->GetVideoOutput();
if (!vo)
return;
DeleteAllChildren();
SetRedraw();
float tmp = 0.0;
QRect dummy;
vo->GetOSDBounds(dummy, m_safeArea, tmp, tmp, tmp);
AVSubtitleRect *hl_button = dvdButton->rects[0];
uint h = hl_button->h;
uint w = hl_button->w;
QRect rect = QRect(hl_button->x, hl_button->y, w, h);
QImage bg_image(hl_button->pict.data[0], w, h, w, QImage::Format_Indexed8);
uint32_t *bgpalette = (uint32_t *)(hl_button->pict.data[1]);
QVector<uint32_t> bg_palette(4);
for (int i = 0; i < 4; i++)
bg_palette[i] = bgpalette[i];
bg_image.setColorTable(bg_palette);
// copy button region of background image
const QRect fg_rect(buttonPos.translated(-hl_button->x, -hl_button->y));
QImage fg_image = bg_image.copy(fg_rect);
QVector<uint32_t> fg_palette(4);
uint32_t *fgpalette = (uint32_t *)(dvdButton->rects[1]->pict.data[1]);
if (fgpalette)
{
for (int i = 0; i < 4; i++)
fg_palette[i] = fgpalette[i];
fg_image.setColorTable(fg_palette);
}
bg_image = bg_image.convertToFormat(QImage::Format_ARGB32);
fg_image = fg_image.convertToFormat(QImage::Format_ARGB32);
// 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);
}
示例2: DisplayAVSubtitles
void SubtitleScreen::DisplayAVSubtitles(void)
{
if (!m_player || !m_subreader)
return;
AVSubtitles* subs = m_subreader->GetAVSubtitles();
QMutexLocker lock(&(subs->lock));
if (subs->buffers.empty() && (kDisplayAVSubtitle != m_subtitleType))
return;
VideoOutput *videoOut = m_player->GetVideoOutput();
VideoFrame *currentFrame = videoOut ? videoOut->GetLastShownFrame() : NULL;
if (!currentFrame || !videoOut)
return;
float tmp = 0.0;
QRect dummy;
videoOut->GetOSDBounds(dummy, m_safeArea, tmp, tmp, tmp);
while (!subs->buffers.empty())
{
const AVSubtitle subtitle = subs->buffers.front();
if (subtitle.start_display_time > currentFrame->timecode)
break;
ClearDisplayedSubtitles();
subs->buffers.pop_front();
for (std::size_t i = 0; i < subtitle.num_rects; ++i)
{
AVSubtitleRect* rect = subtitle.rects[i];
bool displaysub = true;
if (subs->buffers.size() > 0 &&
subs->buffers.front().end_display_time <
currentFrame->timecode)
{
displaysub = false;
}
if (displaysub && rect->type == SUBTITLE_BITMAP)
{
// AVSubtitleRect's image data's not guaranteed to be 4 byte
// aligned.
QSize img_size(rect->w, rect->h);
QRect img_rect(rect->x, rect->y, rect->w, rect->h);
QRect display(rect->display_x, rect->display_y,
rect->display_w, rect->display_h);
// XSUB and some DVD/DVB subs are based on the original video
// size before the video was converted. We need to guess the
// original size and allow for the difference
int right = rect->x + rect->w;
int bottom = rect->y + rect->h;
if (subs->fixPosition || (currentFrame->height < bottom) ||
(currentFrame->width < right))
{
int sd_height = 576;
if ((m_player->GetFrameRate() > 26.0f) && bottom <= 480)
sd_height = 480;
int height = ((currentFrame->height <= sd_height) &&
(bottom <= sd_height)) ? sd_height :
((currentFrame->height <= 720) && bottom <= 720)
? 720 : 1080;
int width = ((currentFrame->width <= 720) &&
(right <= 720)) ? 720 :
((currentFrame->width <= 1280) &&
(right <= 1280)) ? 1280 : 1920;
display = QRect(0, 0, width, height);
}
QRect scaled = videoOut->GetImageRect(img_rect, &display);
QImage qImage(img_size, QImage::Format_ARGB32);
for (int y = 0; y < rect->h; ++y)
{
for (int x = 0; x < rect->w; ++x)
{
const uint8_t color = rect->pict.data[0][y*rect->pict.linesize[0] + x];
const uint32_t pixel = *((uint32_t*)rect->pict.data[1]+color);
qImage.setPixel(x, y, pixel);
}
}
if (scaled.size() != img_size)
{
qImage = qImage.scaled(scaled.width(), scaled.height(),
Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
}
MythPainter *osd_painter = videoOut->GetOSDPainter();
MythImage* image = NULL;
if (osd_painter)
image = osd_painter->GetFormatImage();
long long displayfor = subtitle.end_display_time -
subtitle.start_display_time;
if (displayfor == 0)
displayfor = 60000;
//.........这里部分代码省略.........