ó «‡Uc@sÜdZddlZddlZddlZejdƒddlZddlZdZdZej j ej j e ƒdƒZ dZdd d d d d ddgZdejfd„ƒYZd„ZedkrØeƒndS(sPixbufs A GdkPixbuf represents an image, normally in RGB or RGBA format. Pixbufs are normally used to load files from disk and perform image scaling. This demo is not all that educational, but looks cool. It was written by Extreme Pixbuf Hacker Federico Mena Quintero. It also shows off how to use GtkDrawingArea to do a simple animation. Look at the Image demo for additional pixbuf usage examples.iÿÿÿÿNs2.0i2i<timagessbackground.jpgs apple-red.pngsgnome-applets.pngsgnome-calendar.pngsgnome-foot.pngsgnome-gmush.pngsgnome-gimp.pngsgnome-gsame.pngs gnu-keys.pngt PixbufsDemocBsheZdZdZgZdZdZdZdZ dZdd„Z d„Z d„Z d„Z d„ZRS(icCsftjj|ƒy|j|jƒƒWn$tk rM|jdd„ƒnX|jd|jƒ|j|j j ƒ|j t ƒ|j ƒsÑtj|tjtjtjdƒ}|jdd„ƒ|jƒn‘|j|j|jƒtjjtjjt d|j|jƒ|_tjƒ}|jd|jƒ|j|ƒtjt|j ƒ|_!|j"ƒdS(NtdestroycWs tjƒS(N(tgtkt main_quit(tw((s%/usr/lib/pygtk27/2.0/demos/pixbufs.pyt3ssFailed to load an imagetresponsecSs |jƒS(N(R(tdtr((s%/usr/lib/pygtk27/2.0/demos/pixbufs.pyR>sit expose_event(#RtWindowt__init__t set_screent get_screentAttributeErrortconnecttcleanup_callbackt set_titlet __class__t__name__t set_resizabletFalset load_pixbufst MessageDialogtDIALOG_DESTROY_WITH_PARENTt MESSAGE_ERRORt BUTTONS_CLOSEtshowtset_size_requestt back_widtht back_heighttgdktPixbuftCOLORSPACE_RGBtframet DrawingAreat expose_cbtaddtgobjectt timeout_addt FRAME_DELAYttimeoutt timeout_idtshow_all(tselftparenttdialogtda((s%/usr/lib/pygtk27/2.0/demos/pixbufs.pyR .s0        cCs×|jdk rtSy(tjjtjjt t ƒƒ|_Wnt j k rT}t SX|jjƒ|_|jjƒ|_xWtD]O}y/|jjtjjtjjt |ƒƒƒWq€t j k rÎ}t SXq€WtS(s` Loads the images for the demo and returns whether the operation succeeded. N(t backgroundtNonetTrueRR tpixbuf_new_from_filetostpathtjoint IMAGE_DIRtBACKGROUND_NAMER'tGErrorRt get_widthRt get_heightRt image_namesRtappend(R-terrortfilename((s%/usr/lib/pygtk27/2.0/demos/pixbufs.pyROs    c Csw|jjƒ}|jjƒ}|jj|jj|jj|jj |jj |jj d|||jj|jj ƒ t S(s' Expose callback for the drawing area. tnormal( R#t get_rowstridet get_pixelstwindowtdraw_rgb_imagetstyletblack_gctareatxtytwidththeightR3(R-t draw_areateventt rowstridetpixels((s%/usr/lib/pygtk27/2.0/demos/pixbufs.pyR%is  cCs/|jdk r+tj|jƒd|_ndS(N(R+R2R't source_remove(R-twin((s%/usr/lib/pygtk27/2.0/demos/pixbufs.pyR|sc Cs]|jjdd|j|j|jddƒt|jtƒttƒ}|jd}|jd}t||ƒd}t t ƒ}x­t D]¥}t j |ƒ}dt j |||dt j }|j|jƒ} |j|jƒ} ||dt j|dt j ƒ} t j|| t j|ƒ| ddƒ} t j|| t j|ƒ| ddƒ} |ddkr’t j|dt j ƒ}nt j|dt j ƒ}d||}td|ƒ}tjjƒ}t| ƒ|_t| ƒ|_| ||_| ||_tjjƒ}d|_d|_|j|_|j|_|j|ƒ}|d k rˆ|ddkr­ttdt jdt j|dt j ƒƒƒƒ}n6ttdt jdt j|dt j ƒƒƒƒ}|j|j |j|j|j|j|j| | ||tjj!|ƒ qˆqˆW|d k rJ|j"ƒn|jd 7_t#S( s* Timeout handler to regenerate the frame. ig@g@gà?igÐ?iiÿiN($R1t copy_areaRRR#tfloatt frame_numt CYCLE_LENtmintlenR=tindextmathtpiRR;R<tsintfloortcostmaxRR t RectangletintRIRJRKRLt intersectR2tfabst compositetINTERP_NEARESTt queue_drawR3(R-tftxmidtymidtradiustN_IMAGESti_nametitangtiwtihR txpostypostktr1tr2tdesttalpha((s%/usr/lib/pygtk27/2.0/demos/pixbufs.pyR*sb    $&,,       63      N(Rt __module__R2R#R1RRRR+RUR RR%RR*(((s%/usr/lib/pygtk27/2.0/demos/pixbufs.pyR$s !   cCstƒtjƒdS(N(RRtmain(((s%/usr/lib/pygtk27/2.0/demos/pixbufs.pyRyÆst__main__(t__doc__R5RZtpygtktrequireR'RR)RVR6R7tdirnamet__file__R8R9R=R RRyR(((s%/usr/lib/pygtk27/2.0/demos/pixbufs.pyt s,      ! ¢