0

I have a stream of jpeg pictures(25fps, aboud 1000x700) and i want to render it the screen with as less CPU usage as possible.

By now I found out a fast way to decompress jpeg images - it is a gdi+ api. On my machine it take about 50ns per frame. I don't know how do they manage to do it but it's true, libjpeg8 for example is a much much slower as remembered it.

I tried to use gdi+ to output a stretched picture but it uses to much CPU for such a simple job. So I switched to directx9. It's good for me, but I can't find a good way to convert a gdi+ picture to directx9 texture.

There are a lot of ways to do it and all of them slow and have high CPU usage.

One of them:

  1. get surface from texture
  2. get hdc from surface
  3. create gdi+ graphics from hdc
  4. draw without stretching (DrawI of flat API).

Another way:

  1. lock bits of image
  2. lock bits of surface
  3. copy bits

By the way D3DXCreateTextureFromFileInMemory is slow.

The question is how can I use an image as texture without copy overhead? Or what is the best way to convert image to texture?

nshy
  • 1,074
  • 8
  • 13
  • You pretty much have no choice, gdi images will be stored in the main pc memory, and textures are generally stored on graphics card memory, so at some point a copy is going to have to happen – jcoder Nov 23 '12 at 12:19
  • Ok. I guessed it, then how to make this copy fast, just like plain memcpy? By now it takes 10ms for copying just about 4Mb of memory. Something is wrong with pixel format or something? By the way isn't it strange that gdi+ drawing with stretching takes just same 10ms as without it? – nshy Nov 23 '12 at 15:44
  • Don't recreate your texture every frame? – Esme Povirk Nov 23 '12 at 19:41
  • @VincentPovirk I'dont. I measured only time of converting image to texture. Yes, `D3DXCreateTextureFromFileInMemory` creates texture but there is no options, d3dx api gives no possibility load jpeg into existing texture AFAIK. – nshy Nov 24 '12 at 05:27

0 Answers0