gpt4 book ai didi

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

转载 作者:塔克拉玛干 更新时间:2023-11-03 07:36:57 29 4
gpt4 key购买 nike

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

调查adobe premiere cs4 sdk我无法快速找到答案 - 可能吗?

请提供一些 sample !

谢谢!

最佳答案

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

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

更新 alt text http://img413.imageshack.us/img413/6201/adobe.jpg工作示例,使用来自 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;
}
}

在函数clean memory的最后

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

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

关于C++ Adob​​e Premiere 视频过滤器 - 在输出视频帧中打印/绘制/渲染文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2513403/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com