Trans. Images
Moderators: Shine, Insert_witty_name
-
- Posts: 53
- Joined: Wed Aug 31, 2005 1:43 am
Trans. Images
I noticed that on the first function I call, I can use transparent images but if i press (X) to go to the next function, it wont blit the pic as transparent. Is this a bug or is there something Im doing wrong?
I want my money back!?
-
- Posts: 53
- Joined: Wed Aug 31, 2005 1:43 am
44 views and no help? Common ppl! :P
Ok, I have created a sample code to show you what im talking about.
Blank.png = 480*272 blank image with colors of (77,77,77)
Trans.png = 138*126 blank image with colors of (255,255,255) Opacity of 50%
Ok, I have created a sample code to show you what im talking about.
Blank.png = 480*272 blank image with colors of (77,77,77)
Trans.png = 138*126 blank image with colors of (255,255,255) Opacity of 50%
Code: Select all
-------------------------------------------
-- USB
System.usbDiskModeActivate()
-------------------------------------------
-------------------------------------------
-- Load Images
Skin = {
First = Image.load("Blank.png"),
TransPic = Image.load("Trans.png")
}
-------------------------------------------
-------------------------------------------
-- Main App
function MainApp()
while true do
pad = Controls.read()
screen:blit(0,0, Skin.First)
if pad:cross() then
SecApp()
end
if pad:square() then
screen:blit(50,50, Skin.TransPic)
end
if pad:start() then
break
end
screen.waitVblankStart()
screen.flip()
end
end
-------------------------------------------
-------------------------------------------
-- Second App
function SecApp()
while true do
pad = Controls.read()
screen:blit(50,50, Skin.TransPic)
if pad:start() then
break
end
screen.waitVblankStart()
screen.flip()
end
end
-------------------------------------------
-------------------------------------------
while not Controls.read():start() do
MainApp()
end
-------------------------------------------
I want my money back!?
-
- Posts: 53
- Joined: Wed Aug 31, 2005 1:43 am
ok, if you press square it will blit the image with transparent just like its supose to. However if you press cross it will load the second function but the image is no longer transparent, just a white square. I was wonder if this is something i am doing wrong or if its a bug, or if it can only blit trans images to the first function.
I want my money back!?
This is by design. When you press square, first the Skin.First image is blitted, which sets the screen to a fixed color, then your Skin.TransPic is blitted and all this in a loop. When you press cross, Skin.TransPic is blitted in a loop. Blitting Skin.TransPic the first time it is merged with the background with an alpha value of 50%. The second time there is already a bit white and Skin.TransPic is merged with this and so forth, until there is white only.2Xtremes2004 wrote:I was wonder if this is something i am doing wrong or if its a bug, or if it can only blit trans images to the first function.
-
- Posts: 53
- Joined: Wed Aug 31, 2005 1:43 am
Um. Maybe a stupid question: Does this mean transparent PNGs are now supported in the latest Lua Player?
I tried something similar with a normal screen:blit using a gradient (black to transparent) 24-bit PNG created in Photoshop, resulting in only the first, black, line (i.e at 100% opacity) being blitted.
I can't see anything special in the code example above that sets the transparency apart from alpha data inside the PNG. Can't see any reference to transparancy in the function reference either.
Anyone able to shed some light on this?
I tried something similar with a normal screen:blit using a gradient (black to transparent) 24-bit PNG created in Photoshop, resulting in only the first, black, line (i.e at 100% opacity) being blitted.
I can't see anything special in the code example above that sets the transparency apart from alpha data inside the PNG. Can't see any reference to transparancy in the function reference either.
Anyone able to shed some light on this?
Thanks for the reply. But, where do I enable partial transparency?
The function reference for blit still says "nil image:blit(x, y, Image source, [sourcex, sourcey, width, height], [alpha = true])". Does this mean that transparency should be set when creating the PNG image (if so, I haven't managed it - see my post above), or as a percentage for alpha (i.e not a boolean value as stated in the reference?
The function reference for blit still says "nil image:blit(x, y, Image source, [sourcex, sourcey, width, height], [alpha = true])". Does this mean that transparency should be set when creating the PNG image (if so, I haven't managed it - see my post above), or as a percentage for alpha (i.e not a boolean value as stated in the reference?