Combining or overlaying images through script?

Does Maxscript have the ability to overlay a transparent PNG on top of another image, like a stamp or such?

Comments

Comment viewing options

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

With .NET...

I am sure you can do this task with the native Maxscript functions, but at the moment I can give you a hint with .NET. I hope can recall correct...
At first create graphics class:
g = dotnetclass "system.drawing.graphics"
Then create a new bitmap or from file such as:
b = dotnetobject "system.drawing.bitmap" 256 256
Or... b = (dotnetclass "system.drawing.image").fromfile "c:\\myImage.bmp"
Next create the graphics inherited object:
gfi = g.fromimage b
Now you can paint over this image using the graphics object gfi.
gfi.drawimage "c:\\myStamp.png"
....
Just examine the graphics drawing methods in the Listener: showmethods gfi.
There are many drawing methods. You should be able to specify the x, y coordinates, maybe with this method, just take a look.

Haider of Sweden's picture

.

I got the help I needed on CGTalk (credits goes to Jorge Rodríguez, PolyTools3D), and the solution looks like this:

(
fn BlendImages mBackImg mFrontImg =
(
result = copy mBackImg
pasteBitmap mFrontImg result [0,0] [0,0] type:#blend
 
close mBackImg
close mFrontImg
 
return result
)
 
fn SaveImage mImg mFileName =
(
mImg.filename = mFileName
save mImg
close mImg
)
back = openBitMap "$userscripts//splashes//_splash.png"	-- background image
front = openBitMap "$userscripts//splashes//_header.png"	-- alpha image
 
img = BlendImages back front
SaveImage img "$userscripts//splashes//splash.bmp"
)

Kind regards
Haider
www.haider.se

TsveTan's picture

To be clear

use b.save "c:\\myImage.bmp" to save the file.

Comment viewing options

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