From: David C. <D. C. <si...@te...> - 2000-04-20 02:19:13
|
Mark Baker writes: > > > Blitting a png takes about 50% longer than an identical bmp. (Of > > course, the png is compressed to 5% of the bmp's size :) > > Are you including the loading time? PNGs are decompressed on load, like all > other image types, so after the load, it should blit at the same rate as a BMP. > The images were loaded to a non-visible surface before the timing loop begins, so I believe there actually is a difference in blit rates between PNGs and BMPs. Here's my (ugly) code: <snip> import sdl, random, sys, time width = 640 height = 480 depth = 16 fb = sdl.video_set_mode(width, height, depth, sdl.SWSURFACE) src = sdl.image_load("./happy.png") #src = sdl.image_load("./happy.bmp") start = time.time() for i in range(500): x_pos = (random.random() * (width * 0.9)) y_pos = (random.random() * (height * 0.9)) fb.blit(src, (0, 0, 64, 48), (x_pos, y_pos, 64, 48)) fb.update_rect((x_pos, y_pos, 64, 48)) # fb.update_rect( (0,0,0,0) ) end = time.time() print "500 repetions took", end-start, "seconds." print "That's", (end-start) * 2, "milliseconds per blit." sdl.quit() sys.exit(0) <snip> As you can see, pretty unsophisticated - I switched between options just by uncommenting and recommenting code :) Anyway, I realize that the timed loop is pretty full, but I was looking for relative numbers here, not absolute measurements. Preliminary pySDL documentation: http://www3.telus.net/futility/futility/docs/pysdl/index.html -- -------------------------------------------------------------------------\ David "Futility [D!]" Clark | "Being healthy" is merely dying at the | si...@te... | slowest possible rate. | |