def main(): ########### gdk_rgb_set_verbose (TRUE); push_rgb_visual() try: tbf_readlen = os.environ["TBF_READLEN"] except KeyError: tbf_readlen = "" if tbf_readlen: readlen = string.atoi(tbf_readlen) try: tbf_bps = os.environ["TBF_KBPS"] except KeyError: tbf_bps = "" if tbf_bps: bps = string.atoi(tbf_bps) print "Simulating %d kBytes/sec" % bps readlen = (bps * 1024) / 10 i = 1 if len(sys.argv) == 1: print "USAGE: testanimation.py FILE1 ..." return 0 for i in range(1, len(sys.argv)): animation = GdkPixbuf.GdkPixbufAnimationFromFile(sys.argv[i]) j = 0 frames = animation.get_frames() for frame in frames: pixbuf = frame.get_pixbuf() title = "Frame %d" % j print "Frame %d x:%d y:%d width:%d height:%d" % \ (j, frame.get_x_offset(), frame.get_y_offset(), pixbuf.get_width(), pixbuf.get_height()) new_testrgb_window(pixbuf, title) j = j + 1 found_valid = TRUE mainloop() return 0
text = text + "delay time == %d\n" % frame.get_delay_time() action = frame.get_action() if action == 0: action_string = "FRAME_RETAIN" elif action == 1: action_string = "FRAME_DISPOSE" elif action == 2: action_string = "FRAME_REVERT" else: raise "BadEnumHaHa" text = text + "action == %s" % action_string label = GtkLabel(text) vbox.pack_start(label, FALSE, FALSE) win.show_all() anim = GdkPixbuf.GdkPixbufAnimationFromFile("anim.gif") #anim = GdkPixbuf.GdkPixbufAnimationFromFile ("pic.jpg") frames = anim.get_frames() print "width == %d" % anim.get_width() print "height == %d" % anim.get_height() print "number of frames = %d" % anim.get_num_frames() print "frames == ", frames for frame in frames: show_frame(frame) app() mainloop()