C++ Adobe Premiere 视频过滤器 - 在输出视频帧中打印/绘制/渲染文本

发布于 2024-08-26 10:23:15 字数 226 浏览 5 评论 0原文

我想为 Adob​​e Premiere 编写视频过滤器,并且需要将一些文本打印/绘制/渲染到输出视频帧中。

调查 adobe Premiere cs4 sdk 我找不到快速答案 -是否可以?

请提供一些样品!

谢谢!

I want to write video filter for Adobe Premiere, and I need to print/draw/render some text into the output video frame.

Looking into adobe premiere cs4 sdk I couldn't find a quick answer - is it possible?

Please provide some samples!

Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

鸵鸟症 2024-09-02 10:23:15

我将尝试实现的一些策略:

  1. 使用 GDI 将文本绘制到帧大小的位图中(VideoHandle->piSuites->ppixFuncs->ppixGetBounds)
  2. 与位图像素重叠帧像素(VideoHandle->source)

UPDATE< /强>
替代文本 http://img413.imageshack.us/img413/6201/adobe.jpg< /a>
工作示例,使用 SDK 中的 Simple_Video_Filter 示例...

在 xFilter(短选择器,VideoHandle theData)函数的开头创建带有文本的位图:

TCHAR szBuffer[50] = {0};
RECT rect;
HDC hdc = GetDC(NULL);
int iLength = 0;
iLength = wsprintf(szBuffer, "Hello World!");
BITMAPINFO bmInfo;
memset(&bmInfo.bmiHeader,0,sizeof(BITMAPINFOHEADER));
bmInfo.bmiHeader.biSize=sizeof(BITMAPINFOHEADER);
bmInfo.bmiHeader.biWidth=100;
bmInfo.bmiHeader.biHeight=15;
bmInfo.bmiHeader.biPlanes=1;
bmInfo.bmiHeader.biBitCount = 32;
bmInfo.bmiHeader.biCompression = BI_RGB;
//create a temporary dc in memory.
HDC pDC = GetDC(0);
HDC TmpDC=CreateCompatibleDC(pDC);
//create a new bitmap and select it in the memory dc
BYTE *pbase;
HBITMAP TmpBmp=CreateDIBSection(pDC, &bmInfo,DIB_RGB_COLORS,(void**)&pbase,0,0);
HGDIOBJ TmpObj=SelectObject(TmpDC,TmpBmp);
SetRect(&rect, 0, 0, 100, 15);
DrawText(TmpDC, szBuffer, iLength, &rect, 32);

在设置过滤器的中间,而不是

redSource = (redSource + redAdd) & 0x000000ff;
greenSource = (greenSource + greenAdd) & 0x000000ff;
blueSource = (blueSource + blueAdd) & 0x000000ff;

使用

int x = vert;
int y = horiz;
if(x < 215 && y < 300)
{
    COLORREF c = GetPixel(TmpDC,y-200, 215 - x);
    if(0 == ((int)GetRValue(c)+(int)GetGValue(c)+(int)GetBValue(c)))
    {
        redSource =255;
        greenSource =255;
        blueSource =255;
    }
}

并在函数的末尾清理内存

SelectObject(TmpDC,TmpObj);
DeleteDC(TmpDC);

PS [有一天:)]需要在内存中存储一​​次位图,而不是每帧每次创建......

Some strategy I will try to implement:

  1. draw text with GDI into bitmap of frame size (VideoHandle->piSuites->ppixFuncs->ppixGetBounds)
  2. overlap frame pixels (VideoHandle->source) with bitmap pixels

UPDATE
alt text http://img413.imageshack.us/img413/6201/adobe.jpg
Working sample, using Simple_Video_Filter sample from SDK...

at the beginning of xFilter (short selector, VideoHandle theData) function create bitmap with text:

TCHAR szBuffer[50] = {0};
RECT rect;
HDC hdc = GetDC(NULL);
int iLength = 0;
iLength = wsprintf(szBuffer, "Hello World!");
BITMAPINFO bmInfo;
memset(&bmInfo.bmiHeader,0,sizeof(BITMAPINFOHEADER));
bmInfo.bmiHeader.biSize=sizeof(BITMAPINFOHEADER);
bmInfo.bmiHeader.biWidth=100;
bmInfo.bmiHeader.biHeight=15;
bmInfo.bmiHeader.biPlanes=1;
bmInfo.bmiHeader.biBitCount = 32;
bmInfo.bmiHeader.biCompression = BI_RGB;
//create a temporary dc in memory.
HDC pDC = GetDC(0);
HDC TmpDC=CreateCompatibleDC(pDC);
//create a new bitmap and select it in the memory dc
BYTE *pbase;
HBITMAP TmpBmp=CreateDIBSection(pDC, &bmInfo,DIB_RGB_COLORS,(void**)&pbase,0,0);
HGDIOBJ TmpObj=SelectObject(TmpDC,TmpBmp);
SetRect(&rect, 0, 0, 100, 15);
DrawText(TmpDC, szBuffer, iLength, &rect, 32);

in the middle where filter is set, instead of

redSource = (redSource + redAdd) & 0x000000ff;
greenSource = (greenSource + greenAdd) & 0x000000ff;
blueSource = (blueSource + blueAdd) & 0x000000ff;

use

int x = vert;
int y = horiz;
if(x < 215 && y < 300)
{
    COLORREF c = GetPixel(TmpDC,y-200, 215 - x);
    if(0 == ((int)GetRValue(c)+(int)GetGValue(c)+(int)GetBValue(c)))
    {
        redSource =255;
        greenSource =255;
        blueSource =255;
    }
}

and in the end of function clean memory

SelectObject(TmpDC,TmpObj);
DeleteDC(TmpDC);

PS [some day :)] need to store bitmap in memory once instead of creating each time per frame...

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文