def loadImage(filePath):

    inputImg = ASVLOFFSCREEN()

    if bUseBGRToEngine:  #true
        bufferInfo = ImageLoader.getBGRFromFile(filePath)
        inputImg.u32PixelArrayFormat = ASVL_COLOR_FORMAT.ASVL_PAF_RGB24_B8G8R8
        inputImg.i32Width = bufferInfo.width
        inputImg.i32Height = bufferInfo.height
        inputImg.pi32Pitch[0] = bufferInfo.width * 3
        inputImg.ppu8Plane[0] = cast(bufferInfo.buffer, c_ubyte_p)
        inputImg.ppu8Plane[1] = cast(0, c_ubyte_p)
        inputImg.ppu8Plane[2] = cast(0, c_ubyte_p)
        inputImg.ppu8Plane[3] = cast(0, c_ubyte_p)
    else:
        bufferInfo = ImageLoader.getI420FromFile(filePath)
        inputImg.u32PixelArrayFormat = ASVL_COLOR_FORMAT.ASVL_PAF_I420
        inputImg.i32Width = bufferInfo.width
        inputImg.i32Height = bufferInfo.height
        inputImg.pi32Pitch[0] = inputImg.i32Width
        inputImg.pi32Pitch[1] = inputImg.i32Width // 2
        inputImg.pi32Pitch[2] = inputImg.i32Width // 2
        inputImg.ppu8Plane[0] = cast(bufferInfo.buffer, c_ubyte_p)
        inputImg.ppu8Plane[1] = cast(
            addressof(inputImg.ppu8Plane[0].contents) +
            (inputImg.pi32Pitch[0] * inputImg.i32Height), c_ubyte_p)
        inputImg.ppu8Plane[2] = cast(
            addressof(inputImg.ppu8Plane[1].contents) +
            (inputImg.pi32Pitch[1] * inputImg.i32Height // 2), c_ubyte_p)
        inputImg.ppu8Plane[3] = cast(0, c_ubyte_p)
    inputImg.gc_ppu8Plane0 = bufferInfo.buffer

    return inputImg
def loadImage(filePath):
    """
    加载图片
    """
    t1 = time.time()
    bufferInfo = ImageLoader.getI420FromFile(filePath)
    inputImg = ASVLOFFSCREEN()
    inputImg.u32PixelArrayFormat = ASVL_COLOR_FORMAT.ASVL_PAF_I420
    inputImg.i32Width = bufferInfo.width
    inputImg.i32Height = bufferInfo.height
    inputImg.pi32Pitch[0] = inputImg.i32Width
    inputImg.pi32Pitch[1] = inputImg.i32Width // 2
    inputImg.pi32Pitch[2] = inputImg.i32Width // 2
    inputImg.ppu8Plane[0] = cast(bufferInfo.buffer, c_ubyte_p)
    inputImg.ppu8Plane[1] = cast(
        addressof(inputImg.ppu8Plane[0].contents) +
        (inputImg.pi32Pitch[0] * inputImg.i32Height), c_ubyte_p)
    inputImg.ppu8Plane[2] = cast(
        addressof(inputImg.ppu8Plane[1].contents) +
        (inputImg.pi32Pitch[1] * inputImg.i32Height // 2), c_ubyte_p)
    inputImg.ppu8Plane[3] = cast(0, c_ubyte_p)

    inputImg.gc_ppu8Plane0 = bufferInfo.buffer
    t2 = time.time()
    print('Time on loadImage:',t2-t1)

    return inputImg