Page 1 of 2

Replacing Brushes

Posted: Mon Apr 18, 2011 10:40 pm
by djrikki
Hi,

If I want to load a brush and then change it how do I do? I noticed also if I flip, rotate or similar - it leaves remnants underneath. :S

Same goes for TextObjects, how do I update/replace a textobject?

Finally how do I check a brush/text object exists and if so clear it from the screen.

Code: Select all

LoadBrush(#IMAGEREVERT, #AISSFOLDER .. "restore", {Transparency = #FUCHSIA}) ; Restore
DisplayBrush(#IMAGEREVERT,0,0)

debugprint("here")

wait(50)

freebrush(#IMAGEREVERT)

debugprint("now here")

LoadBrush(#IMAGEREVERT, #AISSFOLDER .. "pdf", {Transparency = #FUCHSIA}) ; Restore
DisplayBrush(#IMAGEREVERT,0,0)

Re: Replacing Brushes

Posted: Tue Apr 19, 2011 11:15 am
by airsoftsoftwair
I guess the easiest way would be to use the powerful layers system of Hollywood. Then you can do all that with ease :)

Re: Replacing Brushes

Posted: Tue Apr 19, 2011 6:03 pm
by djrikki
Hi Andreas,

Having trouble getting using Layers with displays that require buttons, I keep getting this error:
A BGPic needs to be active while calling button functions!

File: imageprocessing.hws (current line: 70 - in function MakeButton)
Here is a portion of the code in question:

Code: Select all

			windowtitle = filepart(filename) .. " (" .. imageproperties.width .. "x" .. imageproperties.height .. ")"
	
			createdisplay(#IMAGEWINDOW, {active=true, width=640, height=480, title = windowtitle, layers=true, nomodeswitch=true, nohide=true})
			selectdisplay(#IMAGEWINDOW)
			movedisplay(640,515)
				
			;setfillstyle(#FILLCOLOR)
			;box(0,0,640,40, #AMIGALIGHTERGREY)
			
			createlayer(0,0,640,480, {color= #AMIGALIGHTERGREY})
			selectlayer(1)

			loadbrush(#IMAGEPREVIEW,filename)
			copybrush(#IMAGEPREVIEW,99)
			scalebrush(99,640,440)
			displaybrush(99,0,41)
			
			opendisplay(#IMAGEWINDOW)
			
			evtfunc = {OnMouseUp = p_actionToolbar, OnMouseOver = p_actionToolbar}
			
			/**********  Create toolbar *********/
			displaybrush(#IMAGEROTLEFT,400,8)
			makebutton(#IMAGEROTLEFT, #SIMPLEBUTTON,400,8,24,24, evtfunc)
Error occurs as the bottom line is called. I don't understand the error message at all. :S

Re: Replacing Brushes

Posted: Tue Apr 19, 2011 11:42 pm
by Tuxedo
Hi!

Plz explain better your layer/button problem...

For the replacing brush problem with activated layers you can easly:

Code: Select all

LoadBrush(1, ...)
DisplayBrush(1, 34, 47, {Name = "foo"})

...

RemoveLayer("foo")

FreeBrush(1)
LoadBrush(1, ...
Hope to dont have forgot nothing... :P

Re: Replacing Brushes

Posted: Wed Apr 20, 2011 11:47 am
by djrikki
Imagine a window, it has buttons across the top to rotate an image etc... below the buttons is an image. When I press the button it should rotate the image. Atm the image isn't on a layer so its leaves a graphic remnant underneath when rotated. So I want to move everything to layers, including the buttons as well so they depress correctly.

Re: Replacing Brushes

Posted: Wed Apr 20, 2011 7:42 pm
by Tuxedo
mmm...
I think that wasnt needed.
On my app LoView I discovered that using layers slowdown the gfx update a lot...
For what you are trying to do, imho, was really better to update the whole "blitting area" whit a buffered display or and "handmade" buffered display...
So you dont have the "old" picture remnants...
For the buttons update there an example of my code on LoView:

Code: Select all

		IF	msg.id = 9
			Box(LoadPicPOS, 1, 24, 24, $DDDDDD)
			DisplayBrush(LoadPic_s, LoadPicPOS, 1)
On the above code when button "9" was pressed I blit also an "empty box" of the toolbar background color to delete the old button state so the blited button was nice and clear.
Another way to solve gfx remnants for buttons was to use non trasparent buttons...

I dunno if that was usefull to you...
Plz let me know!

Good Work!

Re: Replacing Brushes

Posted: Wed Apr 20, 2011 8:33 pm
by djrikki
I tried playing around with DoubleBuffering as you suggested, no luck. Are you able to upload the LoView sourcecode on to os4depot or send me it? Would be much appreciaterd.

Re: Replacing Brushes

Posted: Wed Apr 20, 2011 10:47 pm
by djrikki
Hmm, made some progress, using RotateLayer() instead.

Re: Replacing Brushes

Posted: Thu Apr 21, 2011 11:52 pm
by Tuxedo
Sorry but in that days I'm reall tyired from my "real" work...
About LoView source sorry but I want spread all the source code over the world...
Plz make some targeted questions and I will reply asap I can...

Happy coding!

Re: Replacing Brushes

Posted: Sun Apr 24, 2011 1:42 pm
by jalih
djrikki wrote:Imagine a window, it has buttons across the top to rotate an image etc... below the buttons is an image. When I press the button it should rotate the image. Atm the image isn't on a layer so its leaves a graphic remnant underneath when rotated. So I want to move everything to layers, including the buttons as well so they depress correctly.
You can use my Sokoban game as an example how to work with double-buffer and buttons.

Have fun!

Available here: http://www.mediafire.com/?zdhp9d691a0k7cp