+else:
+ arrout[:,:,0:3] = arrin[:,:,0:3]
+
+
+# Set up the alpha channel.
+if args.mask == '':
+ # Set up mask for portions of the data set not containing terrain.
+ arrt = numpy.ones((tin.height, tin.width), dtype=numpy.dtype(bool))
+ ind0, ind1 = numpy.meshgrid(numpy.linspace(0, tin.height - 1, tin.height),
+ numpy.linspace(0, tin.width - 1, tin.width), indexing='ij')
+ for i in range(0, len(args.terrain), 4):
+ arrt = numpy.logical_and(arrt,
+ numpy.logical_or(numpy.logical_or(
+ ind1 < args.terrain[i], ind0 < args.terrain[i + 1]),
+ numpy.logical_or(ind1 >= args.terrain[i + 2],
+ ind0 >= args.terrain[i + 3])))
+ del ind0, ind1
+
+ # Combine with where the input is equal to transparent color to get
+ # the transparency mask.
+ if palette:
+ if trind is not None:
+ arrout[:,:,3] = numpy.where(
+ numpy.logical_and(arrt, arrin == trind),
+ numpy.zeros((tin.height, tin.width), dtype='u1'),
+ 255 * numpy.ones((tin.height, tin.width), dtype='u1'))
+ else:
+ arrout[:,:,3] = numpy.where(
+ numpy.logical_and(arrt, numpy.logical_and(
+ arrout[:,:,0] == trarr[0], numpy.logical_and(
+ arrout[:,:,1] == trarr[1], arrout[:,:,2] == trarr[2]))),
+ numpy.zeros((tin.height, tin.width), dtype='u1'),
+ 255 * numpy.ones((tin.height, tin.width), dtype='u1'))
+ else: