Trans. Images

Discuss using and improving Lua and the Lua Player specific to the PSP.

Moderators: Shine, Insert_witty_name

Post Reply
2Xtremes2004
Posts: 53
Joined: Wed Aug 31, 2005 1:43 am

Trans. Images

Post by 2Xtremes2004 »

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!?
2Xtremes2004
Posts: 53
Joined: Wed Aug 31, 2005 1:43 am

Post by 2Xtremes2004 »

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%

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!?
User avatar
JoshDB
Posts: 87
Joined: Wed Oct 05, 2005 3:54 am

Post by JoshDB »

Okay... What's your problem, more specifically?
2Xtremes2004
Posts: 53
Joined: Wed Aug 31, 2005 1:43 am

Post by 2Xtremes2004 »

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!?
Shine
Posts: 728
Joined: Fri Dec 03, 2004 12:10 pm
Location: Germany

Post by Shine »

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.
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
Posts: 53
Joined: Wed Aug 31, 2005 1:43 am

Post by 2Xtremes2004 »

Ok, thx for clearing that up. I now have it fixed :)
I want my money back!?
sjurk
Posts: 4
Joined: Thu Dec 08, 2005 9:37 am
Location: Oslo, Norway
Contact:

Post by sjurk »

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?
User avatar
JoshDB
Posts: 87
Joined: Wed Oct 05, 2005 3:54 am

Post by JoshDB »

The latst lua player supports aplha transparency from 0% to 100%, i.e. partial transparency
sjurk
Posts: 4
Joined: Thu Dec 08, 2005 9:37 am
Location: Oslo, Norway
Contact:

Post by sjurk »

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?
Post Reply