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.

AppGameKit Classic Chat / SaveImage results in png image without alpha?

Author
Message
Naphier
15
Years of Service
User Offline
Joined: 2nd Oct 2010
Location: St Petersburg, Florida
Posted: 11th Jul 2014 21:11
So if I create an image with GetImage the resulting sprite has an alpha channel, but when I save the image the alpha channel is black.
Am I missing a setting?


Thanks!

Marl
14
Years of Service
User Offline
Joined: 19th Nov 2011
Location: Bradford, UK
Posted: 12th Jul 2014 17:05
This probably one for Paul, but you could double check the sprite alpha is coming from the image alpha channel (rather than just being a transparent colour) by making a second image from the alpha channel and saving that.
Van B
Moderator
23
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 17th Jul 2014 09:53
To get alpha on bitmaps (which your reading the image from), try using BITMAP FORMAT 21 at the start of your program.

A bit obscure I know, but I think that will do the trick.

I am the one who knocks...
Naphier
15
Years of Service
User Offline
Joined: 2nd Oct 2010
Location: St Petersburg, Florida
Posted: 17th Jul 2014 10:06
Thanks but just gave that a go and the compiler doesn't understand it. Looks like a DBPro command.

No worries though, I just decided not to save the image to the drive. I really only need it for a single image in my current project so it's not a big deal.

Van B
Moderator
23
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 17th Jul 2014 13:42
Ach, for some reason I thought this was DBPro, sorry about that.

I am the one who knocks...
MASTER OF PUPPETS
22
Years of Service
User Offline
Joined: 9th Jun 2004
Location: Trapped Under Ice
Posted: 18th Jul 2014 14:11 Edited at: 18th Jul 2014 14:14
Perhaps you won't use it, but maybe we can solve the issue on this thread. That way, anyone that stumbles across this thread while searching for a solution, may find the answer here. I placed this modified code at the beginning of a program:



In "Document/AGK/[-project name here-]", I find that it creates a white 32*32 pixel box in a 64*64 pixel image. The alpha channel appears as it should (in quadrants 1 , 3 ,and 4). Are these results repeated with you guys?

|,,|, (Dead Knot Broken) ,|,,|
Naphier
15
Years of Service
User Offline
Joined: 2nd Oct 2010
Location: St Petersburg, Florida
Posted: 18th Jul 2014 18:33
Thanks for getting me to stab at this again.
So here's what happens:
Your code works just fine, but if you introduce any other sprites, like a background sprite it also gets caught in the image.
Why? Apparently, Render()...
So all we need is
CreateSprite
ClearScreen
DrawSprite
GetImage

Then it works like a charm no matter what other sprites you already have. I've still decided to not save my image because the image created is non-power of 2 and to ensure that it is AND generate a subimages.txt file just isn't worth the extra work for a single image. Maybe someday I'll work up a nice API for doing something like this with multiple images being packed into an atlas in the future.

Cheers!

Login to post a reply

Server time is: 2026-07-26 08:03:28
Your offset time is: 2026-07-26 08:03:28