예제 #1
0
 def unpremultiply(self, img_data):
     if type(img_data) not in (str, _buffer):
         try:
             unpremultiply_argb_in_place(img_data)
             return img_data
         except:
             log.warn("failed to unpremultiply %s (len=%s)" % (type(img_data), len(img_data)))
     return unpremultiply_argb(img_data)
예제 #2
0
 def unpremultiply(self, img_data):
     if type(img_data) not in (str, _buffer):
         try:
             unpremultiply_argb_in_place(img_data)
             return img_data
         except:
             log.warn("failed to unpremultiply %s (len=%s)" % (type(img_data), len(img_data)))
     return unpremultiply_argb(img_data)
예제 #3
0
 def unpremultiply(self, img_data):
     from xpra.codecs.argb.argb import unpremultiply_argb, unpremultiply_argb_in_place   #@UnresolvedImport
     if type(img_data) not in (str, _buffer):
         try:
             unpremultiply_argb_in_place(img_data)
             return img_data
         except:
             log.warn("failed to unpremultiply %s (len=%s)" % (type(img_data), len(img_data)))
     return unpremultiply_argb(img_data)
예제 #4
0
 def unpremultiply(self, img_data):
     if type(img_data) == str:
         #cannot do in-place:
         assert unpremultiply_argb is not None, "missing argb.unpremultiply_argb"
         return byte_buffer_to_buffer(unpremultiply_argb(img_data))
     #assume this is a writeable buffer (ie: ctypes from mmap):
     assert unpremultiply_argb_in_place is not None, "missing argb.unpremultiply_argb_in_place"
     unpremultiply_argb_in_place(img_data)
     return img_data
예제 #5
0
 def unpremultiply(self, img_data):
     if type(img_data)==str:
         #cannot do in-place:
         assert unpremultiply_argb is not None, "missing argb.unpremultiply_argb"
         return byte_buffer_to_buffer(unpremultiply_argb(img_data))
     #assume this is a writeable buffer (ie: ctypes from mmap):
     assert unpremultiply_argb is not None, "missing argb.unpremultiply_argb_in_place"
     unpremultiply_argb_in_place(img_data)
     return img_data
예제 #6
0
 def _do_paint_rgb32(self, img_data, x, y, width, height, rowstride, options, callbacks):
     #log.debug("do_paint_rgb32(%s bytes, %s, %s, %s, %s, %s, %s, %s) backing depth=%s", len(img_data), x, y, width, height, rowstride, options, callbacks, self._backing.get_depth())
     #log.info("data head=%s", [hex(ord(v))[2:] for v in list(img_data[:500])])
     if self._backing is None:
         return  False
     from xpra.codecs.argb.argb import unpremultiply_argb, unpremultiply_argb_in_place, byte_buffer_to_buffer   #@UnresolvedImport
     if type(img_data)==str or not hasattr(img_data, "raw"):
         #cannot do in-place:
         img_data = byte_buffer_to_buffer(unpremultiply_argb(img_data))
     else:
         #assume this is a writeable buffer (ie: ctypes from mmap):
         unpremultiply_argb_in_place(img_data)
     pixbuf = gdk.pixbuf_new_from_data(img_data, gtk.gdk.COLORSPACE_RGB, True, 8, width, height, rowstride)
     cr = self._backing.cairo_create()
     cr.rectangle(x, y, width, height)
     cr.set_source_pixbuf(pixbuf, x, y)
     cr.set_operator(cairo.OPERATOR_SOURCE)
     cr.paint()
     return True
예제 #7
0
 def _do_paint_rgb32(self, img_data, x, y, width, height, rowstride,
                     options, callbacks):
     #log.debug("do_paint_rgb32(%s bytes, %s, %s, %s, %s, %s, %s, %s) backing depth=%s", len(img_data), x, y, width, height, rowstride, options, callbacks, self._backing.get_depth())
     #log.info("data head=%s", [hex(ord(v))[2:] for v in list(img_data[:500])])
     if self._backing is None:
         return False
     from xpra.codecs.argb.argb import unpremultiply_argb, unpremultiply_argb_in_place, byte_buffer_to_buffer  #@UnresolvedImport
     if type(img_data) == str or not hasattr(img_data, "raw"):
         #cannot do in-place:
         img_data = byte_buffer_to_buffer(unpremultiply_argb(img_data))
     else:
         #assume this is a writeable buffer (ie: ctypes from mmap):
         unpremultiply_argb_in_place(img_data)
     pixbuf = gdk.pixbuf_new_from_data(img_data, gtk.gdk.COLORSPACE_RGB,
                                       True, 8, width, height, rowstride)
     cr = self._backing.cairo_create()
     cr.rectangle(x, y, width, height)
     cr.set_source_pixbuf(pixbuf, x, y)
     cr.set_operator(cairo.OPERATOR_SOURCE)
     cr.paint()
     return True
예제 #8
0
 def unpremultiply(self, img_data):
     try:
         unpremultiply_argb_in_place(img_data)
         return img_data
     except:
         return byte_buffer_to_buffer(unpremultiply_argb(img_data))