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.

Newcomers DBPro Corner / partial transparency for sprite from .PNG picture

Author
Message
Laski apina
15
Years of Service
User Offline
Joined: 5th Sep 2009
Location:
Posted: 5th Sep 2009 20:25
I have searched the forum and all but still can't make this to work.

I thought it works like this:

load image "sprite.png",1
get image 1,0,0,100,100
sprite 1,x,y,1

So I wouldn't have to paste the picture to screen and then GET it, because that of course messes the transparency.

Help would be appreciated.
Dream And Death
18
Years of Service
User Offline
Joined: 21st Feb 2006
Location: The circus! Juggling job, kids and DBPro
Posted: 5th Sep 2009 21:18
load image "sprite.png",1
sprite 1,x,y,1

You've loaded the png as image 1 already...you don't need to 'get image' or anythign else.

"You get what everyone gets, you get a lifetime!" - Death, The Sandman Library

First you Dream, then you ... - Neil Gaiman, 2001
Virtual Nomad
Moderator
18
Years of Service
User Offline
Joined: 14th Dec 2005
Location: SF Bay Area, USA
Posted: 5th Sep 2009 21:21
try:
load image "sprite.png",1,1
sprite 1,x,y,1


Laski apina
15
Years of Service
User Offline
Joined: 5th Sep 2009
Location:
Posted: 5th Sep 2009 22:05
But wouldn't it just use the whole picture as the sprite. You see I keep many sprites in one file and would want to just cut them off one by one. Just like I have my drawn font in one file.
Rudolpho
18
Years of Service
User Offline
Joined: 28th Dec 2005
Location: Sweden
Posted: 5th Sep 2009 23:00
Yes, then you'd do it like you first wrote. That isn't the most efficient way though, and it won't retain transparency.
What you should instead do is make a memblock from the source image, then make another (smaller) memblock and copy the relevant pixels over there. You might have to read up on them, but image memblocks are very easy to grasp. Basically they're a map of 32-bit pixels (where the last byte is the alpha channel), preceeded by a header made up of the dwords WIDTH, HEIGHT and DEPTH. When using make memblock from image, the depth value is always (I think?) 32.

Grog Grueslayer
Valued Member
19
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 5th Sep 2009 23:50 Edited at: 5th Sep 2009 23:51
To deal with sprite sheets it's better to load the sheet as a bitmap then grab all the images you need off that sheet. Loading it as bitmap numbers 1 to 32 hides it from the user so you can do anything you want to the bitmap without the user seeing anything. When you're done change the working bitmap back to bitmap zero (which is the main screen). To save the alpha channel using GET IMAGE you just add SET BITMAP FORMAT 21 before the first bitmap creation or GET IMAGE command.



Laski apina
15
Years of Service
User Offline
Joined: 5th Sep 2009
Location:
Posted: 6th Sep 2009 09:22
Thank you Grog Grueslayer, that did the trick

Login to post a reply

Server time is: 2024-09-28 10:26:56
Your offset time is: 2024-09-28 10:26:56