右上OSD换行位置

rtmpsuck
XI.CHEN 6 months ago
parent 8dabf9aecc
commit d5b46fb343

@ -3421,6 +3421,8 @@ bool CPhoneDevice::PostProcessPhoto(const PHOTO_INFO& photoInfo, const vector<ID
cv::Point lt(0, mat.rows - fs - 20 * ratio);
cv::Point lt2(0, lt.y - 2 * ratio);
cv::Point rb(0 + textSize.width + 2 * ratio, lt2.y + textSize.height + 8 * ratio);
cv::Point rt(0 + textSize.width + 2 * ratio, mat.rows - fs - 20 * ratio);
if (rb.x > (int)width - 1)
{
@ -3467,6 +3469,16 @@ bool CPhoneDevice::PostProcessPhoto(const PHOTO_INFO& photoInfo, const vector<ID
}
else if (it->alignment == OSD_ALIGNMENT_TOP_RIGHT)
{
std::size_t newlinePos = it->text.find('\n');
if (newlinePos != std::string::npos)
{
std::string textBeforeNewline = it->text.substr(0, newlinePos);
std::string textAfterNewline = it->text.substr(newlinePos + 1);
if(textBeforeNewline.length()>=textAfterNewline.length())
textSize = ft2->getTextSize(textBeforeNewline, fontSize, thickness, &baseline);
else
textSize = ft2->getTextSize(textAfterNewline, fontSize, thickness, &baseline);
}
pt.x = width - textSize.width - it->x * ratio;
pt.y= it->y * ratio;
}

Loading…
Cancel
Save