Skip to content

Commit

Permalink
changing the pixel format may change the rowstride
Browse files Browse the repository at this point in the history
git-svn-id: https://xpra.org/svn/Xpra/trunk@10411 3bb7dfac-3a0b-4e04-842a-767bc560f471
  • Loading branch information
totaam committed Aug 23, 2015
1 parent 292dee1 commit 5a8a982
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/xpra/client/gtk2/pixmap_backing.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,20 +80,20 @@ def init(self, w, h):

def bgr_to_rgb(self, img_data, width, height, rowstride, rgb_format, target_format):
if not rgb_format.startswith("BGR"):
return img_data
return img_data, rowstride
from xpra.codecs.loader import get_codec
PIL = get_codec("PIL")
img = PIL.Image.frombuffer(target_format, (width, height), img_data, "raw", rgb_format, rowstride)
data_fn = getattr(img, "tobytes", getattr(img, "tostring"))
img_data = data_fn("raw", target_format)
log.warn("%s converted to %s", rgb_format, target_format)
return img_data
return img_data, width*len(target_format)

def _do_paint_rgb24(self, img_data, x, y, width, height, rowstride, options):
log.info("_do_paint_rgb24%s", (len(img_data), x, y, width, height, rowstride, options))
img_data = memoryview_to_bytes(img_data)
if INDIRECT_BGR:
img_data = self.bgr_to_rgb(img_data, width, height, rowstride, options.strget("rgb_format", ""), "RGB")
img_data, rowstride = self.bgr_to_rgb(img_data, width, height, rowstride, options.strget("rgb_format", ""), "RGB")
gc = self._backing.new_gc()
self._backing.draw_rgb_image(gc, x, y, width, height, gdk.RGB_DITHER_NONE, img_data, rowstride)
return True
Expand All @@ -102,7 +102,7 @@ def _do_paint_rgb32(self, img_data, x, y, width, height, rowstride, options):
log.info("_do_paint_rgb32%s", (len(img_data), x, y, width, height, rowstride, options))
img_data = memoryview_to_bytes(self.unpremultiply(img_data))
if INDIRECT_BGR:
img_data = self.bgr_to_rgb(img_data, width, height, rowstride, options.strget("rgb_format", ""), "RGBX")
img_data, rowstride = self.bgr_to_rgb(img_data, width, height, rowstride, options.strget("rgb_format", ""), "RGBX")
gc = self._backing.new_gc()
self._backing.draw_rgb_32_image(gc, x, y, width, height, gdk.RGB_DITHER_NONE, img_data, rowstride)
return True

0 comments on commit 5a8a982

Please sign in to comment.