StretchBlt?? You must be joking, haha. Did you know that on average StretchBlt consumes 60% more processing time than BitBlt. That is expected though. Stretching is alittle more involved than block copying. StretchBlt is definately a GDI call I avoid at all costs.

I have tested stretchBlt against stretching the image via code yourself to a DIB Section and then using BitBlt to move it to the screen. My routines outperform StretchBlt dramatically. I do have to commend Blit() though. I can't outperform that!! That perks up my app royally. Now if I can get rid of that anti-alias feature that it is automating then I'll be all set.

But definately, if you are using a graphics intensive app, its best to create a DIB and then "stretch" directly to the bit data yourself using code. You can bypass all the GDI bounds checking and whatever else it does

of course - stretching at equal ratios is one thing 2:1,3:1,4:1, etc., that is easy to visualize with code, but stretching like this 2.3:1, 3.7:1. Thats a different matter, I think I would even falter and bow down to almighty StretchBlt:grin:
Posted on 2002-01-18 06:56:56 by Rockinronstar
Rockinronstar, Oh sorry miss-read your post, I thought you were using StretchBlt-----How bout GDI BitBlt ?---It doesn't antialias----and is real fast-----------
Posted on 2002-01-18 07:21:25 by BradB
Rockinronstar, Oh sorry miss-read your post, I thought you were using StretchBlt-----How bout GDI BitBlt ?---It doesn't antialias----and is real fast-----------

thats actually what I have been using. You are right, it is quite fast. I think that Blit() outperforms it though. On small images the difference isn't noticeable, but on 1024x768 images you can tell( abit, haha).

What I usually do is create a DIB, use my own stretching algorithms and stretch the original to this myself, then use BitBlt to transfer to screen.

It works quite well actually. Would like to get Blit() working perfectly, then I think I'll be at my max efficiency
Posted on 2002-01-18 07:37:29 by Rockinronstar
Just curious, for your algorithm's---are you stretching by pasting strips? ----how are you handling non-integers ?
Thanks, B
Also, have you worked any rotation algo's?
Posted on 2002-01-18 07:41:57 by BradB
Rockinronstar, Could optimize your stretch algo. MMX?
Should be as fast(er) as a memcpy, IMO. ;)
Posted on 2002-01-18 10:33:32 by bitRAKE
MMX??? Not sure how I could implement that? How can you use MMX in this case?
Posted on 2002-01-18 12:13:31 by Rockinronstar
About your problm with the Blit method, I have found this on the DX7 SDK from an 'old' CD.

The Blt method automatically re-scales the source image to fit the destination rectangle. If resizing is not your intention, for best performance you should make sure that your source and destination rectangles are exactly the same size, or else use IDirectDrawSurface7:BltFast. (See Blitting with BltFast.)

Hardware acceleration for scaling depends on the DDFXCAPS_BLT* flags in the dwFXCaps member of the DDCAPS structure for the device. If, for example, a device has the DDFXCAPS_BLTSTRETCHXN capability but not DDFXCAPS_BLTSTRETCHX, it can assist when the x-axis of the source rectangle is being multiplied by a whole number but not when non-integral (arbitrary) scaling is being done.

Devices might also support arithmetic scaling, which is scaling by interpolation rather than simple multiplication or deletion of pixels. For instance, if an axis was being increased by one-third, the pixels would be recolored to provide a closer approximation to the original image than would be produced by the doubling of every third pixel on that axis.

Applications cannot control the type of scaling done by the driver, except by setting the DDBLTFX_ARITHSTRETCHY flag in the dwDDFX member of the DDBLTFX structure passed to Blt. This flag requests that arithmetic stretching be done on the y-axis. Arithmetic stretching on the x-axis and arithmetic shrinking are not currently supported in the DirectDraw API, but a driver may perform them by default.
Posted on 2002-01-18 12:29:32 by LuHa
To use MMX for the stretch you'd have to write optimized algorithms for each 2x2, 3x3, 4x4, etc. method. Not an easy task, but certainly has it's rewards. It's basically used like an MMX copy, but with multiple stores. With prefetch it should only be limited by the bus speed.
Posted on 2002-01-18 22:03:06 by bitRAKE
Sounds very interesting Bitrake!! Think I will save that method for my advanced days, haha. I have very little PC Asm experience, and no MMX, Floating point experience. So I gotta learn the basics of those first and then tackle advanced methods.
Posted on 2002-01-20 12:13:19 by Rockinronstar