|
|
|
|||||||||||
Como dibujar un imagen (jpg, png, gif, etc..) en CairoJuly
21
Para dibujar usando cairo por lo general creas un objeto heredando propiedades de gtk.DrawingArea. y obviamente, tenemos un metodo para el redibujado. Dentro de ese metodo metemos esto:
def setPixbuf(self,pixbuf): if type(pixbuf) != gtk.gdk.Pixbuf: raise TypeError("Pixbuf debe ser %s recibido %s"%(gtk.gdk.Pixbuf, type(pixbuf))) self.__Pixbuf = pixbuf self.emit("expose-event",gtk.gdk.Event(gtk.gdk.EXPOSE)) def exposeEvent(self, widget,event): x,y,w,h = self.allocation try: context = self.window.cairo_create() except AttributeError: return True if self.__Pixbuf != None: scaledPixbuf = self.__Pixbuf.scale_simple(ancho, alto, gtk.gdk.INTERP_BILINEAR) ct = gtk.gdk.CairoContext(context) ct.set_source_pixbuf(scaledPixbuf,BORDER_WIDTH,BORDER_WIDTH) context.paint() context.stroke()
Comment XML feeds: RSS | Atom
|
|||||||||||
|
|
|||||||||||