2 Questions about BGPic-Function

Discuss any general programming issues here
User avatar
fingus
Posts: 152
Joined: Fri Sep 16, 2011 9:53 am

2 Questions about BGPic-Function

Post by fingus » Thu Nov 10, 2011 12:40 pm

I want to enable composing in my flipclock project.

To get realtime Background-Transparency i want do use the BGpic-Function for the bottom-layer.

Before i put some hours of work into it, i want to know if:

1. Is it possible with BGPic to display some Layers above Bpic-layer, does it work?

2. Will the Scaling-Engine (resizing image with free aspect-ratio) of Hollywood working with BGPic?

djrikki
Posts: 682
Joined: Wed Apr 06, 2011 12:26 am

Re: 2 Questions about BGPic-Function

Post by djrikki » Thu Nov 10, 2011 5:16 pm

I'll paste this from the other forum section in case Andreas hasn't read it.

Fingus is in essence asking for transparent windows - and I am too.

FAO Andreas,

Hey, is there any chance of adding support for creating transparent displays/windows? I tried to do the same thing as Fingus sometime ago, using the GrabDesktop() trick - doesn't really work very well - users did need to move windows right!

I bet I am not the only who would also like to create a Splash window - transparency is needed there too - *think Adobe irregular-shaped splash windows*
Evolve - Rapid GUI Development tool for MUI Royale and RapaGUI
http://myevolve.wordpress.com

User avatar
airsoftsoftwair
Posts: 3309
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: 2 Questions about BGPic-Function

Post by airsoftsoftwair » Sat Nov 12, 2011 10:07 pm

@fingus: Every Hollywood display has a BGPic attached to it. You can't work without them. So yes, everything that you listed is possible.

User avatar
fingus
Posts: 152
Joined: Fri Sep 16, 2011 9:53 am

Re: 2 Questions about BGPic-Function

Post by fingus » Mon Nov 21, 2011 9:50 am

I´m starting implementing compositing in my flipclock-project but i face one problem:

If in the area of the deepest layer (BGPic) are completely transparency areas, then the parts of the layers above are not shown there!

Image
(For better visibility i set the background to white)

You see it in the screenshot with the clipped area of the whie flipclock-sheets on top and between main and secondary bar.

It seems the BGPic sets a kind of "mask". I try to set transparency for above layers to 0, but that doesn´t seem to have any effect on it.

djrikki
Posts: 682
Joined: Wed Apr 06, 2011 12:26 am

Re: 2 Questions about BGPic-Function

Post by djrikki » Mon Nov 21, 2011 2:49 pm

Did you get my PM on Amigaworld fingus?
Evolve - Rapid GUI Development tool for MUI Royale and RapaGUI
http://myevolve.wordpress.com

User avatar
airsoftsoftwair
Posts: 3309
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: 2 Questions about BGPic-Function

Post by airsoftsoftwair » Mon Nov 21, 2011 10:41 pm

fingus wrote: It seems the BGPic sets a kind of "mask".
That's normal behaviour. The BGPic's shape will act as a mask for all drawing operations. If you do not want that, you have to draw to an offscreen BGPic and then switch to this BGPic to make the changes visible.

User avatar
fingus
Posts: 152
Joined: Fri Sep 16, 2011 9:53 am

Re: 2 Questions about BGPic-Function

Post by fingus » Fri Nov 25, 2011 10:47 pm

That's normal behaviour. The BGPic's shape will act as a mask for all drawing operations. If you do not want that, you have to draw to an offscreen BGPic and then switch to this BGPic to make the changes visible.
I read the guide but don't know how to realise to draw all layers to a non visible bgpic and then to switch (by copybgpic(offscreen,visible) )to visible bpic. It should then have a black background picture?!? can you provide a small example with 1-2 brushes attached to it?

This doesn't work:

Code: Select all

@BRUSH 1, "appleimg.png", {LoadAlpha = True}  
EnableLayers()
DisplayBGPic(1, { x=-600, y =-600 }) ; draw to offscreen
DisplayBrush(1,#CENTER,#CENTER)  ; attach a brush
Print("hello world!", #BLACK) ; attach a text
Box(50,50,100,100, #BLUE) ; attach a nox

CopyBGPic(1,2) ; copy to new bgpic2
DisplayBGPic(2)  ; display it on the visible screen

		@DISPLAY
        {
        Title = "test",
        Borderless = True,
        Layers = True,
        sizeable = True,
        scalemode=#SCALEMODE_LAYER,
        Smoothscale=True,
        KeepProportions=True,
        width = 528,
        height = 535,
        active = False,
        dragregion = {{type = #BOX, x = 0, y = 0, width = 528,height = 200}},
        sizeregion = {{ type = #BOX, x = 0, y = 201, width = 528, height = 200}}
        }


EscapeQuit(True)

; wait until something happens!
Repeat
	WaitEvent
Forever        


User avatar
airsoftsoftwair
Posts: 3309
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: 2 Questions about BGPic-Function

Post by airsoftsoftwair » Fri Nov 25, 2011 11:40 pm

Create an offscreen BGPic and then draw to it using SelectBGPic() together with #SELMODE_COMBO so that all drawing commands render to the color and alpha channel of the BGPic. When you're finished preparing your BGPic in this way, simply call EndSelect() and DisplayBGPic() to bring it to the front.

User avatar
fingus
Posts: 152
Joined: Fri Sep 16, 2011 9:53 am

Re: 2 Questions about BGPic-Function

Post by fingus » Mon Nov 28, 2011 11:00 pm

Andreas wrote:Create an offscreen BGPic and then draw to it using SelectBGPic() together with #SELMODE_COMBO so that all drawing commands render to the color and alpha channel of the BGPic. When you're finished preparing your BGPic in this way, simply call EndSelect() and DisplayBGPic() to bring it to the front.
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".

User avatar
airsoftsoftwair
Posts: 3309
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: 2 Questions about BGPic-Function

Post by airsoftsoftwair » Thu Dec 01, 2011 10:30 am

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)

Post Reply