Another problem with Image Button ....

Hi all

Reading this question:
http://www.scriptspot.com/forums/3ds-max/general-scripting/script-to-fin...
I enjoyed exploring the script by creating an image reader with relevant information (to study a little MAXScript).

All right, so the script works ecc, BUT... Run this script:

try (destroydialog ::fmi) catch()
 
rollout fmi "Find Info Image"
(
	Global Sel_Bitmap, new_bitmap, Info
 
	group "Image..."
	(
	button bt1 "Select Image"
	)
	group "Measure Image..."
	(
	label lab1 "Width ="
	label lab2 "Height ="
	)
	group "Preview"
	(
		button bt4 "No preview" width:128 height:128 enabled:false
		label lab3 ""
	)
 
	group "More info..."
	(
		button bt2 "More Info..." enabled:false
	)
 
		button bt3 "Exit"
	---
	on bt1 pressed do
	(
    Sel_Bitmap = selectbitmap()
		if Sel_Bitmap != undefined then
		(
	Info = getBitmapInfo Sel_Bitmap
	ffp = filenameFromPath
    renderWidth = Info[3]
	renderHeight = Info[4] 
	lab1.text = ("Width = " + Info[3] as string)
	lab2.text = ("Height = " + Info[4] as string)
	lab3.text = ffp (Sel_Bitmap as string)
	new_bitmap = bitmap 128 128
	cnb = copy Sel_Bitmap new_bitmap
	bt4.images =  #(new_bitmap,undefined,1,1,1,1,1 )
       close cnb
		freescenebitmaps()
			bt2.enabled = true
			bt4.enabled = true
		)
		else messagebox "Please, select a Image file..." beep:false title:""
 	)
 
	on bt2 pressed do
	(
		try (destroydialog ::mi) catch()
		rollout mi "More Info image..."
		(
			group ""
			(
			label lab_07 "" 
			label lab_01 ""
			label lab_02 ""
			label lab_03 ""
			label lab_04 ""
			label lab_05 ""
			label lab_06 ""
			)
 
			button clo "Exit"
 
			on clo pressed do destroydialog mi
			on mi open do
			(
				lab_01.text = "Type File = " + (info[2] as string)
				lab_02.text = "Gamma = " + (Sel_Bitmap.gamma as string)
				lab_03.text = "Aspect Ratio = " + (Info[7] as string)
				lab_04.text = "Nh. Frame = " + (Sel_Bitmap.numframes as string)
				lab_05.text = (Info[5] as string) + "  Bits/Channel"
				lab_06.text = "Alpha channel = " + (Info[9] as string)
				lab_07.text = "Location = " + (Info[1] as string)
			)
 
		)
		createdialog mi 600 180 
	)
 
	on bt3 pressed do destroydialog fmi
 
	on bt4 pressed do
	(
       display Sel_Bitmap
	)
 
 
)
createdialog fmi style:#(#style_titlebar, #style_sysmenu, #style_toolwindow)

As you can see, the button image bt4 is not created. If I try with bitmap is all Ok, but with image button nothing.

The bt4.images have needs of a bitmap in the array, so I thought I'd create a new bitmap

new_bitmap = bitmap 128 128

and copy the original selected

Sel_Bitmap = selectbitmap()

image on it for fit the measure ("copy" in Bitmap maxscript).
Then with

cnb = copy Sel_Bitmap new_bitmap

I have create a new bitmap to use in array for image button.

bt4.images =  #(new_bitmap,undefined,1,1,1,1,1 )

This same procedure with a bitmap instead of a button, works well. Why I can not see the bitmap in the button?

Any idea?

Thanks for any help

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Michele71's picture

Ok, I have found this my

Ok, I have found this my solution:

local temp_new_bitmap_filename = (getDir #preview +"/Temp.bmp")
	local new_bitmap = bitmap 128 128 filename:temp_new_bitmap_filename gamma:0.2
	cnb = copy Sel_Bitmap new_bitmap
		save new_bitmap
	bt4.images =  #(new_bitmap.filename,undefined,1,1,1,1,1 )

I've create a temp. bitmap and copy it in image button

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.