Drawing images with transparent parts
Moderators: Shine, Insert_witty_name
Drawing images with transparent parts
Hello, I'm Dan. I am currently working on a Shell that will emulate to an extent Windows, like controls such as windows, buttons, edit box's, static controls, and ect.
Currently I'm working on the cursor drawing. Im new to LUA but not to programming, I have no idea of how to make parts of an image transparent. I've read the LUA tutorial http://wiki.ps2dev.org/psp:lua_player:tutorial and I still dont understand how to do it. Could someone please enlighten me?
Here beith the image
Currently I'm working on the cursor drawing. Im new to LUA but not to programming, I have no idea of how to make parts of an image transparent. I've read the LUA tutorial http://wiki.ps2dev.org/psp:lua_player:tutorial and I still dont understand how to do it. Could someone please enlighten me?
Here beith the image
I've been using a paint program to specify transparent parts of the png. Blit in luaplayer will take into account whichever parts of the image are transparent.
If you don't have a paint program capable of doing this (such as Paint Shop Pro or Photoshop), try GIMP (http://www.gimp.org) - it's free and very good.
Lee
If you don't have a paint program capable of doing this (such as Paint Shop Pro or Photoshop), try GIMP (http://www.gimp.org) - it's free and very good.
Lee
Thanks, it now works as expected.
So far in my program I have implemented the creation of windows, buttons, static text, and progress bars. I'm going to add one or two more controls and then start working on the messaging system like windows has (SendMessageA(hwnd,msg,wparam,lparam)).
EDIT:
So far in my program I have implemented the creation of windows, buttons, static text, and progress bars. I'm going to add one or two more controls and then start working on the messaging system like windows has (SendMessageA(hwnd,msg,wparam,lparam)).
EDIT:
Code: Select all
hMsgBox=CreateWindow(20,20,200,100,"Notice")
hMsgBoxOk=CreateButton(7,4,50,15,"Ok",hMsgBox)
hMsgBoxcancel=CreateButton(146,83,50,15,"Cancel",hMsgBox)
hMsgBoxPBar=CreateProgressBar(5,59,150,20,0,100,50,hMsgBox)
hWin=CreateWindow(250,60,150,100,"Window")
hWinMsg=CreateStatic(20,10,96,80,"This is the message that is displayed.",hWin)
I've worked on this a lot and here's a screenshot of an app being run on it.
It's a fully working calculator. To close the window simply press the x in the top right corner of the window. Now to add windows being dragged by the titlebar...
Heres the code for the calculator to show how simple it was to make (thanks to KawaGeo and ema for evaluate method)
It's a fully working calculator. To close the window simply press the x in the top right corner of the window. Now to add windows being dragged by the titlebar...
Heres the code for the calculator to show how simple it was to make (thanks to KawaGeo and ema for evaluate method)
Code: Select all
--Main proc where all messages are sent
function MainProc(wnd,msg,wparam,lparam)
if wnd==hCalculator then
if msg==wm_lclick then
if wparam==hCalculator_1 then
CalculatorEquation=CalculatorEquation.."1"
elseif wparam==hCalculator_2 then
CalculatorEquation=CalculatorEquation.."2"
elseif wparam==hCalculator_3 then
CalculatorEquation=CalculatorEquation.."3"
elseif wparam==hCalculator_4 then
CalculatorEquation=CalculatorEquation.."4"
elseif wparam==hCalculator_5 then
CalculatorEquation=CalculatorEquation.."5"
elseif wparam==hCalculator_6 then
CalculatorEquation=CalculatorEquation.."6"
elseif wparam==hCalculator_7 then
CalculatorEquation=CalculatorEquation.."7"
elseif wparam==hCalculator_8 then
CalculatorEquation=CalculatorEquation.."8"
elseif wparam==hCalculator_9 then
CalculatorEquation=CalculatorEquation.."9"
elseif wparam==hCalculator_0 then
CalculatorEquation=CalculatorEquation.."0"
elseif wparam==hCalculator_equal then
script = "return "..CalculatorEquation
CalculatorEquation = assert(loadstring(script))()
elseif wparam==hCalculator_period then
CalculatorEquation=CalculatorEquation.."."
elseif wparam==hCalculator_plus then
CalculatorEquation=CalculatorEquation.."+"
elseif wparam==hCalculator_minus then
CalculatorEquation=CalculatorEquation.."-"
elseif wparam==hCalculator_mult then
CalculatorEquation=CalculatorEquation.."*"
elseif wparam==hCalculator_div then
CalculatorEquation=CalculatorEquation.."/"
elseif wparam==hCalculator_cls then
CalculatorEquation="0"
end
SetWindowText(hCalculator_ans,CalculatorEquation)
end
end
end
--Control creation
hCalculator=CreateWindow(20,20,157,172,"Calculator")
hCalculator_1=CreateButton(10,100,30,30,"1",hCalculator)
hCalculator_2=CreateButton(45,100,30,30,"2",hCalculator)
hCalculator_3=CreateButton(80,100,30,30,"3",hCalculator)
hCalculator_4=CreateButton(10,65,30,30,"4",hCalculator)
hCalculator_5=CreateButton(45,65,30,30,"5",hCalculator)
hCalculator_6=CreateButton(80,65,30,30,"6",hCalculator)
hCalculator_7=CreateButton(10,30,30,30,"7",hCalculator)
hCalculator_8=CreateButton(45,30,30,30,"8",hCalculator)
hCalculator_9=CreateButton(80,30,30,30,"9",hCalculator)
hCalculator_0=CreateButton(10,135,30,30,"0",hCalculator)
hCalculator_equal=CreateButton(80,135,30,30,"=",hCalculator)
hCalculator_period=CreateButton(45,135,30,30,".",hCalculator)
hCalculator_plus=CreateButton(115,30,30,30,"+",hCalculator)
hCalculator_minus=CreateButton(115,65,30,30,"-",hCalculator)
hCalculator_mult=CreateButton(115,100,30,30,"*",hCalculator)
hCalculator_div=CreateButton(115,135,30,30,"/",hCalculator)
hCalculator_ans=CreateStatic(10,5,100,20,"0",hCalculator)
hCalculator_cls=CreateButton(115,5,30,20,"C",hCalculator)
I have an initiate message, paint message, left click message, right click message, left and right over message, and a close message. Coding with it kinda sucks so Ima scratch this project and work on a better planned organized project like this. But for this being my first project in LUA and on PSP I'd say I did a pretty good job.Zenurb wrote:You could in theory emulate the entire windows drawing api.
Have you written some kind of events into your API? (e.g. mouse clicks bringing a window to topmost status, window movement, window painting, etc.)
I'd prefer to see a more object orientated language like Ruby become a PSP "Player" language. Ruby could probably be more easily intergrated into it and would allow for proper object orientatism. Sadly this probably wont come true :( I can't port it because I don't know a thing about C.
Proud Dvorak User
US 1.5 PSP (Original)
US 1.5 PSP (Original)
-
- Posts: 24
- Joined: Fri Feb 17, 2006 5:08 am
another thing you can do to .png that will help get smaller image is to turn them to indexed colr (yeah you only get 256 colors but you can do amazing stuff with 256 colors) and you can have the transparency to, good way to make smaller files.
lil update, indexed color will preserve the invisibility around the image but not transparency on an image, for that you need rgb
lil update, indexed color will preserve the invisibility around the image but not transparency on an image, for that you need rgb