Notifications
Clear all

[Closed] Resizing an Image

If I have a 500x500px png image saved somewhere on my drive and I want to use it as a image for a button in a rollout, but the button is 200x200px wide and I assign the image to it, there are parts of the original image cut off because the image is larger than the button. Is it possible from withing maxscript to resize the file temporarily and assign it as the button’s image, while still keeping the original intact?

6 Replies

open source bitmap

copy it to bitmap with a different size

copy <source_bitmap> <dest_bitmap>

Copies the source bitmap to the destination bitmap. If the size of the two bitmaps is different, the image will be scaled to fit the destination bitmap.

use resized bitmap with a button instead of filename

if you don’t need a button exact functionality you can use imgTag instead. it has #stretch option

Could you write a small example of the script in action? I’d really appreciate it since I’ve pretty much guessed that’s what you had to do, but I didn’t have the necessary programming skills to actually apply it. All I was getting were error after error. I’m just not used with working with bitmaps through maxscript.

rollout dialog ""
(
    local source = openbitmap @"file500x500"
    local target

    button bt width:310 height:310 
    on dialog open do
    (
        target = bitmap 300 300
        copy source target
        bt.images = #(target,undefined,1,1,1,1,1)
    )
)
createdialog dialog

(i don’t have max right now to test it)

1 Reply
(@linkbird)
Joined: 11 months ago

Posts: 0

Tested it out and it works just like I wanted it to! Thank you very much You were very helpful

Happy 8000 posts Denis! Can’t be many people on this forum with that kind of contribution!