I have a problem in which im not sure what i am doing wrong.
What i am trying to do is load brushes, make them into animation, and then display that animation so that there is transparent color. For i dont want boxes to display in my game.
Im not really sure where the problem lies. According to hollywood guide, I am doing right. But it still doesnt work. My best guess is that the problem resides in different displays giving different colors, but one of my solutions should fix even that one.
Heres the code with pictures so you can see the problem for yourself: (I will take this off after problem is solved)
http://dl.dropbox.com/u/3375468/GrabAnim.zip
What i have tried so far:
1. Loadbrush/LaodAnim Transparency = #GREEN /$00FF00 (full green)
2. I also tried changing one of the pictures green into $000100 (smallest possible amount of green) in hopes it would work on every screen, no help.
3. I loaded first brush, selected it as output device, then color=readpixel(1,1) *which should be that green i am wanting to be transparent.
Then after that i loaded the rest of brushes, made them into animation, and used LoadBrush( 1, filename, {Transparency=color}) as well as LoadAnim with same Transparency=color.
But even that didnt help.
4. I have also used in all these previous examples the RealColor() Function, but even that havent helped.
What am i doing wrong in here? Why cant i get that Green become transparent?
How to get the Transparency to actually work?
Re: How to get the Transparency to actually work?
Couple of things just in case:
Pictures are in png format.
I have modified them in GIMP.
Some of the pictures might have been modified with option to use indexed colors (I dont think i did to these, but to some otheers i think i indexed them down to 3 colors).
That green was chosen in Gimp as Background color, and i saved them as "Dont save the background color" or "Save background color as trasnparent" or something else like that in hopes i wouldnt have needed to use hollywoods transparency options at all, but that didnt work.
Pictures are in png format.
I have modified them in GIMP.
Some of the pictures might have been modified with option to use indexed colors (I dont think i did to these, but to some otheers i think i indexed them down to 3 colors).
That green was chosen in Gimp as Background color, and i saved them as "Dont save the background color" or "Save background color as trasnparent" or something else like that in hopes i wouldnt have needed to use hollywoods transparency options at all, but that didnt work.
Re: How to get the Transparency to actually work?
I still havent got transparency to work, anyone?
Re: How to get the Transparency to actually work?
This works for me:
I think you need to obtain the transparency color for each brush individually. A bit of typing work and not very elegant that you need to load each brush twice though.
Code: Select all
@DISPLAY { Title = "bla",width=1024, height=768 }
CreateGradientBGPic (1, #LINEAR, #BLUE, #RED)
DisplayBGPic(1)
SetFont("times", 24)
SetFontColor (#GREEN)
LoadBrush(1, "graphics/santaground1.png")
SelectBrush(1)
mycolor=ReadPixel(1,1)
EndSelect()
Print("mycolor=",mycolor)
SetFillStyle (#FILLCOLOR)
LoadBrush(1, "graphics/santaground1.png", { Transparency = mycolor} )
LoadBrush(2, "graphics/santaground2.png" )
SelectBrush(2)
mycolor=ReadPixel(1,1)
EndSelect()
Print("mycolor=",mycolor)
LoadBrush(2, "graphics/santaground2.png", { Transparency = mycolor} )
DisplayBrush (1, 1,1)
DisplayBrush (2, 200,1)
WaitLeftMouse()
Re: How to get the Transparency to actually work?
Thanks a lot Zylesea. I was trying to do the same as you, but for some reason i didint get even that to work. But i tried only once, so maybe i had some thought error there on that try.
I will tyr your piece code.
This really helps me. I usually get so irritatetd by some problem when i enoucnter it, that i cant get forward at anything else until that problem is fixed.
Like this time. Not a single line of code done on anything else, only trying to figure this problem out.
I will tyr your piece code.
This really helps me. I usually get so irritatetd by some problem when i enoucnter it, that i cant get forward at anything else until that problem is fixed.
Like this time. Not a single line of code done on anything else, only trying to figure this problem out.
- airsoftsoftwair
- Posts: 5446
- Joined: Fri Feb 12, 2010 2:33 pm
- Location: Germany
- Contact:
Re: How to get the Transparency to actually work?
Actually, I don't understand where the problem is. You can simply change the transparency color in a brush using SetBrushTransparency(). You normally don't have to mess around with GetRealColor() and ReadPixel() stuff at all....
Re: How to get the Transparency to actually work?
Reason for readpixel is that if i use #GREEN, #BLACK or something similar, it wont work. With readpixel i can find out the color which to use for transparency.
I have now partially got the problem solved thanks to you and Zylesea.
I can now get Brushes become Transparent, but i have ran in to another problem. I cant seem to get Transparency to work correctly in Animation.
What is happening in code.
New animation stream creation is began, and fololowing sequence happens:
1. Load Brush
2. Select Brush as output device (necessary for readpixel command)
3. Readpixel color
4. Endselect
5. Write new anim frame using this brush and set transparency as the readpixel color (to my understanding should work, but in reality doesnt)
(optional)6. SetBrushTransparency for readpixel color (This works as it should, if line is activated, then 4 brushes displayed at end of program show the transparency right)
Repeat the process until all 4 brushes are implied in Animstream
After that, Finish animstream (by otherwords, save it)
After that it basically just loads the just saved animation and displays it to screen scrolling through all the animframes, this however fails what comes to transparency.
After mouse click, it will display those 4 brushes to screen.
Can someone figure out what am i doing wrong here, or is it to do with the png format I am using that it fails to work, and what can i do to get it to work then?
I have now partially got the problem solved thanks to you and Zylesea.
I can now get Brushes become Transparent, but i have ran in to another problem. I cant seem to get Transparency to work correctly in Animation.
Code: Select all
@DISPLAY {Title = "Grab a picture and change it into Anim", Width = 800, Height=600, ScaleMode=#SCALEMODE_LAYER, FitScale=True, Borderless=True}
Function p_loadbrush(n, filename)
LoadBrush(n, "graphics/"..filename..".png")
SelectBrush(n)
color=ReadPixel(1,1)
DebugPrint(color)
EndSelect()
/*SetBrushTransparency(n, color) - If this line is in use, Brushes display with transparency the right way*/
WriteAnimFrame(1, n, {Transparency=color})
EndFunction
beginanimstream(1, "graphics/santaground.anim", 553, 450)
p_loadbrush(1, "santaground1")
p_loadbrush(2, "santaground2")
p_loadbrush(3, "santahit")
p_loadbrush(4, "santafall")
Finishanimstream(1)
/*From this on just testing that things work as they should (which they dont) */
LoadBGPic(1, "graphics/bg1.png")
DisplayBGPic(1)
LoadAnim(1, "graphics/santaground.anim")
DisplayAnimFrame(1, 400, 100, 2 )
ReadPixel(401,101)
Repeat
StartTimer(1)
a=a+1
If a>7
n=n+1
If n>4 Then n=1
NextFrame(1, 200, 100, n)
a=1
EndIf
finishprogram=IsLeftMouse()
WaitTimer(1, 25)
Until finishprogram=1
/*Put SetBrushTransparency line in use, and these brushes wil show right*/
DisplayBrush (1, 1,1)
DisplayBrush (2, 200,1)
DisplayBrush (3, 1, 200)
DisplayBrush (4, 200, 200)
WaitLeftMouse()
What is happening in code.
New animation stream creation is began, and fololowing sequence happens:
1. Load Brush
2. Select Brush as output device (necessary for readpixel command)
3. Readpixel color
4. Endselect
5. Write new anim frame using this brush and set transparency as the readpixel color (to my understanding should work, but in reality doesnt)
(optional)6. SetBrushTransparency for readpixel color (This works as it should, if line is activated, then 4 brushes displayed at end of program show the transparency right)
Repeat the process until all 4 brushes are implied in Animstream
After that, Finish animstream (by otherwords, save it)
After that it basically just loads the just saved animation and displays it to screen scrolling through all the animframes, this however fails what comes to transparency.
After mouse click, it will display those 4 brushes to screen.
Can someone figure out what am i doing wrong here, or is it to do with the png format I am using that it fails to work, and what can i do to get it to work then?
Re: How to get the Transparency to actually work?
although i didint get this exact thing to work the way i meant, i found another way to achieve the same.
however, now i have another question.
Is there something similar to SetBrushTransparency command for Animations?
For it seems to me that only time to decide Animations transparency color is when you load it.
And that forces me to load it twice, first time to use readpixel, second time to actually put the transparency color.
however, now i have another question.
Is there something similar to SetBrushTransparency command for Animations?
For it seems to me that only time to decide Animations transparency color is when you load it.
And that forces me to load it twice, first time to use readpixel, second time to actually put the transparency color.
- airsoftsoftwair
- Posts: 5446
- Joined: Fri Feb 12, 2010 2:33 pm
- Location: Germany
- Contact:
Re: How to get the Transparency to actually work?
Currently not. But you could use CreateAnim() to make an animation from a brush. Then you could use the SetBrushTransparency() call on that source brush.Bugala wrote: Is there something similar to SetBrushTransparency command for Animations?