Ejemplo n.º 1
0
def test_viewcreation():
    qimg = QtGui.QImage(320, 240, QtGui.QImage.Format_RGB32)
    v = _qimageview(qimg)
    assert_equal(v.shape, (240, 320))
    assert v.base is qimg
    del qimg
    w, h = v.base.width(), v.base.height()  # should not segfault
    assert_equal((w, h), (320, 240))
Ejemplo n.º 2
0
def test_odd_size_32bit():
    qimg = QtGui.QImage(321, 240, QtGui.QImage.Format_ARGB32)
    qimg.fill(0)
    v = _qimageview(qimg)
    qimg.setPixel(12, 10, 42)
    assert_equal(v.shape, (240, 321))
    assert_equal(v[10,12], 42)
    assert_equal(v.strides[0], qimg.bytesPerLine())
Ejemplo n.º 3
0
def test_data_access():
    qimg = QtGui.QImage(320, 240, QtGui.QImage.Format_Indexed8)
    setNumColors(qimg, 256)
    qimg.fill(42)
    v = _qimageview(qimg)
    assert_equal(v.shape, (240, 320))
    assert_equal(v[10,10], 42)
    assert_equal(v.nbytes, numBytes(qimg))
Ejemplo n.º 4
0
def test_viewcreation():
    qimg = QtGui.QImage(320, 240, QtGui.QImage.Format_RGB32)
    v = _qimageview(qimg)
    assert_equal(v.shape, (240, 320))
    assert v.base is qimg
    del qimg
    w, h = v.base.width(), v.base.height() # should not segfault
    assert_equal((w, h), (320, 240))
Ejemplo n.º 5
0
def test_odd_size_32bit():
    qimg = QtGui.QImage(321, 240, QtGui.QImage.Format_ARGB32)
    qimg.fill(0)
    v = _qimageview(qimg)
    qimg.setPixel(12, 10, 42)
    assert_equal(v.shape, (240, 321))
    assert_equal(v[10, 12], 42)
    assert_equal(v.strides[0], qimg.bytesPerLine())
Ejemplo n.º 6
0
def test_ARGB32():
    qimg = QtGui.QImage(320, 240, QtGui.QImage.Format_ARGB32)
    qimg.fill(0)
    v = _qimageview(qimg)
    qimg.setPixel(12, 10, 42)
    assert_equal(v.shape, (240, 320))
    assert_equal(v[10,12], 42)
    assert_equal(v.nbytes, numBytes(qimg))
Ejemplo n.º 7
0
def test_data_access():
    qimg = QtGui.QImage(320, 240, QtGui.QImage.Format_Indexed8)
    setNumColors(qimg, 256)
    qimg.fill(42)
    v = _qimageview(qimg)
    assert_equal(v.shape, (240, 320))
    assert_equal(v[10, 10], 42)
    assert_equal(v.nbytes, numBytes(qimg))
Ejemplo n.º 8
0
def test_ARGB32():
    qimg = QtGui.QImage(320, 240, QtGui.QImage.Format_ARGB32)
    qimg.fill(0)
    v = _qimageview(qimg)
    qimg.setPixel(12, 10, 42)
    assert_equal(v.shape, (240, 320))
    assert_equal(v[10, 12], 42)
    assert_equal(v.nbytes, numBytes(qimg))
Ejemplo n.º 9
0
def test_RGBA8888():
    qimg = QtGui.QImage(320, 240, QtGui.QImage.Format_RGBA8888)
    qimg.fill(0)
    v = _qimageview(qimg)
    qimg.setPixel(12, 10, QtGui.qRgb(0x12, 0x34, 0x56))
    assert_equal(v.shape, (240, 320))
    assert_equal(v[10, 12],
                 0x123456ff if sys.byteorder == 'big' else 0xff563412)
    assert_equal(v.nbytes, numBytes(qimg))
Ejemplo n.º 10
0
def test_ARGB32():
    qimg = QtGui.QImage(320, 240, QtGui.QImage.Format_ARGB32)
    qimg.fill(0)
    v = _qimageview(qimg)
    qimg.setPixel(12, 10, QtGui.qRgb(0x12, 0x34, 0x56))
    assert_equal(v.shape, (240, 320))
    assert_equal(v[10, 12],
                 0xff123456 if sys.byteorder == 'little' else 0x563412ff)
    assert_equal(v.nbytes, numBytes(qimg))
Ejemplo n.º 11
0
def test_odd_size_8bit():
    qimg = QtGui.QImage(321, 240, QtGui.QImage.Format_Indexed8)
    setNumColors(qimg, 256)
    qimg.fill(0)
    v = _qimageview(qimg)
    qimg.setPixel(12, 10, 42)
    assert_equal(v.shape, (240, 321))
    assert_equal(v[10, 12], 42)
    assert_equal(v.strides[0], qimg.bytesPerLine())
