本文整理汇总了C++中VideoOutput::GetImageRect方法的典型用法代码示例。如果您正苦于以下问题:C++ VideoOutput::GetImageRect方法的具体用法?C++ VideoOutput::GetImageRect怎么用?C++ VideoOutput::GetImageRect使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类VideoOutput
的用法示例。
在下文中一共展示了VideoOutput::GetImageRect方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: AddScaledImage
void SubtitleScreen::AddScaledImage(QImage &img, QRect &pos)
{
VideoOutput *vo = m_player->GetVideoOutput();
if (!vo)
return;
QRect scaled = vo->GetImageRect(pos);
if (scaled.size() != pos.size())
{
img = img.scaled(scaled.width(), scaled.height(),
Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
}
MythPainter *osd_painter = vo->GetOSDPainter();
MythImage* image = NULL;
if (osd_painter)
image = osd_painter->GetFormatImage();
if (image)
{
image->Assign(img);
MythUIImage *uiimage = new MythUIImage(this, "dvd_button");
if (uiimage)
{
m_refreshArea = true;
uiimage->SetImage(image);
uiimage->SetArea(MythRect(scaled));
}
}
}
示例2: DisplayBDOverlay
void BDOverlayScreen::DisplayBDOverlay(BDOverlay *overlay)
{
if (!overlay || !m_player)
return;
if (!overlay->m_data)
{
m_overlayArea = overlay->m_position;
SetArea(MythRect(m_overlayArea));
DeleteAllChildren();
m_overlayMap.clear();
SetRedraw();
LOG(VB_PLAYBACK, LOG_INFO, LOC +
QString("Initialised Size: %1x%2 (%3+%4) Plane: %5 Pts: %6")
.arg(overlay->m_position.width())
.arg(overlay->m_position.height())
.arg(overlay->m_position.left())
.arg(overlay->m_position.top())
.arg(overlay->m_plane)
.arg(overlay->m_pts));
BDOverlay::DeleteOverlay(overlay);
return;
}
if (!m_overlayArea.isValid())
{
LOG(VB_GENERAL, LOG_ERR, LOC +
"Error: Overlay image submitted before initialisation.");
}
VideoOutput *vo = m_player->GetVideoOutput();
if (!vo)
return;
QRect rect = overlay->m_position;
QString hash = QString("%1+%2+%3x%4")
.arg(rect.left()).arg(rect.top())
.arg(rect.width()).arg(rect.height());
// remove if we already have this overlay
if (m_overlayMap.contains(hash))
{
LOG(VB_PLAYBACK, LOG_DEBUG, LOC + QString("Removing %1 (%2 left)")
.arg(hash).arg(m_overlayMap.size()));
MythUIImage *old = m_overlayMap.take(hash);
DeleteChild(old);
}
// convert the overlay palette to ARGB
uint32_t *origpalette = (uint32_t *)(overlay->m_palette);
QVector<unsigned int> palette;
for (int i = 0; i < 256; i++)
{
int y = (origpalette[i] >> 0) & 0xff;
int cr = (origpalette[i] >> 8) & 0xff;
int cb = (origpalette[i] >> 16) & 0xff;
int a = (origpalette[i] >> 24) & 0xff;
int r = int(y + 1.4022 * (cr - 128));
int b = int(y + 1.7710 * (cb - 128));
int g = int(1.7047 * y - (0.1952 * b) - (0.5647 * r));
if (r < 0) r = 0;
if (g < 0) g = 0;
if (b < 0) b = 0;
if (r > 0xff) r = 0xff;
if (g > 0xff) g = 0xff;
if (b > 0xff) b = 0xff;
palette.push_back((a << 24) | (r << 16) | (g << 8) | b);
}
// convert the image to QImage
QImage img(rect.size(), QImage::Format_Indexed8);
memcpy(img.bits(), overlay->m_data, rect.width() * rect.height());
img.setColorTable(palette);
img.convertToFormat(QImage::Format_ARGB32);
// add to screen
QRect scaled = vo->GetImageRect(rect);
if (scaled.size() != rect.size())
{
img = img.scaled(scaled.width(), scaled.height(),
Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
}
MythPainter *osd_painter = vo->GetOSDPainter();
MythImage* image = NULL;
if (osd_painter)
image = osd_painter->GetFormatImage();
if (image)
{
image->Assign(img);
MythUIImage *uiimage = new MythUIImage(this, "bdoverlay");
if (uiimage)
{
uiimage->SetImage(image);
uiimage->SetArea(MythRect(scaled));
m_overlayMap.insert(hash, uiimage);
LOG(VB_PLAYBACK, LOG_DEBUG, LOC + QString("Added %1 (%2 tot)")
.arg(hash).arg(m_overlayMap.size()));
}
//.........这里部分代码省略.........
示例3: 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;
//.........这里部分代码省略.........