Png

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

Moderators: Shine, Insert_witty_name

Post Reply
maweryck
Posts: 1
Joined: Sun Oct 16, 2005 11:34 pm

Png

Post by maweryck »

HI ALL

How to create the transparency in an image png for the psp?
ShUr1k3n
Posts: 42
Joined: Sun Oct 16, 2005 9:04 pm

Re: Png

Post by ShUr1k3n »

maweryck wrote:HI ALL

How to create the transparency in an image png for the psp?
Hi maweryck,

just use Paint Shop Pro, or any Image Editor that can "Write" PNG format.

ShUr1k3n
LuMo
Posts: 410
Joined: Sun Aug 21, 2005 2:45 am
Location: Austria
Contact:

Post by LuMo »

not sure if every image editor can do that (guess paint can't although it can read andwrite png's)
Photothop can do it, thats for sure :)

greets
"Good artists copy, great artists steal."
Pablo Picasso
go2lumo.com
MasterQ
Posts: 7
Joined: Sat Oct 01, 2005 10:05 am

Post by MasterQ »

use photoshop to make transparent pngs.

but keep in mind that luaplayer can only do full transparency on the pngs. there is no semi-transparency yet. in my opinion this should be put in the player in future versions, because the graphics look really crappy without anti-aliasing. i heard somewhere that they are working on it, though.
haust
Posts: 25
Joined: Sat Oct 01, 2005 12:37 am
Location: France

Post by haust »

ok, so how can i save 16 bits png files with photoshop. Currently I can only save in 4, 8 or 24 bits....
MikeHaggar
Posts: 116
Joined: Mon Jul 18, 2005 2:20 am

Post by MikeHaggar »

Erhm... Save as 24 bit...
link
Posts: 61
Joined: Wed Oct 19, 2005 6:17 am

Post by link »

what if you dont have photoshop? my program shows a checker board for transparent area but when you save it as .png it turns the transparent area into white. are there any free programs that i can use because i dont want to pay $800 dollars to make an inch of a picture transparent.

If i do save it in my program an then run the lua it is just a bunch of boxes with lines. Is there away around this problem? Even if i open the picture and dont do anything, then resave, it it will still be lines. Is there a code imbedded in the .png?
KawaGeo
Posts: 191
Joined: Sat Aug 27, 2005 6:52 am
Location: Calif Mountains

Post by KawaGeo »

I just wrote a function that converts all background in a solid color to transparency. The code is given below.

Code: Select all

function Image:transparentize(bgColor)
  local p
  local transparent = Color.new(0,0,0,0)
  local result = Image.createEmpty(self:width(), self:height())
  for x = 0, self:width()-1 do
    for y = 0, self:height()-1 do
      p = self:pixel(x, y)     -- returns a color
      if p == bgColor then
        result:pixel(x, y, transparent)
      else
        result:pixel(x, y, p)  -- copy the same color
      end
    end
  end
  return result
end
Write a couple of statements to do this...

Code: Select all

black = Color.new(0,0,0)  -- solid color (for an example)

newImage = oldImage:transparentize(black)
PS: You don't have to buy $800 software just to do the job. Hail to Lua Player! :)

PSS I made up the word, transparentize. What a better word is there?

PSSS The function will be included in my LPut library.

PSSSS ...er, never mind. :)
Geo Massar
Retired Engineer
link
Posts: 61
Joined: Wed Oct 19, 2005 6:17 am

Post by link »

Im i supposed to put this into my game code or run it sepperate? On psp or on PC?

PLEASE specify instructions. Where should i put the image that needs transparancy?

Give me some instructions PLEASE of what i should do.
haust
Posts: 25
Joined: Sat Oct 01, 2005 12:37 am
Location: France

Post by haust »

from what I see, you can just copy-paste the code in your game, load your image then transparentize it by specifying the transparency color and it should be ok.
Note that the transparency color should not be used in your non-transparent part of your image....

If I'm wrong someone will correct me.
LuMo
Posts: 410
Joined: Sun Aug 21, 2005 2:45 am
Location: Austria
Contact:

Post by LuMo »

how about that?
rename transparentize to setTransparentColor(color)

usually Color.new(255,0,255) is used as transparency mask, cause its used in very few cases ;)

greets
lumo
"Good artists copy, great artists steal."
Pablo Picasso
go2lumo.com
link
Posts: 61
Joined: Wed Oct 19, 2005 6:17 am

Post by link »

tiles = Image.load("tiles.png")
figure = Image.load("figure.png")


function Image:setTransparentColor(color)
local p
local transparent = Color.new(0,0,0,0)
local result = Image.createEmpty(self:width(), self:height())
for x = 0, self:width()-1 do
for y = 0, self:height()-1 do
p = self:pixel(x, y) -- returns a color
if p == bgColor then
result:pixel(x, y, transparent)
else
result:pixel(x, y, p) -- copy the same color
end
end
end
return result
end
black = Color.new(0,0,0) -- solid color (for an example)

newImage = Image:setTransparentColor(black)
..............

this is what i have. it keeps saying now that it cant perform arithmatic on a nil value. Any ideas?
LuMo
Posts: 410
Joined: Sun Aug 21, 2005 2:45 am
Location: Austria
Contact:

Post by LuMo »

<removed>
"Good artists copy, great artists steal."
Pablo Picasso
go2lumo.com
jimjamjahaa
Posts: 17
Joined: Mon Oct 03, 2005 5:00 am

Post by jimjamjahaa »

are there any free programs that i can use because i dont want to pay $800 dollars to make an inch of a picture transparent.
gimp

it is teh ownage
link
Posts: 61
Joined: Wed Oct 19, 2005 6:17 am

Post by link »

man gimp is awesome!!!! it free and you can do LOTS with it!!!! at first i expected a paint program or something since it was free but you can do just about anything!!! I highly recomend gimp to anyone
Post Reply