views:

272

answers:

2

I am programming in windows c++. I want to know which is the fasted method to draw a DIB onto Screen. The image maybe stretched.

Faster than StretchDIBits, Faster than SetDIBitsToDevice. Faster than StretchBits.

and with high stretch quality.

Many thanks!

+1  A: 

The API function StretchDIBits will take advantage of hardware, I think. Other than that, take a look at BitBlt / StretchBlt.

Also, there are some other questions concerning StretchDIBits that you might take a look at, if you take that route.


If you're unsatisfied by these methods, I don't know what else to tell you. Your CPU can only do so much. Make sure you're caching results of operations when you can and only updating what you need. Look into OpenGL or DirectX to take full advantage of your graphics card.

GMan
many thanks! StretchDIBits is what I used. I want some API faster.
Actually most of the question is asked by myselfTT, still slow~~
A: 

From what I remember when I got a peek at Windows source code, Stretchblt was written by a summer intern in the mid-1980s and never got fixed. The same inefficient code has been carried through to all versions of Windows. On a few Windows mobile devices, StretchBlt will take advantage of 2D hardware acceleration, but not on Desktop Windows. Use DirectDraw on desktop windows to make use of 2D hardware acceleration and get a fast blit. In my desktop video game products, I have my own stretchblt code which stretches the bits in a memory buffer and then calls BitBlt to copy them to the display and that is considerably faster than simply calling StretchBlt.

What I believe is the main cause of StretchBlts failings is that the code is totally oblivious to the speed of cached/uncached memory and it thrashes the cache as it stretches the image.

BitBank
I'm pretty sure DirectDraw was deprecated years ago, unless it's been re-made in a recent version of DirectX.
GMan
DirectDraw is a component of DirectX which includes DirectInput and Direct3D. Not deprecated.
BitBank