+# This shows how to save ImageArray objects, such as those returned from
+# volume renderings, to pngs with varying backgrounds.
+# Lets make a fake "rendering" that has 4 channels and looks like a linear
+# gradient from the bottom to top.
+im = np.zeros([64,128,4])
+for i in xrange(im.shape):
+ for k in xrange(im.shape):
+ im[i,:,k] = np.linspace(0.,10.*k, im.shape)
+# in this case you would have gotten im_arr from something like:
+# im_arr = cam.snapshot()
+# To save it with the default settings, we can just use write_png, where it
+# rescales the image and uses a black background.
+# write_png accepts a background keyword argument that defaults to 'black'.
+# Other choices include:
+# None (0.,0.,0.,0.) <-- Transparent!
+# any rgba list/array: [r,g,b,a], bounded by 0..1