RPGDXThe center of Indie-RPG gaming
Not logged in. [log in] [register]
 
 
Post new topic Reply to topic  
View previous topic - View next topic  
Author Message
Aptyp
Egg-Sucking Troll Humper


Joined: 09 Jun 2004
Posts: 36

PostPosted: 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:

PostPosted: Tue Jul 06, 2004 8:45 pm    Post subject: [quote]

There is a clipping class, I just don't remember its exact name. Lemme check msdn...

http://msdn.microsoft.com/archive/default.asp?url=/archive/en-us/ddraw7/directdraw7/ddref_9j1z.asp
Back to top  
janus
Mage


Joined: 29 Jun 2002
Posts: 464
Location: Issaquah, WA

PostPosted: 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

PostPosted: 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

PostPosted: 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  
Post new topic Reply to topic Page 1 of 1 All times are GMT
 



Display posts from previous:   
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum