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 / Get image and transparency issues

Author
Message
DVader
20
Years of Service
User Offline
Joined: 28th Jan 2004
Location:
Posted: 13th Jun 2012 02:12
Hello, I have been playing around with a new game over the last couple of days and have encountered an annoying quirk with getimage(). I am grabbing an area that includes partial black areas to generate the sprites I need for the game. However when you use those images, the black parts which I want to be transparent, remain black.
I have got around this by saving the image, then reloading it using the flag for transparency, and using that for the sprites. However it seems a bit of a pain to have to do this, as it can generate a lot of image data, and even if deleted after use, it is a lot of extra work and slows things down even more than the actual grabbing.

basjak
14
Years of Service
User Offline
Joined: 16th Apr 2010
Location: feel like signing up for mars
Posted: 13th Jun 2012 03:34
simply because the image has not been saved on a particular format. better save the image then load it again.

Hodgey
15
Years of Service
User Offline
Joined: 10th Oct 2009
Location: Australia
Posted: 13th Jun 2012 03:36 Edited at: 13th Jun 2012 03:37
I just wrote up a quick demo using the getImage() command and the black parts weren't saved (i.e transparent). Try this out:



Note: this will save the grabbed image file in folder AppGameKit creates automatically in "Documents" so you can compare it to what's on the screen.

BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 13th Jun 2012 09:26
It may be related to my problem with getImage() and transparency:

http://forum.thegamecreators.com/?m=forum_view&t=196575&b=41

DVader
20
Years of Service
User Offline
Joined: 28th Jan 2004
Location:
Posted: 13th Jun 2012 15:33
The problem I have is not specifically backdrop black I am afraid. I am overlaying black tiles onto another image, which I then grab. So all it is grabbing is the two combined sprites. The black part is supposed to be transparent and so mask the textured part where needed. So I don't think that example would work any better, Hodgey. I haven't had chance to run your code though, just scan over it here as yet.
Saving the image as a png and reloading is fine, the image works as it should. Trying to simply use the image, however results in the masked parts remaining black. I am using render() before the grab, and clearscreen() after grabbing the image.
It could be related to your problem BatVink, but I have no actual alpha transparency applied. I think it is probably a bug or just not implemented properly yet.
I also cannot think of a way to grab an image larger than the screen as that gives blank space, or worse garbage.

BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 13th Jun 2012 16:56
Quote: "I also cannot think of a way to grab an image larger than the screen as that gives blank space, or worse garbage."


I'm glad you mentioned that, I had serious issues composing menu buttons offscreen. I get garbage too, but if I move the coordinates to within the screen area, it's okay again.

If I get time I'll create a quick sample for the bug list.

Marl
13
Years of Service
User Offline
Joined: 19th Nov 2011
Location: Bradford, UK
Posted: 13th Jun 2012 18:09
Quote: "I also cannot think of a way to grab an image larger than the screen as that gives blank space, or worse garbage."

I can understand the limitation as it is technically a screen grab so it makes sense it has to be from the screen.

Have you tried increasing the virtual resolution and then grabbing the image? in theory it should grab the image at the resolution of the screen, be it real or virtual.

I've not tried it, it's just an idea.
Hodgey
15
Years of Service
User Offline
Joined: 10th Oct 2009
Location: Australia
Posted: 14th Jun 2012 02:31
I see what you mean DVader. Maybe post an enhancement/bug report?

Quote: "I also cannot think of a way to grab an image larger than the screen as that gives blank space, or worse garbage."

One idea could be to use the SetScissor() offscreen but I had a quick go at that and couldn't get it working. I'll try some more experimentation when I have the time.

DVader
20
Years of Service
User Offline
Joined: 28th Jan 2004
Location:
Posted: 20th Jun 2012 21:30
Quote: "I can understand the limitation as it is technically a screen grab so it makes sense it has to be from the screen."

I also see the sense of this however, it does not have to work like that as DB has no problems at all grabbing off screen. The way it works at the moment limits what I am trying to do quite badly on mobile devices, as the resolution is pretty low.
I'm not sure about the set scissor command, as I need to grab both on screen and off screen objects. I'm not really familiar with the command as yet, so will have to see how it works.

Login to post a reply

Server time is: 2024-11-23 16:40:41
Your offset time is: 2024-11-23 16:40:41