Ejemplo n.º 12
0
def test_odd_size_8bit():
    qimg = QtGui.QImage(321, 240, QtGui.QImage.Format_Indexed8)
    setNumColors(qimg, 256)
    qimg.fill(0)
    v = _qimageview(qimg)
    qimg.setPixel(12, 10, 42)
    assert_equal(v.shape, (240, 321))
    assert_equal(v[10,12], 42)
    assert_equal(v.strides[0], qimg.bytesPerLine())
Ejemplo n.º 13
0
def test_viewcreation():
    qimg = QtGui.QImage(320, 240, QtGui.QImage.Format_RGB32)
    v = _qimageview(qimg)
    assert_equal(v.shape, (240, 320))
    assert v.base is not None
    del qimg
    if hasattr(v.base, 'width'):
        w, h = v.base.width(), v.base.height() # should not segfault
        assert_equal((w, h), (320, 240))
    v[239] = numpy.arange(320) # should not segfault
def test_viewcreation():
    qimg = QtGui.QImage(320, 240, QtGui.QImage.Format_RGB32)
    v = _qimageview(qimg)
    assert_equal(v.shape, (240, 320))
    assert v.base is not None
    del qimg
    if hasattr(v.base, 'width'):
        w, h = v.base.width(), v.base.height()  # should not segfault
        assert_equal((w, h), (320, 240))
    v[239] = numpy.arange(320)  # should not segfault
Ejemplo n.º 15
0
def test_coordinate_access():
    qimg = QtGui.QImage(320, 240, QtGui.QImage.Format_Indexed8)
    setNumColors(qimg, 256)
    qimg.fill(0)
    v = _qimageview(qimg)
    qimg.fill(23)
    qimg.setPixel(12, 10, 42)
    assert_equal(v.shape, (240, 320))
    assert_equal(v[10,10], 23)
    assert_equal(v[10,12], 42)
    assert_equal(v.nbytes, numBytes(qimg))
Ejemplo n.º 16
0
def test_coordinate_access():
    qimg = QtGui.QImage(320, 240, QtGui.QImage.Format_Indexed8)
    setNumColors(qimg, 256)
    qimg.fill(0)
    v = _qimageview(qimg)
    qimg.fill(23)
    qimg.setPixel(12, 10, 42)
    assert_equal(v.shape, (240, 320))
    assert_equal(v[10, 10], 23)
    assert_equal(v[10, 12], 42)
    assert_equal(v.nbytes, numBytes(qimg))
Ejemplo n.º 17
0
def test_RGBX64():
    qimg = QtGui.QImage(320, 240, QtGui.QImage.Format_RGBX64)
    qimg.fill(QtGui.qRgb(0, 0, 0))
    v = _qimageview(qimg)
    qimg.setPixel(12, 10, QtGui.qRgb(0x12, 0x34, 0x56))
    assert_equal(v.shape, (240, 320))
    assert_equal(v[10, 10],
                 0xffff000000000000 if sys.byteorder == 'little' else 0xffff)
    assert_equal(
        v[10, 12], 0xffff565634341212
        if sys.byteorder == 'little' else 0x121234345656ffff)
    assert_equal(v.nbytes, numBytes(qimg))
Ejemplo n.º 18
0
def test_mono():
    qimg = QtGui.QImage(320, 240, QtGui.QImage.Format_Mono)
    v = _qimageview(qimg)
Ejemplo n.º 19
0
def test_rgb666():
    qimg = QtGui.QImage(320, 240, QtGui.QImage.Format_RGB666)
    v = _qimageview(qimg)
Ejemplo n.º 20
0
def test_qimageview_wrongarg():
    v = _qimageview(42)
Ejemplo n.º 21
0
def test_qimageview_manyargs():
    qimg = QtGui.QImage(320, 240, QtGui.QImage.Format_Indexed8)
    v = _qimageview(qimg, 1)
Ejemplo n.º 22
0
def test_qimageview_wrongarg():
    v = _qimageview(42)
Ejemplo n.º 23
0
def test_rgb666():
    qimg = QtGui.QImage(320, 240, QtGui.QImage.Format_RGB666)
    v = _qimageview(qimg)
Ejemplo n.º 24
0
def test_mono():
    qimg = QtGui.QImage(320, 240, QtGui.QImage.Format_Mono)
    v = _qimageview(qimg)
Ejemplo n.º 25
0
def test_qimageview_noargs():
    v = _qimageview()
Ejemplo n.º 26
0
def test_qimageview_noargs():
    v = _qimageview()
Ejemplo n.º 27
0
def test_qimageview_manyargs():
    qimg = QtGui.QImage(320, 240, QtGui.QImage.Format_Indexed8)
    v = _qimageview(qimg, 1)