Exemple #1
0
 def test_SDL_CreateRGBSurfaceWithFormatFrom(self):
     for buf, bpp, pitch, masks, fmt in rgba_pixelations_16x16:
         if bpp == 32:
             arflag = "I"
         elif bpp == 16:
             arflag = "H"
         bytebuf = CTypesView(array.array(arflag, buf))
         bufptr = cast(bytebuf.to_bytes(), POINTER(Uint8))
         sf = surface.SDL_CreateRGBSurfaceWithFormatFrom(
             bufptr, 16, 16, bpp, pitch, fmt)
         self.assertIsInstance(sf.contents, surface.SDL_Surface)
         surface.SDL_FreeSurface(sf)
Exemple #2
0
 def test_SDL_ConvertPixels(self):
     for buf, bpp, pitch, masks, fmt in rgba_pixelations_16x16:
         bytecount = bpp // 8
         arflag = None
         if bpp == 32:
             arflag = "I"
         elif bpp == 16:
             arflag = "H"
         src = CTypesView(array.array(arflag, buf), bytecount)
         srcp = cast(src.to_bytes(), POINTER(Uint8))
         dst = (Uint8 * len(src))()
         dstp = cast(dst, POINTER(Uint8))
         ret = surface.SDL_ConvertPixels(16, 16, fmt, srcp, 16 * bytecount,
                                         fmt, dstp, 16 * bytecount)
         self.assertEqual(ret, 0)
         for index, val in enumerate(dst):
             self.assertEqual(val, src.view[index])