def testSetRGBAImage(self): """set image of new symbolObj""" assert self.x_symbol.name == 'xmarks' assert self.x_symbol.type == mapscript.MS_SYMBOL_PIXMAP format = mapscript.outputFormatObj('GD/PNG') img = self.x_symbol.getImage(format) img.save('set-%s.%s' % (self.x_symbol.name, img.format.extension))
def testSetPCTImage(self): """set image of new symbolObj""" assert self.h_symbol.name == 'house' assert self.h_symbol.type == mapscript.MS_SYMBOL_PIXMAP format = mapscript.outputFormatObj('GD/PNG') format.transparent = mapscript.MS_ON img = self.h_symbol.getImage(format) img.save('set-%s.%s' % (self.h_symbol.name, img.format.extension))
def testConstructorImage(self): """create new instance of symbolObj from an image""" symbol = mapscript.symbolObj('xmarks', XMARKS_IMAGE) assert symbol.name == 'xmarks' assert symbol.type == mapscript.MS_SYMBOL_PIXMAP format = mapscript.outputFormatObj('GD/PNG') img = symbol.getImage(format) img.save('sym-%s.%s' % (symbol.name, img.format.extension))
def testConstructorWithFormat(self): """imageObj with an optional driver works""" driver = 'GD/PNG' format = mapscript.outputFormatObj(driver) imgobj = mapscript.imageObj(10, 10, format) assert imgobj.thisown == 1 assert imgobj.format.driver == driver assert imgobj.height == 10 assert imgobj.width == 10
def testRemoveOutputFormat(self): """testRemoveOutputFormat may fail depending on GD options""" num = self.map.numoutputformats new_format = mapscript.outputFormatObj('GDAL/GTiff', 'gtiffx') self.map.appendOutputFormat(new_format) assert self.map.numoutputformats == num + 1 assert new_format.refcount == 2, new_format.refcount assert self.map.removeOutputFormat('gtiffx') == mapscript.MS_SUCCESS assert new_format.refcount == 1, new_format.refcount assert self.map.numoutputformats == num self.assertRaises(mapscript.MapServerError, self.map.selectOutputFormat, 'gtiffx') self.map.selectOutputFormat('GTiff') assert self.map.outputformat.mimetype == 'image/tiff'
def testAppendNewOutputFormat(self): """test that a new output format can be created on-the-fly""" num = self.map.numoutputformats new_format = mapscript.outputFormatObj('GDAL/GTiff', 'gtiffx') assert new_format.refcount == 1, new_format.refcount self.map.appendOutputFormat(new_format) assert self.map.numoutputformats == num + 1 assert new_format.refcount == 2, new_format.refcount self.map.selectOutputFormat('gtiffx') self.map.save('testAppendNewOutputFormat.map') self.map.getLayerByName('INLINE-PIXMAP-RGBA').status = mapscript.MS_ON imgobj = self.map.draw() filename = 'testAppendNewOutputFormat.tif' imgobj.save(filename)
def testOutputFormatConstructor(self): new_format = mapscript.outputFormatObj('GDAL/GTiff', 'gtiff') assert new_format.refcount == 1, new_format.refcount assert new_format.name == 'gtiff' assert new_format.mimetype == 'image/tiff'