views:

139

answers:

1

Hello!

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!

+1  A: 

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 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...

Max Gontar