| View previous topic :: View next topic |
| Author |
Message |
swordman
Joined: 27 Dec 2005 Posts: 27
|
Posted: Fri Mar 31, 2006 5:59 am Post subject: Alpha Mask |
|
|
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 |
|
 |
CT_Bolt
Joined: 04 Mar 2006 Posts: 14 Location: Computer Chair
|
Posted: Fri Mar 31, 2006 6:16 am Post subject: Oops... |
|
|
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 |
|
 |
CT_Bolt
Joined: 04 Mar 2006 Posts: 14 Location: Computer Chair
|
Posted: Fri Mar 31, 2006 6:27 am Post subject: Check it out. |
|
|
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 |
|
 |
swordman
Joined: 27 Dec 2005 Posts: 27
|
Posted: Fri Mar 31, 2006 9:25 pm Post subject: |
|
|
| Thanks CT_Bolt! Your code is perfect! |
|
| Back to top |
|
 |
CT_Bolt
Joined: 04 Mar 2006 Posts: 14 Location: Computer Chair
|
Posted: Sat Apr 01, 2006 3:20 am Post subject: No problem |
|
|
| 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 |
|
 |
swordman
Joined: 27 Dec 2005 Posts: 27
|
Posted: Sat Apr 01, 2006 7:07 pm Post subject: |
|
|
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 |
|
 |
JorDy
Joined: 11 Dec 2005 Posts: 121
|
Posted: Sat Apr 01, 2006 8:18 pm Post subject: |
|
|
| i had that problem with the :pixel(x,y) function i solved it by setting the ammount of pixeld to cover as but the code seems fine to me |
|
| Back to top |
|
 |
CT_Bolt
Joined: 04 Mar 2006 Posts: 14 Location: Computer Chair
|
Posted: Sun Apr 02, 2006 8:07 am Post subject: Ahh... oh yeah. |
|
|
| Hmm... I see... yes I did overlook that... well thanks for fixing it. |
|
| Back to top |
|
 |
|