[09 Oct 2009] My personal fight against alpha-channel ^_^
[09 Oct 2009] My personal fight against alpha-channel ^_^
Note: This is an archived post that was originally sent to the Hollywood mailing list on Fri, 09 Oct 2009 20:29:02 -0000
Hello guys, I'm not able to sort out how I can blit images with an alpha channel within a brush with alpha channel...
In details:
1. I create a brush
2. I create an alpha-channel for the above brush
3. I display brushes with an alpha-channel (png files) within the above brush (using SelectBrush)
4. I display the first brush to the display without results O_o' I'd like to have the first brush all transparent with the brush (at 3) with their original transparency levels
If I display the brushes (at 3) they are displayed correctly with their alpha channel I've assumed that the procedure should be:
- Create a brush
- Select its AlphaChannel
- Set Max transparency & Cls the brush
- Set Min transparency and display the brushes (at 3) to create their alpha-channeled zones
- Finally select the first brush and display the brushes (at same positions where I've created the alpha-channel "zones"
But I haven't succeded... I'm lost.
I'm missing myself in this thing, anyone can help? Can you provide an example?
Regards, Fabio
Hello guys, I'm not able to sort out how I can blit images with an alpha channel within a brush with alpha channel...
In details:
1. I create a brush
2. I create an alpha-channel for the above brush
3. I display brushes with an alpha-channel (png files) within the above brush (using SelectBrush)
4. I display the first brush to the display without results O_o' I'd like to have the first brush all transparent with the brush (at 3) with their original transparency levels
If I display the brushes (at 3) they are displayed correctly with their alpha channel I've assumed that the procedure should be:
- Create a brush
- Select its AlphaChannel
- Set Max transparency & Cls the brush
- Set Min transparency and display the brushes (at 3) to create their alpha-channeled zones
- Finally select the first brush and display the brushes (at same positions where I've created the alpha-channel "zones"
But I haven't succeded... I'm lost.
I'm missing myself in this thing, anyone can help? Can you provide an example?
Regards, Fabio
----------------------------
[Allanon] Fabio Falcucci | GitHub for recent works | Support me on Patreon for Hollywood libraries | ☆★ All my links ★☆
[Allanon] Fabio Falcucci | GitHub for recent works | Support me on Patreon for Hollywood libraries | ☆★ All my links ★☆
[10 Oct 2009] Re: My personal fight against alpha-channel ^_^
Note: This is an archived post that was originally sent to the Hollywood mailing list on Sat, 10 Oct 2009 06:59:28 -0000
The problem is that the alpha-channel from the base brush is effecting also the brush that is displayed on top of it, because the second brush is actually being made a part of the base brush---using SelectBrush(). This does not happen when the graphics are simply being layered on the display. If you use SetAlphaIntensity(), you can transfer the alpha-channel of the second brush to the alpha-channel of the base brush by using the #VANILLACOPY constant; but this still may not give you the desired result.
The problem is that the alpha-channel from the base brush is effecting also the brush that is displayed on top of it, because the second brush is actually being made a part of the base brush---using SelectBrush(). This does not happen when the graphics are simply being layered on the display. If you use SetAlphaIntensity(), you can transfer the alpha-channel of the second brush to the alpha-channel of the base brush by using the #VANILLACOPY constant; but this still may not give you the desired result.
- airsoftsoftwair
- Posts: 5443
- Joined: Fri Feb 12, 2010 2:33 pm
- Location: Germany
- Contact:
[11 Oct 2009] Re: My personal fight against alpha-channel ^_^
Note: This is an archived post that was originally sent to the Hollywood mailing list on Sun, 11 Oct 2009 10:34:59 +0200
If I didn't get you right, maybe you can make a little illustration that shows how the result shall look and then I can hopefully tell you how to achieve that look
I'm not sure what you want to do exactly but I think Paul has pointed already in the right direction: Using SetAlphaIntensity(#VANILLACOPY) allows you to copy dynamic alpha values to your brush. If you don't use #VANILLACOPY, you'll end up with static alpha values being copied, i.e. SetAlphaIntensity(128) would set every visible pixel's alpha to 128.I'm missing myself in this thing, anyone can help? Can you provide an example?
If I didn't get you right, maybe you can make a little illustration that shows how the result shall look and then I can hopefully tell you how to achieve that look
[11 Oct 2009] Re: My personal fight against alpha-channel ^_^
Note: This is an archived post that was originally sent to the Hollywood mailing list on Sun, 11 Oct 2009 21:06:21 -0000
Thank you both!! That was exactly what I was looking for!!! ^_^I'm not sure what you want to do exactly but I think Paul has pointed already in the right direction: Using SetAlphaIntensity(#VANILLACOPY) allows you to copy dynamic alpha values to your brush. If you don't use #VANILLACOPY, you'll end up with static alpha values being copied, i.e. SetAlphaIntensity(128) would set every visible pixel's alpha to 128.
If I didn't get you right, maybe you can make a little illustration that shows how the result shall look and then I can hopefully tell you how to achieve that look
----------------------------
[Allanon] Fabio Falcucci | GitHub for recent works | Support me on Patreon for Hollywood libraries | ☆★ All my links ★☆
[Allanon] Fabio Falcucci | GitHub for recent works | Support me on Patreon for Hollywood libraries | ☆★ All my links ★☆
[11 Oct 2009] Re: My personal fight against alpha-channel ^_^
Note: This is an archived post that was originally sent to the Hollywood mailing list on Sun, 11 Oct 2009 23:17:38 -0000
Since you are merging two brushes into one brush (one on top of another) using SelectBrush(), there is something that you might NOT like about transfering the alpha-channel data using #VANILLACOPY. The transparent areas of the second brush will become transparent for the base brush as well, so that you do not see the underlying brush in those areas. To get around this problem, you could try using something like the p_MergeAlphaChannels() function in the following script.
Since you are merging two brushes into one brush (one on top of another) using SelectBrush(), there is something that you might NOT like about transfering the alpha-channel data using #VANILLACOPY. The transparent areas of the second brush will become transparent for the base brush as well, so that you do not see the underlying brush in those areas. To get around this problem, you could try using something like the p_MergeAlphaChannels() function in the following script.
Code: Select all
sel1$=FileRequest("Select Background Image", "")
sel2$=FileRequest("Select Foreground Image", "")
XVar=StringRequest("X Offset", "Enter the desired X offset for the second image.", "", #NUMERICAL)
YVar=StringRequest("Y Offset", "Enter the desired Y offset for the second image.", "", #NUMERICAL)
LoadBrush(1, sel1$, {LoadAlpha=True})
LoadBrush(2, sel2$, {LoadAlpha=True})
Function p_MergeAlphaChannels(Brush1, Brush2, XOffset, YOffset)
Width1=GetAttribute(#BRUSH, Brush1, #ATTRWIDTH)
Height1=GetAttribute(#BRUSH, Brush1, #ATTRHEIGHT)
Width2=GetAttribute(#BRUSH, Brush2, #ATTRWIDTH)
Height2=GetAttribute(#BRUSH, Brush2, #ATTRHEIGHT)
SelectBrush(Brush1)
DisplayBrush(Brush2, XOffset, YOffset)
For x=0 To Min(Width2, Width1-XOffset)-1
For y=0 To Min(Height2, Height1-YOffset)-1
If XOffset+x<0 OR YOffset+y<0 Then Continue
SelectAlphaChannel(Brush1)
Local LevelOne=ReadPixel(XOffset+x, YOffset+y)
SelectAlphaChannel(Brush2)
Local LevelTwo=ReadPixel(x, y)
If LevelOne<LevelTwo
SelectAlphaChannel(Brush1)
SetAlphaIntensity(LevelTwo)
Plot(XOffset+x, YOffset+y)
EndIf
Next
Next
EndFunction
p_MergeAlphaChannels(1, 2, XVar, YVar)
SaveBrush(1, "Ram:New.png", $0, #IMGFMT_PNG)
[12 Oct 2009] Re: My personal fight against alpha-channel ^_^
Note: This is an archived post that was originally sent to the Hollywood mailing list on Mon, 12 Oct 2009 00:47:53 -0000
I'm sorry the code in the previous message came through looking so bad (my tabs got lost). Also, I just noticed that I forgot to make the Width1, Height1, Width2, and Height2 variables Local. (Oooops!)
I'm sorry the code in the previous message came through looking so bad (my tabs got lost). Also, I just noticed that I forgot to make the Width1, Height1, Width2, and Height2 variables Local. (Oooops!)
[16 Oct 2009] Re: My personal fight against alpha-channel ^_^
Note: This is an archived post that was originally sent to the Hollywood mailing list on Fri, 16 Oct 2009 20:02:55 -0000
Thank you for your sample code, its interesting even if I don't need to merge alpha-channels right now but can be usefull in the future Actually I've another problem: seems to me that when using Box() associated with SetFillStyle(#FILLTEXTURE, brushid) the alpha-channel is not copied... I'm missing something?
I know, I'm alpha-channel obsessed ^_^, forgive me
Regards, Fabio
Thank you for your sample code, its interesting even if I don't need to merge alpha-channels right now but can be usefull in the future Actually I've another problem: seems to me that when using Box() associated with SetFillStyle(#FILLTEXTURE, brushid) the alpha-channel is not copied... I'm missing something?
I know, I'm alpha-channel obsessed ^_^, forgive me
Regards, Fabio
----------------------------
[Allanon] Fabio Falcucci | GitHub for recent works | Support me on Patreon for Hollywood libraries | ☆★ All my links ★☆
[Allanon] Fabio Falcucci | GitHub for recent works | Support me on Patreon for Hollywood libraries | ☆★ All my links ★☆
- airsoftsoftwair
- Posts: 5443
- Joined: Fri Feb 12, 2010 2:33 pm
- Location: Germany
- Contact:
[19 Oct 2009] Re: Re: My personal fight against alpha-channel ^_^
Note: This is an archived post that was originally sent to the Hollywood mailing list on Mon, 19 Oct 2009 11:11:58 +0200
No, textures currently don't support alpha channel or masks. They're always opaque. If you want alpha channel, you have to write the texturing code for yourself but it's not that hardThank you for your sample code, its interesting even if I don't need to merge alpha-channels right now but can be usefull in the future Actually I've another problem: seems to me that when using Box() associated with SetFillStyle(#FILLTEXTURE, brushid) the alpha-channel is not copied... I'm missing something?
[22 Oct 2009] Re: My personal fight against alpha-channel ^_^
Note: This is an archived post that was originally sent to the Hollywood mailing list on Thu, 22 Oct 2009 21:24:20 -0000
Fabio
Maybe it's not hard but for sure will be SLOOOOWWWWNo, textures currently don't support alpha channel or masks. They're always opaque. If you want alpha channel, you have to write the texturing code for yourself but it's not that hard
Fabio
----------------------------
[Allanon] Fabio Falcucci | GitHub for recent works | Support me on Patreon for Hollywood libraries | ☆★ All my links ★☆
[Allanon] Fabio Falcucci | GitHub for recent works | Support me on Patreon for Hollywood libraries | ☆★ All my links ★☆
- airsoftsoftwair
- Posts: 5443
- Joined: Fri Feb 12, 2010 2:33 pm
- Location: Germany
- Contact:
[23 Oct 2009] Re: Re: My personal fight against alpha-channel ^_^
Note: This is an archived post that was originally sent to the Hollywood mailing list on Fri, 23 Oct 2009 13:15:34 +0200
True, but what do you want to do? I don't see much sense in extending #FILLTEXTURE to support alpha channel or monochrome masks. It's meant to do wallpaper effects like a pattern as a page background etc. These things usually don't use transparency or if they do, then on top of a background color...Maybe it's not hard but for sure will be SLOOOOWWWW