bitmapmaxscriptzbuffer

How to save a bitmap as 16-bit in Maxscript?


I want to read out the z-buffer of camera, and render it as an image.

I could achieve it with the following code:

--Place the z camera
z_cam = freecamera name: "depth"  position:[0.0,0.0,50.0] rotation: (eulertoquat (eulerAngles 0 0 0))

z_name = "mybitmap.png"

--get z buffer          
rbmp = render outputsize:[512,424] channels:#(#zdepth) vfb:off camera: z_cam
z_d = getchannelasmask rbmp #zdepth outputfile:z_name 
z_d.fileName = z_name
save z_d
close z_d

However, this will save the image as 24-Bit Png, with 3 Channels (8 bit each channel). I wish to save it as a grayscale image, where I use 16-Bit for the pixel representation. How can achieve that with max-script?


Solution

  • Did you try calling pngio.setType #gray16 beforehands?

    Alternatively, save to exr with a zDepth channel and use that.