Public Group

# Getting a RECT from a directdraw surface? [RESOLVED]

This topic is 5125 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hello! Does anyone know if there's a way of getting a size RECT from a surface in DirectDraw? I need one for clipping, because at the moment I use the bitmap size at loadtime, but it's not very efficient or dynamic. Thanks for any help [Edited by - Naigewron on October 9, 2004 12:04:45 AM]

##### Share on other sites
Call something like GetSurfaceDesc on the surface you want, and the DDSD structure it returns will have the width and height.

##### Share on other sites
do you mean the size of the whole surface or just a section of the surface? if you mean the whole surface, you would have needed to specify the size on creation of the surface anyway... but if you need to find the size still, try the dwWidth and dwHeight properties of the surface description you needed to use to make the surface. for example:
//you would have your surface description declared:DDSURFACEDESC2 ddsd;//..and your RECT structure declared:RECT size;/*now you would set up dx and sizes and everything else... ORload the bitmap onto a surface (which is what i understand ur doing)*///.../*now you've set up dx/image surface and are ready to set 'size' up:you would use 'ddsd''s dwWidth and dwHeight properties to get the surface size:*/size.Left = 0;size.Top = 0;size.Right = ddsd.dwWidth;size.Bottom = ddsd.dwHeight;/*now you have the size of the surface in your 'size' RECT struct!*/

i really hope that all made sense and that its what ur asking for! if not, please specify more clearly what u r trying to achieve ;)

the_moo

edit: hey a fellow aussie! its nice to see someone on here from the same country!

##### Share on other sites
Off Topic:

Quote:
 edit: hey a fellow aussie! its nice to see someone on here from the same country!

AUSSIE! AUSSIE! AUSSIE!

Heh, there's a few of us around.

##### Share on other sites
kazgaroth - woooooo AUSSIE! *ahem* i guess there's more of us around than i thought ;) pity you all seem to live in melbourne... ;)

##### Share on other sites
Melbourne rocks, and you know it, hehe!

Thanks for the code sample, I'll try that out and come back whining for more if I can't figure it out [grin]

##### Share on other sites
Thanks, that worked beautifully. Never realized you could use a SURFACEDESC object! Cheers!

##### Share on other sites
not a problem Naigewron ;) glad it worked for ya.

just one last thing: i find it very ironic that this thread had posts from almost only aussies...!

1. 1
Rutin
31
2. 2
3. 3
4. 4
5. 5

• 13
• 53
• 11
• 10
• 14
• ### Forum Statistics

• Total Topics
632967
• Total Posts
3009553
• ### Who's Online (See full list)

There are no registered users currently online

×