forums.ps2dev.org Forum Index forums.ps2dev.org
Homebrew PS2, PSP & PS3 Development Discussions
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Alpha Mask

 
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Lua Player Development
View previous topic :: View next topic  
Author Message
swordman



Joined: 27 Dec 2005
Posts: 27

PostPosted: Fri Mar 31, 2006 5:59 am    Post subject: Alpha Mask Reply with quote

Hi! Is there a way to use an image as alpha mask to others?
Also a B/W one could be fine;)
Thanks!
Back to top
View user's profile Send private message
CT_Bolt



Joined: 04 Mar 2006
Posts: 14
Location: Computer Chair

PostPosted: Fri Mar 31, 2006 6:16 am    Post subject: Oops... Reply with quote

My I.E. glitched and sent my post twice.

Last edited by CT_Bolt on Fri Mar 31, 2006 6:30 am; edited 1 time in total
Back to top
View user's profile Send private message Yahoo Messenger
CT_Bolt



Joined: 04 Mar 2006
Posts: 14
Location: Computer Chair

PostPosted: Fri Mar 31, 2006 6:27 am    Post subject: Check it out. Reply with quote

I have made a function for the Image Class that does just that... It makes an alpha mask of the image that calls the function 'AlphaImage' and sets it to anouther image.

Use it like this:
Code:
X = 0 ; Y = 0 ; Color.new(200,0,0,200)
MyImagesAlphaMask = MyImage.AlphaImage(X, Y, Colour)
My Alpha Function: Click Here
Back to top
View user's profile Send private message Yahoo Messenger
swordman



Joined: 27 Dec 2005
Posts: 27

PostPosted: Fri Mar 31, 2006 9:25 pm    Post subject: Reply with quote

Thanks CT_Bolt! Your code is perfect!
Back to top
View user's profile Send private message
CT_Bolt



Joined: 04 Mar 2006
Posts: 14
Location: Computer Chair

PostPosted: Sat Apr 01, 2006 3:20 am    Post subject: No problem Reply with quote

Well I am happy you can use it... if you have any other problems just post them and I'll be happy to help.
Back to top
View user's profile Send private message Yahoo Messenger
swordman



Joined: 27 Dec 2005
Posts: 27

PostPosted: Sat Apr 01, 2006 7:07 pm    Post subject: Reply with quote

Hi CT_Bolt
I do some more test but at some point i get errors al line

Code:

color = self:pixel(XPos,YPos)


Something aboute XPos or YPos meke them unvalid.
So I rewrite the function myself.
If it could be usefull, here it is

Code:

function Mask(ToDraw,Mask,Alpha)
  if not Alpha then Alpha = Color.new(0,0,0,0) end
  Masked = Image.createEmpty(Mask:width(),Mask:height())
  Masked:clear(Color.new(0,0,0,0))
  for xp = 0, Mask:width()-1 do
    for yp = 0, Mask:height()-1 do
      pix = Mask:pixel(xp,yp)
      c = pix:colors()
      if  not (c.a == 0) then
        Masked:fillRect(xp,yp,1,1,ToDraw:pixel(xp,yp))
      end
    end
  end
  return Masked
end


The main idea is the same, but i cuold use it without error.
Thanks Again!
Back to top
View user's profile Send private message
JorDy



Joined: 11 Dec 2005
Posts: 121

PostPosted: Sat Apr 01, 2006 8:18 pm    Post subject: Reply with quote

i had that problem with the :pixel(x,y) function i solved it by setting the ammount of pixeld to cover as
Code:
Image:width()-1
but the code seems fine to me
Back to top
View user's profile Send private message
CT_Bolt



Joined: 04 Mar 2006
Posts: 14
Location: Computer Chair

PostPosted: Sun Apr 02, 2006 8:07 am    Post subject: Ahh... oh yeah. Reply with quote

Hmm... I see... yes I did overlook that... well thanks for fixing it.
Back to top
View user's profile Send private message Yahoo Messenger
Display posts from previous:   
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Lua Player Development All times are GMT + 10 Hours
Page 1 of 1

 
Jump to:  
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