Esempio n. 1
0
 def array2bmp(array, alpha):
     w = array.shape[0]
     h = array.shape[1]
     im = wxEmptyImage(h, w)
     im.SetData(array.tostring())
     image_SetAlpha(im, alpha)
     return im.ConvertToBitmap()
Esempio n. 2
0
 def scale_bitmap(figure_image, bitmap):
    h, w, d  = figure_image.shape
    bitmapw, bitmaph = bitmap.GetSize()
    image = wxEmptyImage(w, h)
    image.SetData(figure_image[:,:,0:3].tostring())
    image_SetAlpha(image, figure_image[:,:,3])
    return image.Scale(csize[0], csize[1]).ConvertToBitmap()
Esempio n. 3
0
 def array2bmp(array, alpha):
     w = array.shape[0]
     h = array.shape[1]
     im = wxEmptyImage(h, w)
     im.SetData(array.tostring())
     image_SetAlpha(im, alpha)
     return im.ConvertToBitmap()
Esempio n. 4
0
def make_bitmap_with_bluebox(bitmap):
    # second bitmap has blue box around it
    h, w = bitmap.GetSize()
    image = bitmap.ConvertToImage()
    alpha = np.frombuffer(bytes(image_GetAlpha(image)),
                          dtype=np.uint8).reshape(w, h, -1)
    array = np.frombuffer(bytes(image.GetData()), dtype=np.uint8)
    array = array.copy()
    alpha = alpha.copy()

    array = array.reshape(w, h, -1)
    array[0, 1:-2, :1] = 0
    array[-1, 1:-2, :1] = 0
    array[1:-2, 0, :1] = 0
    array[1:-2, -1, :1] = 0

    array[1, 1, :1] = 0
    array[1, -2, :1] = 0
    array[-2, 1, :1] = 0
    array[-2, -2, :1] = 0

    array[1, 1, 2] = 255
    array[1, -2, 2] = 255
    array[-2, 1, 2] = 255
    array[-2, -2, 2] = 255

    array[0, 1:-2, 2] = 255
    array[-1, 1:-2, 2] = 255
    array[1:-2, 0, 2] = 255
    array[1:-2, -1, 2] = 255

    alpha[1:-2, -1] = 127
    alpha[1:-2, 0] = 127
    alpha[0, 1:-2] = 127
    alpha[-1, 1:-2] = 127
    alpha[1, 1] = 127
    alpha[1, -2] = 127
    alpha[-2, 1] = 127
    alpha[-2, -2] = 127
    image = wxEmptyImage(h, w)
    image.SetData(array.tobytes())
    image_SetAlpha(image, alpha)
    bitmap2 = image.ConvertToBitmap()

    return bitmap2
Esempio n. 5
0
def make_bitmap_with_bluebox(bitmap):
        ### second bitmap has blue box around it
        h, w = bitmap.GetSize()
        image = bitmap.ConvertToImage()
        alpha = np.fromstring(bytes(image_GetAlpha(image)), 
                              dtype=np.uint8).reshape(w, h, -1)
        array = np.fromstring(bytes(image.GetData()), 
                   dtype=np.uint8)
        array = array.reshape(w, h, array.shape[0]/w/h)
        array[0,   1:-2,  :1]  = 0 
        array[-1,  1:-2,  :1]  = 0
        array[1:-2,   0,  :1]  = 0
        array[1:-2,  -1,  :1]  = 0

        array[1,1,:1] = 0
        array[1,-2,:1] = 0
        array[-2,1,:1] = 0
        array[-2,-2,:1] = 0

        array[1,1,  2] = 255
        array[1,-2, 2] = 255
        array[-2,1, 2] = 255
        array[-2,-2,2] = 255

        array[0,   1:-2, 2]=255
        array[-1,  1:-2, 2]=255
        array[1:-2,   0, 2]=255
        array[1:-2,  -1, 2]=255

        alpha[1:-2,   -1] = 127
        alpha[1:-2,    0] = 127
        alpha[0,    1:-2] = 127
        alpha[-1,   1:-2] = 127
        alpha[1,1] = 127
        alpha[1,-2] = 127
        alpha[-2,1] = 127
        alpha[-2,-2] = 127
        image = wxEmptyImage(h, w)
        image.SetData(array.tostring())
        image_SetAlpha(image, alpha)
        bitmap2 = image.ConvertToBitmap()

        return bitmap2