Notifications
Clear all

[Closed] Setting a Bitmap in a Diloag background

Hey everybody, I have a problem setting a bitmap in dialog background … in fact the script runs, but the problem is that i just see a Dark Background which is not the background I have spicifed… here is the Code :


macroScript UITest category:"Test"
(
    dir = (getDir #preview + "/22.bmp")
    anim_bmp = bitmap 160 400 filename:dir

        
    rollout resRollout "Resoulation Control" width:160 height:400
    (
        groupBox grp1 "Resoulation : " pos:[8,8] width:144 height:152
        button R_to_anim "Ready to Animation" pos:[24,32] width:112 height:16
        button R_to_render "Ready to Rendering" pos:[24,56] width:112 height:16
        groupBox smoothGrp2 "Smooth" pos:[16,80] width:128 height:72
        radioButtons smoothRB "Turn ON/OFF : " pos:[32,96] width:92 height:30 labels:#("ON", "OFF") default:2 columns:2
        spinner smoothLevel "Level : " pos:[40,128] width:72 height:16
        
        -----------------------------------
        on R_to_anim pressed do 
            (
                undo "Ready to Animation" on
                    (
                        highLow_Mesh[1].node.ishidden = true
                        highLow_Mesh[2].node.ishidden = false
                    )
            )
        on R_to_render pressed do
            (
                undo "Ready to Animation" on
                    (
                        highLow_Mesh[1].node.ishidden = false
                        highLow_Mesh[2].node.ishidden = true
                    )
            )
        on smoothRB changed state do 
            (
                undo "Smooth ON/OFF" on
                    (
                        if smoothRB.state == 1 do
                            (
                                highLow_Mesh[1].node.modifiers[1].Enabled = true
                            )
                        if smoothRB.state == 2 do
                            (
                                highLow_Mesh[1].node.modifiers[1].Enabled = false
                            )
                    )
            )
    )

    CreateDialog resRollout bitmap:anim_bmp
)

I was wondering if you could help me on this.
Thanks.

10 Replies

you are using wrong constructor for bitmap…
it has to be


dir = (getDir #preview + "/22.bmp")
anim_bmp = openbitmap dir

[left][color=yellow]bitmap <width <height> [ filename:<filename_string> ][/left]
[left] [/left]
[left]Creates an empty bitmap. The bitmap value returned is a savable bitmap.[/left]

[left]The filename: parameter allows you to set the name of the file the bitmap will be saved to using the save method. Specifying an existing bitmap file name does not load the contents of the bitmap file into the bitmap value.[/left]

[/color]

1 Reply
(@wamo)
Joined: 11 months ago

Posts: 0

I aprociate it Denis, I could get it work now … ,

but I have another question which is about having bitmap on rollouts background in a Custom Attribiute, becuase it may be better to setup everything there, but i couldn’tfind any syantax for it when adding Custom Attributes … what do i need to do ?!

Thanks,

I have faced another problem here :

I have Created a Diloag using CreateDialog() , and have loaded a Bitmap in the Dialog option
It works cool … now i want to add maxscript control into the Dialog form … a Slider in this case, seems to work, but the problem is : When i Scurb time slider backward/forward the Slider have some ghoast there, it means it’s kindda mixing itself with bitmap background and screw up the background … I have atached the images before scurb and after …

hey Ehsan,
why you don´t use a imageButton inside a group, and controls (spinner/slider) inside another one ?

e.g (from help)


 rollout test "test"
 
 (
 	local W = 200, H = 200
 	group " "
 	(
 		button btn "Press To Render" width:W height:H
 	)
 	
 	group " "
 	(
 		spinner sp range:[0,100,0] offset:[0,0]
 	)
 
 
 	on btn pressed do 
 	(
 		IMG = render outputsize:[W,H] vfb:off
 		btn.images = #(IMG, undefined, 1,1,1,1,1 )
 	)
 
 )
 
 createDialog test 220 280
 
 

hope it helps

1 Reply
(@wamo)
Joined: 11 months ago

Posts: 0

Hi Reneto, becoz i Don’t need an ImageButton …

I used a Bitmap as backgorund for the Dialog for a GUI test … I can put my buttons and whatever there, but sliders seems to have problem… kindda i gusse Dynamic UI controls on a loaded bitmap will mix up and screw…

You could try using an imgTag control. Something like:


rollout testRoll "test"
(
	imgTag theImage height:140 width:140 bitmap:(bitmap 50 50 color:red)
	slider theSlider width:140
)
createDialog testRoll

It’s essentially like a bitmap control, but with no border, so if you use a bitmap file it will look very similar to using a background image, and since you can control the size and location there will probably be no drawing errors.

Macro is absolutely right. Definitely imgTag is the solution for you:


try(destroydialog testRol) catch()
rollout testRol "test"
(
 imgTag theImage width:200 height:60 bitmap:(bitmap 2 2 color:red) enabled:off pos:[0,0]
 slider theSlider width:180 pos:[15,12]
)
createDialog testRol width:200 height:60

1 Reply
(@marcobrunetta)
Joined: 11 months ago

Posts: 0

Macro?? I think you’ve been coding for way to long Denis. =P

 PEN

Early test of an image tag based joy stick control.


try(destroyDialog testImgTag)catch()
rollout testImgTag "Test Img Tag" width:220
(
	local curBoxControl=undefined
	local curSliderControlX=undefined
	local curSliderControlY=undefined
	local boxControlItVal=[0,0]
	
	local crossCol=(color 255 0 0)
	local circleCol=(color 0 0 100)
	local bgCol=(color 100 100 100) 
	local gridCol=(color 120 120 120) 
	local gridSpace=25
	local dPos=[-1,-1,-1]
	
	imgTag boxControlIt "MouseTracker" \
		height:100 width:100 bitMap:undefined
	
	imgTag boxControlIt2 "MouseTracker2" \
		height:100 width:100 bitMap:undefined
	
	timer mouseTime interval:10
	
	
	fn boxControl control:undefined width:0 height:0 pos:[0,0]=
	(
		if control!=undefined then
		(
			local bm=bitmap width height color:bgCol
			for h = 0 to height by gridSpace do
			(
				for i = 0 to width do (setPixels bm [i,h] #(gridCol))
			)
			for w = 0 to width by gridSpace do
			(
				for i = 0 to height do (setPixels bm [w,i] #(gridCol))
			)
			for i = 0 to width do (setPixels bm [i,pos.y] #(crossCol))
			for i = 0 to height do (setPixels bm [pos.x,i] #(crossCol))
			
			r=10
			j=pos.x
			k=pos.y
			for i = 1 to 360 by 5 do
			(
				x=r*cos i + j
				y=r*sin i + k
				setPixels bm [x,y] #(circleCol)
			)
			
			control.bitmap=bm
			boxControlItVal=pos
		)
	)
	
	local rcMenuCon=undefined
	fn conMenus con:undefined=
	(
		rcMenu menu
		(
			menuItem reset "Reset"
			menuItem resetX "Reset X"
			menuItem resetY "Reset Y"
			
			on reset picked do
			(
				boxControlItVal=[rcMenuCon.width/2,rcMenuCon.height/2]
				boxControl control:rcMenuCon width:rcMenuCon.width height:rcMenuCon.height pos:boxControlItVal
			)
			on resetX picked do
			(
				boxControlItVal=[boxControlIt.width/2,boxControlItVal.y]
				boxControl control:rcMenuCon width:rcMenuCon.width height:rcMenuCon.height pos:boxControlItVal
			)
			on resetY picked do
			(
				boxControlItVal=[boxControlItVal.x,rcMenuCon.height/2]
				boxControl control:rcMenuCon width:rcMenuCon.width height:rcMenuCon.height pos:boxControlItVal
			)
		)
		rcMenuCon=con
		menu
	)
	
	fn events control:undefined mouseEvent:undefined rolloutDef:undefined=
	(
		case mouseEvent of
		(
			#buttonDown:
			(
				dPos=[-1,-1,-1]
				curBoxControl=control
				circleCol=(color 200 0 0)
			)
			#buttonUp:
			(
				if curBoxControl!=undefined then
				(
					circleCol=(color 0 0 100)
					dPos=mouse.screenPos-(GetDialogPos rolloutDef)-[3,22]
					newPos=dPos-control.pos
					boxControl control:control width:control.width height:control.height pos:newPos
					dPos=[-1,-1,-1]
					curBoxControl=undefined
					gc light:true
				)
			)
			#mouseOut:
			(
				if curBoxControl!=undefined then
				(
					circleCol=(color 0 0 100)
					dPos=mouse.screenPos-(GetDialogPos rolloutDef)-[3,22]
					newPos=dPos-control.pos
					boxControl control:control width:control.width height:control.height pos:newPos
				)
				curBoxControl=undefined
				dPos=[-1,-1,-1]
				gc light:true
			)
			#RbuttonDown:
			(
				PopupMenu (conMenus con:control)
			)
		)
	
	)
	on boxControlIt lbuttondown pos flag do 
	(
		events control:boxControlIt mouseEvent:#buttonDown rolloutDef:testImgTag
	)
	on boxControlIt lbuttonup pos flag do 
	(
		events control:boxControlIt mouseEvent:#buttonUp rolloutDef:testImgTag
	)
	on boxControlIt mouseout do 
	(
		events control:boxControlIt mouseEvent:#mouseOut rolloutDef:testImgTag
	)
	on boxControlIt rbuttonDown do
	(
		events control:boxControlIt mouseEvent:#RbuttonDown rolloutDef:testImgTag
	)
	 
	on boxControlIt2 lbuttondown pos flag do 
	(
		events control:boxControlIt2 mouseEvent:#buttonDown rolloutDef:testImgTag
	)
	on boxControlIt2 lbuttonup pos flag do 
	(
		events control:boxControlIt2 mouseEvent:#buttonUp rolloutDef:testImgTag
	)
	on boxControlIt2 mouseout do 
	(
		events control:boxControlIt2 mouseEvent:#mouseOut rolloutDef:testImgTag
	)
	on boxControlIt2 rbuttonDown do
	(
		events control:boxControlIt2 mouseEvent:#RbuttonDown rolloutDef:testImgTag
	)
	
	on mouseTime tick do
	(
		p=mouse.screenPos-(GetDialogPos testImgTag)-[3,22]
		if dPos!=p then
		(
			dPos=p
			if curBoxControl!=undefined then
			(
				newPos=dPos-curBoxControl.pos
				boxControl control:curBoxControl width:curBoxControl.width height:curBoxControl.height pos:newPos
			)
		)
	)	
	 
	on testImgTag open do
	(
		boxControl control:boxControlIt width:boxControlIt.width height:boxControlIt.height pos:[boxControlIt.width/2,boxControlIt.height/2]
		boxControl control:boxControlIt2 width:boxControlIt2.width height:boxControlIt2.height pos:[boxControlIt2.width/2,boxControlIt2.height/2]
	)
)
createDialog testImgTag


could anyone please show some test code about the same thing using dotNET ??
i´m curious.