Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Dark GDK / Blit only *parts* of an image?

Author
Message
Paisleys finest
18
Years of Service
User Offline
Joined: 11th Nov 2005
Location: In a house
Posted: 31st Mar 2007 13:37
I have 100 images of "enemy" sprites. Whenever an enemy is shot it's to explode into its component parts, a la Robotron 2084.

Problem - how best to extract the component parts of an image ON THE FLY.

I don't want to store the component parts in other images, so the question is: how do I blit only parts of an arbitrary image?

The images vary in width/height.

I was thinking of using the .NET equivalent of MAKE MEMORY FROM IMAGE then extracting the pixels I need, locking the back buffer and then writing them using pointer arith, but after my last experience with the back buffer (it was helluva slow, but then I was trying to update the entire screen at once lol) I'm hesitant.

Is there a better way or will writing (not reading) to the back buffer be OK this time, I don't expect to need to lock it for so many CPU cycles as before.

Regards, Scott T.

Looking for mature software developer to finish my Bruce Lee remake.. apply via email to MSN address.
IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 31st Mar 2007 16:50
I can't think of any way to do this with sprites & images - you can't paste part of an image, and although you can specify where in the texture a sprite starts, you can't specify the number of pixels to use in the texture.

The only way I can think of is to use a secondary bitmap, and to use the COPY BITMAP command to copy to your main screen buffer. If you create your secondary bitmap with an alpha layer, then the COPY BITMAP command should copy to your target correctly - never tried it myself though.

cypher0
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location:
Posted: 2nd Apr 2007 05:16
The .NET equiv of MakeMemblockFromImage / Bitmap is (Bitmap).LockPixels, though you'll just get a pointer like in DGDK and you will still have to do pointer arith, there really isn't a way around this.

Converting your bitmap to an image would allow the simpler method of using black as the transparent colour though:

(DGDK).Bitmap.SetCurrentBitmap(OldCB)
(DGDK).Image.GetImage(ID, X1, Y1, X2, Y2)

You could use then a fill routine to render component regions black (if they are constant colours), or create another image of the component part regions.

GDI32: int FloodFill(int hdc, int x, int y, int crColor)
Paisleys finest
18
Years of Service
User Offline
Joined: 11th Nov 2005
Location: In a house
Posted: 4th Apr 2007 15:28
Well, I saw the trick done with BlitzATron (a Blitz Basic variant of Robotron) so I'm sure it can be done with DarkGDK.

I think I will have to use MAKE MEMORY FROM IMAGE, extract the pixels I need, and then directly write to the back buffer, I can't think of any other way. Should be interesting!!!

I see there's a method that appears to get the IDirectDrawSurface * in the .NET interface, does it work or is it a stub?

Regards, Scott T.

Looking for mature software developer to finish my Bruce Lee remake.. apply via email to MSN address.

Login to post a reply

Server time is: 2024-09-28 23:18:38
Your offset time is: 2024-09-28 23:18:38