Ejemplo n.º 1
0
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
Ejemplo n.º 2
0
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
Ejemplo n.º 3
0
 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 ) )
Ejemplo n.º 4
0
 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) ] )