def convertImageToBuffer(img): from floatcanvas.math import numpy w, h = img.GetWidth(), img.GetHeight() img_data = numpy.array( [ord(c) for c in img.GetDataBuffer()], dtype = 'u8' ).reshape( (w, h, 3) ) if not img.HasAlpha(): return img_data else: data = numpy.empty( (w,h,4), 'u8' ) data[...,:3] = img_data data[...,3] = numpy.array( [ord(c) for c in img.GetAlphaBuffer()], dtype = 'u8' ).reshape(w,h) return data
def convertImageToBuffer(img): from floatcanvas.math import numpy w, h = img.GetWidth(), img.GetHeight() img_data = numpy.array([ord(c) for c in img.GetDataBuffer()], dtype='u8').reshape((w, h, 3)) if not img.HasAlpha(): return img_data else: data = numpy.empty((w, h, 4), 'u8') data[..., :3] = img_data data[..., 3] = numpy.array([ord(c) for c in img.GetAlphaBuffer()], dtype='u8').reshape(w, h) return data
def testMercatorInverse(self): t = MercatorTransform( 0, 100 ) coords = numpy.array( [ (1,1), (0,0), (0.5, 0.8) ] ) tc = t( coords ) ttc = t.inverse( tc ) self.assert_( (ttc == coords).all(), ( tc, ttc, coords ) )
def setUp(self): self.coords2d = numpy.array( [ (0,0), (2,0), (2,2), (0,2) ] ) self.coords3d = numpy.array( [ (0,0,0), (2,0,0), (2,2,0), (0,2,0) ] )