Resizing Bitmap


Hi guys,

I’m doing some tests on grabbing the viewport, but I can’t for the life of me figure out how to resize (scale) a grabbed bitmap.

If I set the height or width, it simply crops the image.

I get the feeling I’m either missing something obvious, or the function is simply not present in MS.

Ps. if tutorials describing this exist, I’ve been unable to find them, but feel free to point and laugh - as long as you also point at the tutorials :smiley:


grab viewport, make texturemap, and render it with renderMap ()…


If you can live with unfiltered resize, all you have to do is make a destination bitmap with the desired size and copy the original bitmap into the new bitmap.
The renderMap() method Denis mentioned will produce a filtered rescaled image which is much nicer, but it has to fire up the scanline renderer and that can be slower if you are processing thumbnails on the fly, for example…


Thank you both for your replies - that’ll accomplish what I’m after nicely!

I think I’ll use the quick method for now, and then probably make the “high quality” with the filtering later, but this will let me prototype it quickly to get a go-ahead to spend more time developing (yay).

Incidentally, I’m not entirely sure what you mean when you say “make texturemap” yet, but hopefully understanding will come with some more tinkering (this is my first foray into bitmaps in Maxscript).


Did I say that?

I said:

–Make a destination bitmap:
theNewMap = bitmap 128 128
–Copy original map into it:
copy theOldMap theNewMap
–If you display it, it will be a resized version:
display theNewMap


Nope, you didn’t, denisT did :slight_smile: The copy bitmap works perfectly (even if it’s unfiltered, as you pointed out).


rendermap function renders texturemap. So you have to create Bitmaptexture (which is sub class of texturemap) and render it:

	db = viewport.getViewportDib()
	db.filename = (getdir #temp) + "\	emp_dib.bmp"
	save db
	tx = bitmaptexture bitmap:db
	rendermap tx into:bb size:([db.width,db.height]/4) filter:on display:on
	format "original size: % %
" db.width db.height
	format "rendered size: % %
" bb.width bb.height

this sample renders grabbed viewport 4 time smaller then original size.


Thanks a million denisT and Bobo, this is now about as perfect as it’ll get - I now have buttons to grab the viewport to the “scene status” folder, grab the viewport to the project management system, or do a render to the management system. All in one click of a button, brilliant.


I was trying this myself, had trouble with the alpha, but I figured it out

This helped me too… thanks guys


Maybe you can save the alpha into a different bitmap variable, and resize each, then combine back together?


hi, I posted a function on my blog a while back that i use to get a scaled viewport capture, you might find it useful. It’s a bit rough around the edges but it works for my purposes.


This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.