 |
forums.ps2dev.org Homebrew PS2, PSP & PS3 Development Discussions
|
| View previous topic :: View next topic |
| Author |
Message |
KcDan
Joined: 24 Jan 2006 Posts: 13 Location: Delaware
|
Posted: Tue Jan 24, 2006 11:53 am Post subject: 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
 |
|
| Back to top |
|
 |
fullerlee
Joined: 03 Nov 2005 Posts: 54
|
Posted: Thu Jan 26, 2006 5:12 am Post subject: |
|
|
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 |
|
| Back to top |
|
 |
KcDan
Joined: 24 Jan 2006 Posts: 13 Location: Delaware
|
Posted: Thu Jan 26, 2006 6:58 am Post subject: |
|
|
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:
| Code: |
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) |
 |
|
| Back to top |
|
 |
mrn
Joined: 02 Nov 2005 Posts: 116
|
Posted: Fri Jan 27, 2006 4:00 am Post subject: |
|
|
Nice tools.
I'd propose to ALLOW "hot keys" whenever a message box appears by also printing them. Example:
[O OK] [X Cancel] [> Next] [< Prev] etc.
imho, such hot-keyes should become standard in the PSP-Lua world.. |
|
| Back to top |
|
 |
KcDan
Joined: 24 Jan 2006 Posts: 13 Location: Delaware
|
Posted: Fri Jan 27, 2006 12:03 pm Post subject: |
|
|
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)
| Code: |
--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)
|
|
|
| Back to top |
|
 |
romero126
Joined: 24 Dec 2005 Posts: 200
|
Posted: Sun Jan 29, 2006 12:24 pm Post subject: |
|
|
| hmm looks very familiar |
|
| Back to top |
|
 |
Zenurb
Joined: 30 Sep 2005 Posts: 106 Location: United Kingdom
|
Posted: Sun Jan 29, 2006 12:46 pm Post subject: |
|
|
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.) _________________ Proud Dvorak User
US 1.5 PSP (Original) |
|
| Back to top |
|
 |
KcDan
Joined: 24 Jan 2006 Posts: 13 Location: Delaware
|
Posted: Mon Jan 30, 2006 9:20 am Post subject: |
|
|
| 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 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. |
|
| Back to top |
|
 |
Zenurb
Joined: 30 Sep 2005 Posts: 106 Location: United Kingdom
|
Posted: Mon Jan 30, 2006 5:20 pm Post subject: |
|
|
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) |
|
| Back to top |
|
 |
my psprecious
Joined: 17 Feb 2006 Posts: 24
|
Posted: Fri Feb 17, 2006 5:26 am Post subject: |
|
|
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 |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|