Page 2 of 2

Re: 2 Questions about BGPic-Function

Posted: Thu Dec 01, 2011 8:29 pm
by fingus
Andreas wrote:
fingus wrote:How to create an offscreen BGPic?
Is the meaning of offscreen here, drawing to a non-visible-area (left, top, down, right of the actual screen) or is this something like a double-buffered area?
The Manual didn't describe this and even the Example of BGPic there doesn't work and ends up with a "Didn't find Background-Picture 2".
Normally you can create off-screen BGPics with CreateBGPic() but as you need a BGPic with an alpha channel, you have to create a brush first and then convert it to a BGPic. The code goes something like this:

Code: Select all

tmp = CreateBrush(Nil, 640, 480, 0, {AlphaChannel = True, Clear = True})
tmp2 = BrushToBGPic(tmp, Nil)
FreeBrush(tmp)
SelectBGPic(tmp2, #SELMODE_COMBO)
....draw to it...
EndSelect
DisplayBGPic(tmp2)
Thanks for the example, it works so far! 8-)

But this happen when try to put some Alpha-Channel images above another:
Image
the smaller applebrush don't use the first mentioned brush as background!??

Code: Select all

...
SelectBGPic(tmp2, #SELMODE_COMBO)
DisplayBrush(0,#CENTER,#CENTER)
DisplayBrush(1,400,400)    ;add smaller apple above background
TextOut(200,200,"hello world!!!!!!!!!!!!!!!!!!")
Box(50,50,100,100, #BLUE)
EndSelect
DisplayBGPic(tmp2) 
...

Re: 2 Questions about BGPic-Function

Posted: Fri Dec 02, 2011 6:02 pm
by airsoftsoftwair
That's normal behaviour. In the future there will be a special copy mode that will allow you to choose which pixels should be copied when drawing to offscreen destinations. If you do not want transparent pixels to be copied, you need to copy the image manually and use ReadPixel() on the alpha channel of the source image to find out if the pixel is visible. If it is, then you can copy it to the destination image using Plot(). If it is not visible, then just skip it. This is a little complicated at the moment, but it is possible :) In the next version of Hollywood it will be much easier though.

Re: 2 Questions about BGPic-Function

Posted: Sat Dec 03, 2011 9:38 am
by fingus
Andreas wrote:...you need to copy the image manually and use ReadPixel() on the alpha channel of the source image to find out if the pixel is visible. If it is, then you can copy it to the destination image using Plot(). ...
Sorry, but this solution isn´t really a good way to solve it and it will be consuming too much resources for my taste. So, i decided to rework my flipclock completely (optimizing resource-graphics and merging Layers together) and maybe build a Mask to show some areas of the weather-icons if this works with Hollywood. When this isn´t working, i must change the design to keep things working like i wish.

I thank you for your help, i learned some new ways to solve problems with Hollywood and i had bring you at least two new customers and promoting Hollywood where i can. This Forum is commendable :-)

Re: 2 Questions about BGPic-Function

Posted: Mon Jan 16, 2012 7:36 pm
by djrikki
Fingus,

Did you have any luck making a transparent window? If you look at the DisplayStyle example included Andreas has working in it. I am trying to pick it apart, I have it working, but its not great check out the duplication in the SelectBGPic() line toward the bottom of the code, if I comment it out you will see that everything turns Black. :S

Andreas, can you please look at this code and compile it - and perhaps provide us with the solution!

Code: Select all

@DISPLAY {borderless = True}
    
LoadBrush(2,"tbimages:help", {LoadAlpha = True})
ScaleBrush(2,96,96,True)

Function p_MakeBGPic()
	SetFillStyle(#FILLCOLOR)
	SetFontColor(#RED)
	SetFont("dejavu sans oblique", 40)

	CreateBrush(1, 1024, 768, #BLACK)
	SetBrushTransparency(1, #BLACK)
	SelectBrush(1)
	SelectAlphaChannel(1)
	SetAlphaIntensity(0)
	Box(0, 0, 1024, 768)
	SetAlphaIntensity(255)
	TextOut(#CENTER,#CENTER,"THIS IS A TRANSPARENCY WINDOW WITH\nSOME TEXT AND IMAGE IN IT")
	DisplayBrush(2,#CENTER,#TOP)
	EndSelect

	BrushToBGPic(1, 1)
	FreeBrush(1)
EndFunction

EnableLayers

p_MakeBGPic()

SelectBGPic(1)
	TextOut(#CENTER,#CENTER,"THIS IS A TRANSPARENCY WINDOW WITH\nSOME TEXT AND IMAGE IN IT")
	SetBrushTransparency(2, #BLACK)
	DisplayBrush(2,#CENTER,#TOP)
EndSelect

DisplayBGPic(1)

Wait(150)

Re: 2 Questions about BGPic-Function

Posted: Mon Aug 20, 2012 10:00 am
by fingus
Andreas wrote:That's normal behaviour. In the future there will be a special copy mode that will allow you to choose which pixels should be copied when drawing to offscreen destinations
As we know "SELMODE_COMBO, 1" of Hollywood 5.0 have serious problems with low alpha-values. Another Problem is that the BGPic set the global alpha-transparency for all layers/brushes above this. That leads for example to a transparent brush when it´s displayed over an 50% transparent bgpic area. So the conclusion is that we have to find a workaround for this situation.
If you do not want transparent pixels to be copied, you need to copy the image manually and use ReadPixel() on the alpha channel of the source image to find out if the pixel is visible. If it is, then you can copy it to the destination image using Plot(). If it is not visible, then just skip it. This is a little complicated at the moment, but it is possible :) In the next version of Hollywood it will be much easier though.
Plot() isn´t working with enabled layers.

Re: 2 Questions about BGPic-Function

Posted: Mon Aug 20, 2012 10:38 am
by fingus
Andreas wrote:That's normal behaviour. In the future there will be a special copy mode that will allow you to choose which pixels should be copied when drawing to offscreen destinations
As we know "SELMODE_COMBO, 1" of Hollywood 5.0 have serious problems with low alpha-values on 16bit-screen, 32bit isn´t tested, will follow. Another Problem is that the BGPic set the global alpha-transparency for all layers/brushes above this. That leads for example to a transparent brush when it´s displayed over an 50% transparent bgpic area. So the conclusion is that we have to find a workaround for this situation.
If you do not want transparent pixels to be copied, you need to copy the image manually and use ReadPixel() on the alpha channel of the source image to find out if the pixel is visible. If it is, then you can copy it to the destination image using Plot(). If it is not visible, then just skip it. This is a little complicated at the moment, but it is possible :) In the next version of Hollywood it will be much easier though.
Plot() isn´t working with enabled layers.[/quote]