Question

I know it is possible, and a lot faster than using GDI+. However I haven't found any good example of using DirectX to resize an image and save it to disk. I have implemented this over and over in GDI+, thats not difficult. However GDI+ does not use any hardware acceleration, and I was hoping to get better performance by tapping into the graphics card.

Was it helpful?

Solution

Do you really need to use DirectX? GDI+ does the job well for resizing images. In DirectX, you don't really need to resize images, as most likely you'll be displaying your images as textures. Since textures can only applies on 3d object (triangles/polygons/mesh), the size of the 3d object and view port determines the actual image size displayed. If you need to scale your texture within the 3d object, just play the texture coordinate or matrix.

To manipute the texture, you can use alpha blending, masking and all sort of texture manipulation technique, if that's what you're looking for. To manipulate individual pixel like GDI+, I still think GDI+ is the way to do. DirectX was never mend to do image manipulation.

OTHER TIPS

You can load the image as a texture, texture-map it onto a quad and draw that quad in any size on the screen. That will do the scaling. Afterwards you can grab the pixel-data from the screen, store it in a file or process it further.

It's easy. The basic texturing DirectX examples that come with the SDK can be adjusted to do just this.

However, it is slow. Not the rendering itself, but the transfer of pixel data from the screen to a memory buffer.

Imho it would be much simpler and faster to just write a little code that resizes an image using bilinear scaling from one buffer to another.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top