View previous topic - View next topic |
Author |
Message |
Aptyp Egg-Sucking Troll Humper
Joined: 09 Jun 2004 Posts: 36
|
Posted: Tue Jul 06, 2004 7:44 pm Post subject: Generic image clipper |
[quote] |
|
Here's my stupid problem - suppose I have a generic DirectDraw surface A (source), which I want to blit to generic DirectDraw surface B (destination). Because DirectDraw doesn't do auto-clip, blit call will fail if A (or rather the source rectangle defined for A) will not fit in its entirety into B.
What is known at run-time is A and B's dimensions, and a point on B to which the blit will be performed. What is required is to calculate the four rectangle points on A that encircle the area to be copied to B.
I've written the code to calculate the blit source rectangle to clip whatever parts of A don't fit into B. But I don't like it.
If anyone here has a generic clipper code that does the same thing, I'd sure love to take a look at it.
|
|
Back to top |
|
|
Ninkazu Demon Hunter
Joined: 08 Aug 2002 Posts: 945 Location: Location:
|
|
Back to top |
|
|
janus Mage
Joined: 29 Jun 2002 Posts: 464 Location: Issaquah, WA
|
Posted: Wed Jul 07, 2004 12:50 am Post subject: |
[quote] |
|
Yep. If you attach a clipper, it does the work for you.
I think there's a bug in DirectDrawClipper7, if I remember, but that bug may have only affected VB. It was some sort of bug that occurred when you blitted to 0,0.
|
|
Back to top |
|
|
Aptyp Egg-Sucking Troll Humper
Joined: 09 Jun 2004 Posts: 36
|
Posted: Wed Jul 07, 2004 12:08 pm Post subject: |
[quote] |
|
Unfortunately that only works for primary and backbuffer surfaces, since IDirectDrawClipper needs HWND reference to get the clipping information. My code is required to work with any IDirectDrawSurface7. The problem is purely mathematical, I just thought I could save myself some time by using someone else's already proven code.
|
|
Back to top |
|
|
janus Mage
Joined: 29 Jun 2002 Posts: 464 Location: Issaquah, WA
|
Posted: Wed Jul 07, 2004 6:43 pm Post subject: |
[quote] |
|
Aptyp wrote: | Unfortunately that only works for primary and backbuffer surfaces, since IDirectDrawClipper needs HWND reference to get the clipping information. My code is required to work with any IDirectDrawSurface7. The problem is purely mathematical, I just thought I could save myself some time by using someone else's already proven code. |
You can create a clipper and give it a list of rectangles, I believe.
|
|
Back to top |
|
|