Log in

View Full Version : How do i use GDI functions on Avisynth frames?


Kiyone
13th May 2004, 15:22
Maybe this is a newbish question, i started few days ago to play a bit with the Simple Samples from the SDK. What i wanted to do is draw a rectangle by using GDI functions instead of drawing it directly like its done in the Sample.


// dst = Avisynth PVideoFrame
dstp = dst->GetWritePtr();
// constant values for testing
HBITMAP hbitmap = CreateBitmap(720, 480, 1, 32, dstp);
//create a temporary dc in memory.
HDC pDC = ::GetDC(0);
HDC TmpDC=CreateCompatibleDC(pDC);
HGDIOBJ TmpObj=SelectObject(TmpDC,hbitmap);
HDC dcBmp=CreateCompatibleDC(TmpDC);
// draw a filled rectangle
RECT pos;
SetRect(&pos, 1, 1, 34, 34);
FillRect(dcBmp, &pos, (HBRUSH) (COLOR_WINDOW+1));
SelectObject(dcBmp,TmpObj);
DeleteDC(dcBmp);


Compiled dll works just fine but without drawing anything to the destination frame, except of the source frame.

Any ideas what's wrong with the code or how i can achieve what i want to do?

bill_baroud
14th May 2004, 12:47
hmm, i got similar problem here, although it's to enable OpenGL operation on aviynth frame ;) (and my error is on the wglCreateContext() call). I use some dib section instead of bitmap perhaps it's worth looking at it ?

I'm keeping an eye on this really interesting topic :D

Richard Berg
14th May 2004, 21:52
Might missing a GDIFlush() cause that bug? I'm not very familiar with GDI. Anyway, look at text-overlay.cpp in the AVS source code for some examples.

Fizick
15th May 2004, 01:32
I have no answer, but question:
Can we use hardware GPU (Nvidia GForce etc) for fast some frame calculation and processing?

Richard Berg
15th May 2004, 08:23
Probably not effectively. They are not optimized for pulling rendered buffers out of video memory.

bill_baroud
16th May 2004, 18:49
Can we use hardware GPU (Nvidia GForce etc) for fast some frame calculation and processing?

that's what i'm trying to test, but i have some hard time to set up an offscreen opengl rendering context :/

Probably not effectively
well i have some code for fft and dwt calculation using gpu ;)

the best way to know if it works or not is to test it ;)

Fizick
24th May 2004, 00:07
I found the site http://gpgpu.org/

I am interesting in FFT, as my DePan plugin use it (in CPU) for frames correlation.

Fizick
6th June 2004, 10:20
Seems Avery is realizing similar task:
"One of the features I've been working on for 1.6.0 is the ability to do bicubic resampling in the video displays using hardware 3D support."
http://www.virtualdub.org/

Richard Berg
6th June 2004, 22:21
Interestingly, a few days after I replied here a friend pointed me to an online chat with the developers of a S3 card designed with new video features.

http://www.deltachrome.com/modules.php?name=Forums&file=viewtopic&t=90)http://www.deltachrome.com/modules.php?name=Forums&file=viewtopic&t=90
http://www.s3graphics.com/DeltaChromeFeatureDescription.html

I need to go read up on DXVA and pixel shaders, but this has possibilities.