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 

Creating Masks... Alpha Value

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



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

PostPosted: Mon Mar 27, 2006 5:29 am    Post subject: Creating Masks... Alpha Value Reply with quote

Ok so I know how to blit Alpha Images over top of other images but, only in rectangles.

Is there a way to just blit the image to the screen with an Alpha Mask like... it just draws an alpha value over the image only(with transparent parts).

This is so I can make just the player have a different tint instead of the rectangle of the player have the different tint.

Please any help would be much appreciated.
Back to top
View user's profile Send private message Yahoo Messenger
my psprecious



Joined: 17 Feb 2006
Posts: 24

PostPosted: Tue Mar 28, 2006 10:14 am    Post subject: Reply with quote

Why do you need it (well I already founs a use hehe), actually understand what your problem is, you want an image to overlay over and other, or are you trying to make the collision with the alpha of a character, if yes dude don't waste your time with that, rectangle for colision will do the trick.
Back to top
View user's profile Send private message
Kameku



Joined: 23 Mar 2006
Posts: 32
Location: Oregon, USA

PostPosted: Tue Mar 28, 2006 10:37 am    Post subject: Reply with quote

I'm pretty sure this would be rediculously not neccessary lol

Code:

image = Image.load("myimage.png")
grey = Color.new(127,127,127,127)

for y=1,image:width() do
 for x=1,image:height() do
  color = image:pixel(x,y)
  rgb = color:colors()
  if rgb:a() == 0 then
   image:fillRect(x,y,1,1,grey)
  end
 end
end


Not entirely sure that would work, but hey, worth a try.
Back to top
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger
CT_Bolt



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

PostPosted: Wed Mar 29, 2006 1:39 am    Post subject: Well... Reply with quote

With a litle bit of adjustments this actually works pretty well.
Here is the function I wrote with the help of Kameku's code:

Code:
function Image:DrawAlpha(X, Y, MaskColour, BGColour)
  if MaskColour then
    if not X then X = 0 end
    if not Y then Y = 0 end
    imgAlpha = Image.createEmpty(self:width(), self:height())
    for YPos=0,self:width()-1 do
     for XPos=0,self:height()-1 do
      color = self:pixel(XPos,YPos)
      rgb = color:colors()
      if rgb.a == 0 then
        if BGColour then screen:fillRect(XPos,YPos,1,1,BGColour) end
      else
        imgAlpha:fillRect(XPos,YPos,1,1,MaskColour)
      end
     end
    end
    screen:blit(X, Y, imgAlpha)
  end
end


Call it like this:
Code:
imgStar = Image.load("Star.PNG")
imgStar:DrawAlpha(0,0,Color.new(200,0,0,200))


AND... THANK YOU SO MUCH Kameku!!!
With this I can create lots of cool stuff.
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