Notifications
Clear all

[Closed] Bitmap Icon NO.# to imageTag ?

I can’t find a way to assign one of the icons in max BitmapFiles to imageTag control .
what i mean here is like the image buttons where you define the image as
images:#(theBitmap, theBitmapMask , etc)
is there any way or workaround to do that without explicit Read\Write pixels from max Bitmap Files ?

9 Replies
1 Reply
(@denist)
Joined: 11 months ago

Posts: 0

Sorry, but I don’t understand the problem. What control do you want to assign the icon to? Is it max ImgTag control or anything else? What the icon file is? Is it standard .ICO format file?

 JHN

I don’t think there’s anyway around it, you need get/setpixels to a temporary file an use that in the imagelist. If someone knows how to stream a maxscript bitmap value into a dotnet value, I’d like to hear!

-Johan

JHN

I wish there is someway , the imgtag control eventHandlers are great
i’m that close to make a flyout “like those in Align\pivot controls in the main menu”
now making separate imagefile for each Control while those images do exist in max icons directory is a shame .

denisT

hello denis , please excuse my poor description … i tend to use image/icon/bitmap interchangeably

the problem goes like this

1-in max\icons folder you have Bitmap files (.BMP) and each one contains separate imageFiles
2-you can use these files and assign any (icon\image) they contain to an imageButton for example
3-I can’t find a way to do that for imgTag control

the only option i can find is to open the file … copy the desired pixels and then assign them to the Bitmap parameter of the imgTag control .

i’m looking for a way to avoid that and assign them on the fly … just like you do with the imageButton control

2 Replies
(@denist)
Joined: 11 months ago

Posts: 0

That’s clear now but I have to disappoint you. There is no way to read bitmap file and directly assign bitmap value to imgTag control by index. So you have to copy pixels to an opened bitmap. But imgTag doesn’t need a file, it needs bitmap value. So you can read the bitmap file and make all necessary bitmaps at ones. I do it this way for standard max and my own bmp collections. Don’t worry. It’s fast enough.

 JHN
(@jhn)
Joined: 11 months ago

Posts: 0

Denis, can you directly assign a bitmap value to a dotnet img? I’m using .loadFromBitmap(filename) (don’t know the exact syntax right now) and am temporary saving the maxscript bitmap to disk. If I can directly pass on the mxs bitmap value that would be great!

Thanks,
-Johan

 use Clipboard. You can put max bitmap in Window's Clipboard ([b]setclipboardBitmap[/b]) and assign .net clipboard as .net image.
c#
[b]
    [/b]IDataObject data = Clipboard.GetDataObject();
  Image image = (Image)data.GetData(DataFormats.Bitmap,true);
    
that's easy to write it in MXS

added:


 fn bitmapToDotnet bmp = if iskindof bmp Bitmap do 
 (
 	setclipboardBitmap bmp
 	format = dotnetclass "DataFormats"
 	data = (dotnetclass "Clipboard").GetDataObject()
 	if (data.GetDataPresent format.Bitmap) do data.GetData format.Bitmap on
 )
 
 JHN

It is, and that’s just a great idea! Been wrecking my brain over that one!

Thanks!
-Johan

i added mxs function. see above.

 JHN

Thanks!

-Johan