Generated by Cython 0.29.2

Yellow lines hint at Python interaction.
Click on a line that starts with a "+" to see the C code that Cython generated for it.

Raw output: argb.c

 001: # This file is part of Xpra.
 002: # Copyright (C) 2008, 2009 Nathaniel Smith <njs@pobox.com>
 003: # Copyright (C) 2012-2018 Antoine Martin <antoine@devloop.org.uk>
 004: # Xpra is released under the terms of the GNU GPL v2, or, at your option, any
 005: # later version. See the file COPYING for details.
 006: 
 007: #cython: boundscheck=False, wraparound=False, cdivision=True, language_level=3
 008: from __future__ import absolute_import
 009: 
+010: from xpra.os_util import bytestostr
  __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 10, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_n_s_bytestostr);
  __Pyx_GIVEREF(__pyx_n_s_bytestostr);
  PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_bytestostr);
  __pyx_t_2 = __Pyx_Import(__pyx_n_s_xpra_os_util, __pyx_t_1, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 10, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_bytestostr); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 10, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_bytestostr, __pyx_t_1) < 0) __PYX_ERR(0, 10, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+011: from xpra.util import first_time
  __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 11, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(__pyx_n_s_first_time);
  __Pyx_GIVEREF(__pyx_n_s_first_time);
  PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_first_time);
  __pyx_t_1 = __Pyx_Import(__pyx_n_s_xpra_util, __pyx_t_2, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 11, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_1, __pyx_n_s_first_time); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 11, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_first_time, __pyx_t_2) < 0) __PYX_ERR(0, 11, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
 012: from xpra.buffers.membuf cimport getbuf, padbuf, MemBuf
 013: from xpra.buffers.membuf cimport object_as_buffer, object_as_write_buffer
 014: 
 015: from libc.stdint cimport uint32_t, uint16_t, uint8_t
 016: 
+017: import struct
  __pyx_t_1 = __Pyx_Import(__pyx_n_s_struct, 0, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 17, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_struct, __pyx_t_1) < 0) __PYX_ERR(0, 17, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+018: from xpra.log import Logger
  __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 18, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_n_s_Logger);
  __Pyx_GIVEREF(__pyx_n_s_Logger);
  PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_Logger);
  __pyx_t_2 = __Pyx_Import(__pyx_n_s_xpra_log, __pyx_t_1, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 18, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_Logger); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 18, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_Logger, __pyx_t_1) < 0) __PYX_ERR(0, 18, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+019: log = Logger("encoding")
  __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_Logger); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 19, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_tuple_, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 19, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_log, __pyx_t_1) < 0) __PYX_ERR(0, 19, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
/* … */
  __pyx_tuple_ = PyTuple_Pack(1, __pyx_n_u_encoding); if (unlikely(!__pyx_tuple_)) __PYX_ERR(0, 19, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple_);
  __Pyx_GIVEREF(__pyx_tuple_);
 020: 
+021: assert sizeof(int) == 4
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  if (unlikely(!Py_OptimizeFlag)) {
    if (unlikely(!(((sizeof(int)) == 4) != 0))) {
      PyErr_SetNone(PyExc_AssertionError);
      __PYX_ERR(0, 21, __pyx_L1_error)
    }
  }
  #endif
 022: 
 023: 
+024: cdef int as_buffer(object obj, const void ** buffer, Py_ssize_t * buffer_len) except -1:
static int __pyx_f_4xpra_6codecs_4argb_4argb_as_buffer(PyObject *__pyx_v_obj, void const **__pyx_v_buffer, Py_ssize_t *__pyx_v_buffer_len) {
  size_t __pyx_v_l;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("as_buffer", 0);
/* … */
  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("xpra.codecs.argb.argb.as_buffer", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
 025:     cdef size_t l
+026:     if isinstance(obj, MemBuf):
  __pyx_t_1 = __Pyx_TypeCheck(__pyx_v_obj, __pyx_ptype_4xpra_7buffers_6membuf_MemBuf); 
  __pyx_t_2 = (__pyx_t_1 != 0);
  if (__pyx_t_2) {
/* … */
  }
+027:         buffer[0] = <const void*> (<MemBuf> obj).get_mem()
    (__pyx_v_buffer[0]) = ((void const *)((struct __pyx_vtabstruct_4xpra_7buffers_6membuf_MemBuf *)((struct __pyx_obj_4xpra_7buffers_6membuf_MemBuf *)__pyx_v_obj)->__pyx_vtab)->get_mem(((struct __pyx_obj_4xpra_7buffers_6membuf_MemBuf *)__pyx_v_obj)));
+028:         l = len(obj)
    __pyx_t_3 = PyObject_Length(__pyx_v_obj); if (unlikely(__pyx_t_3 == ((Py_ssize_t)-1))) __PYX_ERR(0, 28, __pyx_L1_error)
    __pyx_v_l = __pyx_t_3;
+029:         buffer_len[0] = <Py_ssize_t> l
    (__pyx_v_buffer_len[0]) = ((Py_ssize_t)__pyx_v_l);
+030:         return 0
    __pyx_r = 0;
    goto __pyx_L0;
+031:     return object_as_buffer(obj, buffer, buffer_len)
  __pyx_r = __pyx_f_4xpra_7buffers_6membuf_object_as_buffer(__pyx_v_obj, __pyx_v_buffer, __pyx_v_buffer_len);
  goto __pyx_L0;
 032: 
 033: 
+034: cdef inline unsigned char clamp(int v):
static CYTHON_INLINE unsigned char __pyx_f_4xpra_6codecs_4argb_4argb_clamp(int __pyx_v_v) {
  unsigned char __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("clamp", 0);
/* … */
  /* function exit code */
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
+035:     if v>255:
  __pyx_t_1 = ((__pyx_v_v > 0xFF) != 0);
  if (__pyx_t_1) {
/* … */
  }
+036:         return 255
    __pyx_r = 0xFF;
    goto __pyx_L0;
+037:     return <unsigned char> v
  __pyx_r = ((unsigned char)__pyx_v_v);
  goto __pyx_L0;
 038: 
 039: 
+040: def bgr565_to_rgbx(buf):
/* Python wrapper */
static PyObject *__pyx_pw_4xpra_6codecs_4argb_4argb_1bgr565_to_rgbx(PyObject *__pyx_self, PyObject *__pyx_v_buf); /*proto*/
static PyMethodDef __pyx_mdef_4xpra_6codecs_4argb_4argb_1bgr565_to_rgbx = {"bgr565_to_rgbx", (PyCFunction)__pyx_pw_4xpra_6codecs_4argb_4argb_1bgr565_to_rgbx, METH_O, 0};
static PyObject *__pyx_pw_4xpra_6codecs_4argb_4argb_1bgr565_to_rgbx(PyObject *__pyx_self, PyObject *__pyx_v_buf) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("bgr565_to_rgbx (wrapper)", 0);
  __pyx_r = __pyx_pf_4xpra_6codecs_4argb_4argb_bgr565_to_rgbx(__pyx_self, ((PyObject *)__pyx_v_buf));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4xpra_6codecs_4argb_4argb_bgr565_to_rgbx(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_buf) {
  uint16_t const *__pyx_v_cbuf;
  Py_ssize_t __pyx_v_cbuf_len;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("bgr565_to_rgbx", 0);
/* … */
  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("xpra.codecs.argb.argb.bgr565_to_rgbx", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
/* … */
  __pyx_tuple__2 = PyTuple_Pack(3, __pyx_n_s_buf, __pyx_n_s_cbuf, __pyx_n_s_cbuf_len); if (unlikely(!__pyx_tuple__2)) __PYX_ERR(0, 40, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__2);
  __Pyx_GIVEREF(__pyx_tuple__2);
/* … */
  __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_4xpra_6codecs_4argb_4argb_1bgr565_to_rgbx, NULL, __pyx_n_s_xpra_codecs_argb_argb); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 40, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_bgr565_to_rgbx, __pyx_t_1) < 0) __PYX_ERR(0, 40, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_codeobj__3 = (PyObject*)__Pyx_PyCode_New(1, 0, 3, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__2, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_xpra_codecs_argb_argb_pyx, __pyx_n_s_bgr565_to_rgbx, 40, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__3)) __PYX_ERR(0, 40, __pyx_L1_error)
+041:     assert len(buf) % 2 == 0, "invalid buffer size: %s is not a multiple of 2" % len(buf)
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  if (unlikely(!Py_OptimizeFlag)) {
    __pyx_t_1 = PyObject_Length(__pyx_v_buf); if (unlikely(__pyx_t_1 == ((Py_ssize_t)-1))) __PYX_ERR(0, 41, __pyx_L1_error)
    if (unlikely(!(((__pyx_t_1 % 2) == 0) != 0))) {
      __pyx_t_2 = PyObject_Length(__pyx_v_buf); if (unlikely(__pyx_t_2 == ((Py_ssize_t)-1))) __PYX_ERR(0, 41, __pyx_L1_error)
      __pyx_t_3 = PyInt_FromSsize_t(__pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 41, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_4 = PyUnicode_Format(__pyx_kp_u_invalid_buffer_size_s_is_not_a_m, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 41, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      PyErr_SetObject(PyExc_AssertionError, __pyx_t_4);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __PYX_ERR(0, 41, __pyx_L1_error)
    }
  }
  #endif
 042:     # buf is a Python buffer object
+043:     cdef const uint16_t* cbuf = <const uint16_t*> 0
  __pyx_v_cbuf = ((uint16_t const *)0);
+044:     cdef Py_ssize_t cbuf_len = 0
  __pyx_v_cbuf_len = 0;
+045:     assert as_buffer(buf, <const void**> &cbuf, &cbuf_len)==0, "cannot convert %s to a readable buffer" % type(buf)
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  if (unlikely(!Py_OptimizeFlag)) {
    __pyx_t_5 = __pyx_f_4xpra_6codecs_4argb_4argb_as_buffer(__pyx_v_buf, ((void const **)(&__pyx_v_cbuf)), (&__pyx_v_cbuf_len)); if (unlikely(__pyx_t_5 == ((int)-1))) __PYX_ERR(0, 45, __pyx_L1_error)
    if (unlikely(!((__pyx_t_5 == 0) != 0))) {
      __pyx_t_4 = __Pyx_PyUnicode_FormatSafe(__pyx_kp_u_cannot_convert_s_to_a_readable_b, ((PyObject *)Py_TYPE(__pyx_v_buf))); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 45, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      PyErr_SetObject(PyExc_AssertionError, __pyx_t_4);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __PYX_ERR(0, 45, __pyx_L1_error)
    }
  }
  #endif
+046:     return bgr565data_to_rgbx(cbuf, cbuf_len)
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_4 = __pyx_f_4xpra_6codecs_4argb_4argb_bgr565data_to_rgbx(__pyx_v_cbuf, __pyx_v_cbuf_len); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 46, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_r = __pyx_t_4;
  __pyx_t_4 = 0;
  goto __pyx_L0;
 047: 
+048: cdef bgr565data_to_rgbx(const uint16_t* rgb565, const int rgb565_len):
static PyObject *__pyx_f_4xpra_6codecs_4argb_4argb_bgr565data_to_rgbx(uint16_t const *__pyx_v_rgb565, int const __pyx_v_rgb565_len) {
  struct __pyx_obj_4xpra_7buffers_6membuf_MemBuf *__pyx_v_output_buf = 0;
  uint32_t *__pyx_v_rgbx;
  uint16_t __pyx_v_v;
  unsigned int __pyx_v_i;
  unsigned int __pyx_v_l;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("bgr565data_to_rgbx", 0);
/* … */
  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("xpra.codecs.argb.argb.bgr565data_to_rgbx", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_output_buf);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
+049:     if rgb565_len <= 0:
  __pyx_t_1 = ((__pyx_v_rgb565_len <= 0) != 0);
  if (__pyx_t_1) {
/* … */
  }
+050:         return None
    __Pyx_XDECREF(__pyx_r);
    __pyx_r = Py_None; __Pyx_INCREF(Py_None);
    goto __pyx_L0;
+051:     assert rgb565_len>0 and rgb565_len % 2 == 0, "invalid buffer size: %s is not a multiple of 2" % rgb565_len
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  if (unlikely(!Py_OptimizeFlag)) {
    __pyx_t_2 = ((__pyx_v_rgb565_len > 0) != 0);
    if (__pyx_t_2) {
    } else {
      __pyx_t_1 = __pyx_t_2;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_2 = (((__pyx_v_rgb565_len % 2) == 0) != 0);
    __pyx_t_1 = __pyx_t_2;
    __pyx_L4_bool_binop_done:;
    if (unlikely(!__pyx_t_1)) {
      __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_rgb565_len); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 51, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_4 = PyUnicode_Format(__pyx_kp_u_invalid_buffer_size_s_is_not_a_m, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 51, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      PyErr_SetObject(PyExc_AssertionError, __pyx_t_4);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __PYX_ERR(0, 51, __pyx_L1_error)
    }
  }
  #endif
+052:     cdef MemBuf output_buf = padbuf(rgb565_len*2, 2)
  __pyx_t_4 = __pyx_f_4xpra_7buffers_6membuf_padbuf((__pyx_v_rgb565_len * 2), 2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 52, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  if (!(likely(((__pyx_t_4) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_4, __pyx_ptype_4xpra_7buffers_6membuf_MemBuf))))) __PYX_ERR(0, 52, __pyx_L1_error)
  __pyx_v_output_buf = ((struct __pyx_obj_4xpra_7buffers_6membuf_MemBuf *)__pyx_t_4);
  __pyx_t_4 = 0;
+053:     cdef uint32_t *rgbx = <uint32_t*> output_buf.get_mem()
  __pyx_v_rgbx = ((uint32_t *)((struct __pyx_vtabstruct_4xpra_7buffers_6membuf_MemBuf *)__pyx_v_output_buf->__pyx_vtab)->get_mem(__pyx_v_output_buf));
 054:     cdef uint16_t v
+055:     cdef unsigned int i = 0
  __pyx_v_i = 0;
+056:     cdef unsigned int l = rgb565_len//2
  __pyx_v_l = (__pyx_v_rgb565_len / 2);
+057:     for i in range(l):
  __pyx_t_5 = __pyx_v_l;
  __pyx_t_6 = __pyx_t_5;
  for (__pyx_t_7 = 0; __pyx_t_7 < __pyx_t_6; __pyx_t_7+=1) {
    __pyx_v_i = __pyx_t_7;
+058:         v = rgb565[i]
    __pyx_v_v = (__pyx_v_rgb565[__pyx_v_i]);
+059:         rgbx[i] = 0xff000000 | (((v & 0xF800) >> 8) + ((v & 0x07E0) << 5) + ((v & 0x001F) << 19))
    __pyx_t_4 = __Pyx_PyInt_From_long(((((__pyx_v_v & 0xF800) >> 8) + ((__pyx_v_v & 0x07E0) << 5)) + ((__pyx_v_v & 0x001F) << 19))); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 59, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_3 = PyNumber_Or(__pyx_int_4278190080, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 59, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_8 = __Pyx_PyInt_As_uint32_t(__pyx_t_3); if (unlikely((__pyx_t_8 == ((uint32_t)-1)) && PyErr_Occurred())) __PYX_ERR(0, 59, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    (__pyx_v_rgbx[__pyx_v_i]) = __pyx_t_8;
  }
+060:     return memoryview(output_buf)
  __Pyx_XDECREF(__pyx_r);
  __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_memoryview); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 60, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_t_3, ((PyObject *)__pyx_v_output_buf)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 60, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_r = __pyx_t_4;
  __pyx_t_4 = 0;
  goto __pyx_L0;
 061: 
+062: def bgr565_to_rgb(buf):
/* Python wrapper */
static PyObject *__pyx_pw_4xpra_6codecs_4argb_4argb_3bgr565_to_rgb(PyObject *__pyx_self, PyObject *__pyx_v_buf); /*proto*/
static PyMethodDef __pyx_mdef_4xpra_6codecs_4argb_4argb_3bgr565_to_rgb = {"bgr565_to_rgb", (PyCFunction)__pyx_pw_4xpra_6codecs_4argb_4argb_3bgr565_to_rgb, METH_O, 0};
static PyObject *__pyx_pw_4xpra_6codecs_4argb_4argb_3bgr565_to_rgb(PyObject *__pyx_self, PyObject *__pyx_v_buf) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("bgr565_to_rgb (wrapper)", 0);
  __pyx_r = __pyx_pf_4xpra_6codecs_4argb_4argb_2bgr565_to_rgb(__pyx_self, ((PyObject *)__pyx_v_buf));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4xpra_6codecs_4argb_4argb_2bgr565_to_rgb(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_buf) {
  uint16_t const *__pyx_v_cbuf;
  Py_ssize_t __pyx_v_cbuf_len;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("bgr565_to_rgb", 0);
/* … */
  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("xpra.codecs.argb.argb.bgr565_to_rgb", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
/* … */
  __pyx_tuple__4 = PyTuple_Pack(3, __pyx_n_s_buf, __pyx_n_s_cbuf, __pyx_n_s_cbuf_len); if (unlikely(!__pyx_tuple__4)) __PYX_ERR(0, 62, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__4);
  __Pyx_GIVEREF(__pyx_tuple__4);
/* … */
  __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_4xpra_6codecs_4argb_4argb_3bgr565_to_rgb, NULL, __pyx_n_s_xpra_codecs_argb_argb); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 62, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_bgr565_to_rgb, __pyx_t_1) < 0) __PYX_ERR(0, 62, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_codeobj__5 = (PyObject*)__Pyx_PyCode_New(1, 0, 3, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__4, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_xpra_codecs_argb_argb_pyx, __pyx_n_s_bgr565_to_rgb, 62, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__5)) __PYX_ERR(0, 62, __pyx_L1_error)
+063:     assert len(buf) % 2 == 0, "invalid buffer size: %s is not a multiple of 2" % len(buf)
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  if (unlikely(!Py_OptimizeFlag)) {
    __pyx_t_1 = PyObject_Length(__pyx_v_buf); if (unlikely(__pyx_t_1 == ((Py_ssize_t)-1))) __PYX_ERR(0, 63, __pyx_L1_error)
    if (unlikely(!(((__pyx_t_1 % 2) == 0) != 0))) {
      __pyx_t_2 = PyObject_Length(__pyx_v_buf); if (unlikely(__pyx_t_2 == ((Py_ssize_t)-1))) __PYX_ERR(0, 63, __pyx_L1_error)
      __pyx_t_3 = PyInt_FromSsize_t(__pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 63, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_4 = PyUnicode_Format(__pyx_kp_u_invalid_buffer_size_s_is_not_a_m, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 63, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      PyErr_SetObject(PyExc_AssertionError, __pyx_t_4);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __PYX_ERR(0, 63, __pyx_L1_error)
    }
  }
  #endif
 064:     # buf is a Python buffer object
+065:     cdef const uint16_t* cbuf = <const uint16_t*> 0
  __pyx_v_cbuf = ((uint16_t const *)0);
+066:     cdef Py_ssize_t cbuf_len = 0
  __pyx_v_cbuf_len = 0;
+067:     assert as_buffer(buf, <const void**> &cbuf, &cbuf_len)==0, "cannot convert %s to a readable buffer" % type(buf)
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  if (unlikely(!Py_OptimizeFlag)) {
    __pyx_t_5 = __pyx_f_4xpra_6codecs_4argb_4argb_as_buffer(__pyx_v_buf, ((void const **)(&__pyx_v_cbuf)), (&__pyx_v_cbuf_len)); if (unlikely(__pyx_t_5 == ((int)-1))) __PYX_ERR(0, 67, __pyx_L1_error)
    if (unlikely(!((__pyx_t_5 == 0) != 0))) {
      __pyx_t_4 = __Pyx_PyUnicode_FormatSafe(__pyx_kp_u_cannot_convert_s_to_a_readable_b, ((PyObject *)Py_TYPE(__pyx_v_buf))); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 67, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      PyErr_SetObject(PyExc_AssertionError, __pyx_t_4);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __PYX_ERR(0, 67, __pyx_L1_error)
    }
  }
  #endif
+068:     return bgr565data_to_rgb(cbuf, cbuf_len)
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_4 = __pyx_f_4xpra_6codecs_4argb_4argb_bgr565data_to_rgb(__pyx_v_cbuf, __pyx_v_cbuf_len); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 68, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_r = __pyx_t_4;
  __pyx_t_4 = 0;
  goto __pyx_L0;
 069: 
+070: cdef bgr565data_to_rgb(const uint16_t* rgb565, const int rgb565_len):
static PyObject *__pyx_f_4xpra_6codecs_4argb_4argb_bgr565data_to_rgb(uint16_t const *__pyx_v_rgb565, int const __pyx_v_rgb565_len) {
  struct __pyx_obj_4xpra_7buffers_6membuf_MemBuf *__pyx_v_output_buf = 0;
  uint8_t *__pyx_v_rgb;
  uint32_t __pyx_v_v;
  unsigned int __pyx_v_i;
  unsigned int __pyx_v_l;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("bgr565data_to_rgb", 0);
/* … */
  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("xpra.codecs.argb.argb.bgr565data_to_rgb", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_output_buf);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
+071:     if rgb565_len <= 0:
  __pyx_t_1 = ((__pyx_v_rgb565_len <= 0) != 0);
  if (__pyx_t_1) {
/* … */
  }
+072:         return None
    __Pyx_XDECREF(__pyx_r);
    __pyx_r = Py_None; __Pyx_INCREF(Py_None);
    goto __pyx_L0;
+073:     assert rgb565_len>0 and rgb565_len % 2 == 0, "invalid buffer size: %s is not a multiple of 2" % rgb565_len
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  if (unlikely(!Py_OptimizeFlag)) {
    __pyx_t_2 = ((__pyx_v_rgb565_len > 0) != 0);
    if (__pyx_t_2) {
    } else {
      __pyx_t_1 = __pyx_t_2;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_2 = (((__pyx_v_rgb565_len % 2) == 0) != 0);
    __pyx_t_1 = __pyx_t_2;
    __pyx_L4_bool_binop_done:;
    if (unlikely(!__pyx_t_1)) {
      __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_rgb565_len); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 73, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_4 = PyUnicode_Format(__pyx_kp_u_invalid_buffer_size_s_is_not_a_m, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 73, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      PyErr_SetObject(PyExc_AssertionError, __pyx_t_4);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __PYX_ERR(0, 73, __pyx_L1_error)
    }
  }
  #endif
+074:     cdef MemBuf output_buf = padbuf(rgb565_len*3//2, 3)
  __pyx_t_4 = __pyx_f_4xpra_7buffers_6membuf_padbuf(((__pyx_v_rgb565_len * 3) / 2), 3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 74, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  if (!(likely(((__pyx_t_4) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_4, __pyx_ptype_4xpra_7buffers_6membuf_MemBuf))))) __PYX_ERR(0, 74, __pyx_L1_error)
  __pyx_v_output_buf = ((struct __pyx_obj_4xpra_7buffers_6membuf_MemBuf *)__pyx_t_4);
  __pyx_t_4 = 0;
+075:     cdef uint8_t *rgb = <uint8_t*> output_buf.get_mem()
  __pyx_v_rgb = ((uint8_t *)((struct __pyx_vtabstruct_4xpra_7buffers_6membuf_MemBuf *)__pyx_v_output_buf->__pyx_vtab)->get_mem(__pyx_v_output_buf));
 076:     cdef uint32_t v
+077:     cdef unsigned int i = 0
  __pyx_v_i = 0;
+078:     cdef unsigned int l = rgb565_len//2
  __pyx_v_l = (__pyx_v_rgb565_len / 2);
+079:     for i in range(l):
  __pyx_t_5 = __pyx_v_l;
  __pyx_t_6 = __pyx_t_5;
  for (__pyx_t_7 = 0; __pyx_t_7 < __pyx_t_6; __pyx_t_7+=1) {
    __pyx_v_i = __pyx_t_7;
+080:         v = rgb565[i]
    __pyx_v_v = (__pyx_v_rgb565[__pyx_v_i]);
+081:         rgb[0] = (v & 0xF800) >> 8
    (__pyx_v_rgb[0]) = ((__pyx_v_v & 0xF800) >> 8);
+082:         rgb[1] = (v & 0x07E0) >> 3
    (__pyx_v_rgb[1]) = ((__pyx_v_v & 0x07E0) >> 3);
+083:         rgb[2] = (v & 0x001F) << 3
    (__pyx_v_rgb[2]) = ((__pyx_v_v & 0x001F) << 3);
+084:         rgb += 3
    __pyx_v_rgb = (__pyx_v_rgb + 3);
  }
+085:     return memoryview(output_buf)
  __Pyx_XDECREF(__pyx_r);
  __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_memoryview); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 85, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_4, ((PyObject *)__pyx_v_output_buf)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 85, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_r = __pyx_t_3;
  __pyx_t_3 = 0;
  goto __pyx_L0;
 086: 
 087: 
+088: def r210_to_rgba(buf):
/* Python wrapper */
static PyObject *__pyx_pw_4xpra_6codecs_4argb_4argb_5r210_to_rgba(PyObject *__pyx_self, PyObject *__pyx_v_buf); /*proto*/
static PyMethodDef __pyx_mdef_4xpra_6codecs_4argb_4argb_5r210_to_rgba = {"r210_to_rgba", (PyCFunction)__pyx_pw_4xpra_6codecs_4argb_4argb_5r210_to_rgba, METH_O, 0};
static PyObject *__pyx_pw_4xpra_6codecs_4argb_4argb_5r210_to_rgba(PyObject *__pyx_self, PyObject *__pyx_v_buf) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("r210_to_rgba (wrapper)", 0);
  __pyx_r = __pyx_pf_4xpra_6codecs_4argb_4argb_4r210_to_rgba(__pyx_self, ((PyObject *)__pyx_v_buf));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4xpra_6codecs_4argb_4argb_4r210_to_rgba(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_buf) {
  unsigned int const *__pyx_v_cbuf;
  Py_ssize_t __pyx_v_cbuf_len;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("r210_to_rgba", 0);
/* … */
  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("xpra.codecs.argb.argb.r210_to_rgba", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
/* … */
  __pyx_tuple__6 = PyTuple_Pack(3, __pyx_n_s_buf, __pyx_n_s_cbuf, __pyx_n_s_cbuf_len); if (unlikely(!__pyx_tuple__6)) __PYX_ERR(0, 88, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__6);
  __Pyx_GIVEREF(__pyx_tuple__6);
/* … */
  __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_4xpra_6codecs_4argb_4argb_5r210_to_rgba, NULL, __pyx_n_s_xpra_codecs_argb_argb); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 88, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_r210_to_rgba, __pyx_t_1) < 0) __PYX_ERR(0, 88, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_codeobj__7 = (PyObject*)__Pyx_PyCode_New(1, 0, 3, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__6, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_xpra_codecs_argb_argb_pyx, __pyx_n_s_r210_to_rgba, 88, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__7)) __PYX_ERR(0, 88, __pyx_L1_error)
+089:     assert len(buf) % 4 == 0, "invalid buffer size: %s is not a multiple of 4" % len(buf)
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  if (unlikely(!Py_OptimizeFlag)) {
    __pyx_t_1 = PyObject_Length(__pyx_v_buf); if (unlikely(__pyx_t_1 == ((Py_ssize_t)-1))) __PYX_ERR(0, 89, __pyx_L1_error)
    if (unlikely(!(((__pyx_t_1 % 4) == 0) != 0))) {
      __pyx_t_2 = PyObject_Length(__pyx_v_buf); if (unlikely(__pyx_t_2 == ((Py_ssize_t)-1))) __PYX_ERR(0, 89, __pyx_L1_error)
      __pyx_t_3 = PyInt_FromSsize_t(__pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 89, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_4 = PyUnicode_Format(__pyx_kp_u_invalid_buffer_size_s_is_not_a_m_2, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 89, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      PyErr_SetObject(PyExc_AssertionError, __pyx_t_4);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __PYX_ERR(0, 89, __pyx_L1_error)
    }
  }
  #endif
 090:     # buf is a Python buffer object
+091:     cdef const unsigned int* cbuf = <const unsigned int *> 0
  __pyx_v_cbuf = ((unsigned int const *)0);
+092:     cdef Py_ssize_t cbuf_len = 0
  __pyx_v_cbuf_len = 0;
+093:     assert as_buffer(buf, <const void**> &cbuf, &cbuf_len)==0, "cannot convert %s to a readable buffer" % type(buf)
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  if (unlikely(!Py_OptimizeFlag)) {
    __pyx_t_5 = __pyx_f_4xpra_6codecs_4argb_4argb_as_buffer(__pyx_v_buf, ((void const **)(&__pyx_v_cbuf)), (&__pyx_v_cbuf_len)); if (unlikely(__pyx_t_5 == ((int)-1))) __PYX_ERR(0, 93, __pyx_L1_error)
    if (unlikely(!((__pyx_t_5 == 0) != 0))) {
      __pyx_t_4 = __Pyx_PyUnicode_FormatSafe(__pyx_kp_u_cannot_convert_s_to_a_readable_b, ((PyObject *)Py_TYPE(__pyx_v_buf))); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 93, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      PyErr_SetObject(PyExc_AssertionError, __pyx_t_4);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __PYX_ERR(0, 93, __pyx_L1_error)
    }
  }
  #endif
+094:     return r210data_to_rgba(cbuf, cbuf_len)
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_4 = __pyx_f_4xpra_6codecs_4argb_4argb_r210data_to_rgba(__pyx_v_cbuf, __pyx_v_cbuf_len); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 94, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_r = __pyx_t_4;
  __pyx_t_4 = 0;
  goto __pyx_L0;
 095: 
+096: cdef r210data_to_rgba(const unsigned int* r210, const int r210_len):
static PyObject *__pyx_f_4xpra_6codecs_4argb_4argb_r210data_to_rgba(unsigned int const *__pyx_v_r210, int const __pyx_v_r210_len) {
  struct __pyx_obj_4xpra_7buffers_6membuf_MemBuf *__pyx_v_output_buf = 0;
  unsigned char *__pyx_v_rgba;
  int __pyx_v_i;
  unsigned int __pyx_v_v;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("r210data_to_rgba", 0);
/* … */
  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("xpra.codecs.argb.argb.r210data_to_rgba", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_output_buf);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
+097:     if r210_len <= 0:
  __pyx_t_1 = ((__pyx_v_r210_len <= 0) != 0);
  if (__pyx_t_1) {
/* … */
  }
+098:         return None
    __Pyx_XDECREF(__pyx_r);
    __pyx_r = Py_None; __Pyx_INCREF(Py_None);
    goto __pyx_L0;
+099:     assert r210_len>0 and r210_len % 4 == 0, "invalid buffer size: %s is not a multiple of 4" % r210_len
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  if (unlikely(!Py_OptimizeFlag)) {
    __pyx_t_2 = ((__pyx_v_r210_len > 0) != 0);
    if (__pyx_t_2) {
    } else {
      __pyx_t_1 = __pyx_t_2;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_2 = (((__pyx_v_r210_len % 4) == 0) != 0);
    __pyx_t_1 = __pyx_t_2;
    __pyx_L4_bool_binop_done:;
    if (unlikely(!__pyx_t_1)) {
      __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_r210_len); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 99, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_4 = PyUnicode_Format(__pyx_kp_u_invalid_buffer_size_s_is_not_a_m_2, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 99, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      PyErr_SetObject(PyExc_AssertionError, __pyx_t_4);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __PYX_ERR(0, 99, __pyx_L1_error)
    }
  }
  #endif
+100:     cdef MemBuf output_buf = getbuf(r210_len)
  __pyx_t_4 = __pyx_f_4xpra_7buffers_6membuf_getbuf(__pyx_v_r210_len); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 100, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  if (!(likely(((__pyx_t_4) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_4, __pyx_ptype_4xpra_7buffers_6membuf_MemBuf))))) __PYX_ERR(0, 100, __pyx_L1_error)
  __pyx_v_output_buf = ((struct __pyx_obj_4xpra_7buffers_6membuf_MemBuf *)__pyx_t_4);
  __pyx_t_4 = 0;
+101:     cdef unsigned char* rgba = <unsigned char*> output_buf.get_mem()
  __pyx_v_rgba = ((unsigned char *)((struct __pyx_vtabstruct_4xpra_7buffers_6membuf_MemBuf *)__pyx_v_output_buf->__pyx_vtab)->get_mem(__pyx_v_output_buf));
 102:     #number of pixels:
+103:     cdef int i = 0
  __pyx_v_i = 0;
 104:     cdef unsigned int v
+105:     while i < r210_len:
  while (1) {
    __pyx_t_1 = ((__pyx_v_i < __pyx_v_r210_len) != 0);
    if (!__pyx_t_1) break;
+106:         v = r210[i//4]
    __pyx_v_v = (__pyx_v_r210[(__pyx_v_i / 4)]);
+107:         rgba[i+2] = (v&0x000003ff) >> 2
    (__pyx_v_rgba[(__pyx_v_i + 2)]) = ((__pyx_v_v & 0x000003ff) >> 2);
+108:         rgba[i+1] = (v&0x000ffc00) >> 12
    (__pyx_v_rgba[(__pyx_v_i + 1)]) = ((__pyx_v_v & 0x000ffc00) >> 12);
+109:         rgba[i]   = (v&0x3ff00000) >> 22
    (__pyx_v_rgba[__pyx_v_i]) = ((__pyx_v_v & 0x3ff00000) >> 22);
+110:         rgba[i+3] = ((v&(<unsigned int>0xc0000000)) >> 30)*85
    (__pyx_v_rgba[(__pyx_v_i + 3)]) = (((__pyx_v_v & ((unsigned int)0xc0000000)) >> 30) * 85);
+111:         i = i + 4
    __pyx_v_i = (__pyx_v_i + 4);
  }
+112:     return memoryview(output_buf)
  __Pyx_XDECREF(__pyx_r);
  __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_memoryview); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 112, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_4, ((PyObject *)__pyx_v_output_buf)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 112, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_r = __pyx_t_3;
  __pyx_t_3 = 0;
  goto __pyx_L0;
 113: 
 114: 
+115: def r210_to_rgbx(buf):
/* Python wrapper */
static PyObject *__pyx_pw_4xpra_6codecs_4argb_4argb_7r210_to_rgbx(PyObject *__pyx_self, PyObject *__pyx_v_buf); /*proto*/
static PyMethodDef __pyx_mdef_4xpra_6codecs_4argb_4argb_7r210_to_rgbx = {"r210_to_rgbx", (PyCFunction)__pyx_pw_4xpra_6codecs_4argb_4argb_7r210_to_rgbx, METH_O, 0};
static PyObject *__pyx_pw_4xpra_6codecs_4argb_4argb_7r210_to_rgbx(PyObject *__pyx_self, PyObject *__pyx_v_buf) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("r210_to_rgbx (wrapper)", 0);
  __pyx_r = __pyx_pf_4xpra_6codecs_4argb_4argb_6r210_to_rgbx(__pyx_self, ((PyObject *)__pyx_v_buf));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4xpra_6codecs_4argb_4argb_6r210_to_rgbx(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_buf) {
  unsigned int const *__pyx_v_cbuf;
  Py_ssize_t __pyx_v_cbuf_len;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("r210_to_rgbx", 0);
/* … */
  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("xpra.codecs.argb.argb.r210_to_rgbx", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
/* … */
  __pyx_tuple__8 = PyTuple_Pack(3, __pyx_n_s_buf, __pyx_n_s_cbuf, __pyx_n_s_cbuf_len); if (unlikely(!__pyx_tuple__8)) __PYX_ERR(0, 115, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__8);
  __Pyx_GIVEREF(__pyx_tuple__8);
/* … */
  __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_4xpra_6codecs_4argb_4argb_7r210_to_rgbx, NULL, __pyx_n_s_xpra_codecs_argb_argb); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 115, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_r210_to_rgbx, __pyx_t_1) < 0) __PYX_ERR(0, 115, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_codeobj__9 = (PyObject*)__Pyx_PyCode_New(1, 0, 3, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__8, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_xpra_codecs_argb_argb_pyx, __pyx_n_s_r210_to_rgbx, 115, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__9)) __PYX_ERR(0, 115, __pyx_L1_error)
+116:     assert len(buf) % 4 == 0, "invalid buffer size: %s is not a multiple of 4" % len(buf)
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  if (unlikely(!Py_OptimizeFlag)) {
    __pyx_t_1 = PyObject_Length(__pyx_v_buf); if (unlikely(__pyx_t_1 == ((Py_ssize_t)-1))) __PYX_ERR(0, 116, __pyx_L1_error)
    if (unlikely(!(((__pyx_t_1 % 4) == 0) != 0))) {
      __pyx_t_2 = PyObject_Length(__pyx_v_buf); if (unlikely(__pyx_t_2 == ((Py_ssize_t)-1))) __PYX_ERR(0, 116, __pyx_L1_error)
      __pyx_t_3 = PyInt_FromSsize_t(__pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 116, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_4 = PyUnicode_Format(__pyx_kp_u_invalid_buffer_size_s_is_not_a_m_2, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 116, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      PyErr_SetObject(PyExc_AssertionError, __pyx_t_4);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __PYX_ERR(0, 116, __pyx_L1_error)
    }
  }
  #endif
 117:     # buf is a Python buffer object
+118:     cdef const unsigned int* cbuf = <const unsigned int *> 0
  __pyx_v_cbuf = ((unsigned int const *)0);
+119:     cdef Py_ssize_t cbuf_len = 0
  __pyx_v_cbuf_len = 0;
+120:     assert as_buffer(buf, <const void**> &cbuf, &cbuf_len)==0, "cannot convert %s to a readable buffer" % type(buf)
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  if (unlikely(!Py_OptimizeFlag)) {
    __pyx_t_5 = __pyx_f_4xpra_6codecs_4argb_4argb_as_buffer(__pyx_v_buf, ((void const **)(&__pyx_v_cbuf)), (&__pyx_v_cbuf_len)); if (unlikely(__pyx_t_5 == ((int)-1))) __PYX_ERR(0, 120, __pyx_L1_error)
    if (unlikely(!((__pyx_t_5 == 0) != 0))) {
      __pyx_t_4 = __Pyx_PyUnicode_FormatSafe(__pyx_kp_u_cannot_convert_s_to_a_readable_b, ((PyObject *)Py_TYPE(__pyx_v_buf))); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 120, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      PyErr_SetObject(PyExc_AssertionError, __pyx_t_4);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __PYX_ERR(0, 120, __pyx_L1_error)
    }
  }
  #endif
+121:     return r210data_to_rgbx(cbuf, cbuf_len)
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_4 = __pyx_f_4xpra_6codecs_4argb_4argb_r210data_to_rgbx(__pyx_v_cbuf, __pyx_v_cbuf_len); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 121, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_r = __pyx_t_4;
  __pyx_t_4 = 0;
  goto __pyx_L0;
 122: 
+123: cdef r210data_to_rgbx(const unsigned int* r210, const int r210_len):
static PyObject *__pyx_f_4xpra_6codecs_4argb_4argb_r210data_to_rgbx(unsigned int const *__pyx_v_r210, int const __pyx_v_r210_len) {
  struct __pyx_obj_4xpra_7buffers_6membuf_MemBuf *__pyx_v_output_buf = 0;
  unsigned char *__pyx_v_rgbx;
  int __pyx_v_i;
  unsigned int __pyx_v_v;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("r210data_to_rgbx", 0);
/* … */
  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("xpra.codecs.argb.argb.r210data_to_rgbx", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_output_buf);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
+124:     if r210_len <= 0:
  __pyx_t_1 = ((__pyx_v_r210_len <= 0) != 0);
  if (__pyx_t_1) {
/* … */
  }
+125:         return None
    __Pyx_XDECREF(__pyx_r);
    __pyx_r = Py_None; __Pyx_INCREF(Py_None);
    goto __pyx_L0;
+126:     assert r210_len>0 and r210_len % 4 == 0, "invalid buffer size: %s is not a multiple of 4" % r210_len
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  if (unlikely(!Py_OptimizeFlag)) {
    __pyx_t_2 = ((__pyx_v_r210_len > 0) != 0);
    if (__pyx_t_2) {
    } else {
      __pyx_t_1 = __pyx_t_2;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_2 = (((__pyx_v_r210_len % 4) == 0) != 0);
    __pyx_t_1 = __pyx_t_2;
    __pyx_L4_bool_binop_done:;
    if (unlikely(!__pyx_t_1)) {
      __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_r210_len); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 126, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_4 = PyUnicode_Format(__pyx_kp_u_invalid_buffer_size_s_is_not_a_m_2, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 126, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      PyErr_SetObject(PyExc_AssertionError, __pyx_t_4);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __PYX_ERR(0, 126, __pyx_L1_error)
    }
  }
  #endif
+127:     cdef MemBuf output_buf = getbuf(r210_len)
  __pyx_t_4 = __pyx_f_4xpra_7buffers_6membuf_getbuf(__pyx_v_r210_len); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 127, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  if (!(likely(((__pyx_t_4) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_4, __pyx_ptype_4xpra_7buffers_6membuf_MemBuf))))) __PYX_ERR(0, 127, __pyx_L1_error)
  __pyx_v_output_buf = ((struct __pyx_obj_4xpra_7buffers_6membuf_MemBuf *)__pyx_t_4);
  __pyx_t_4 = 0;
+128:     cdef unsigned char* rgbx = <unsigned char*> output_buf.get_mem()
  __pyx_v_rgbx = ((unsigned char *)((struct __pyx_vtabstruct_4xpra_7buffers_6membuf_MemBuf *)__pyx_v_output_buf->__pyx_vtab)->get_mem(__pyx_v_output_buf));
 129:     #number of pixels:
+130:     cdef int i = 0
  __pyx_v_i = 0;
 131:     cdef unsigned int v
+132:     while i < r210_len:
  while (1) {
    __pyx_t_1 = ((__pyx_v_i < __pyx_v_r210_len) != 0);
    if (!__pyx_t_1) break;
+133:         v = r210[i//4]
    __pyx_v_v = (__pyx_v_r210[(__pyx_v_i / 4)]);
+134:         rgbx[i+2] = (v&0x000003ff) >> 2
    (__pyx_v_rgbx[(__pyx_v_i + 2)]) = ((__pyx_v_v & 0x000003ff) >> 2);
+135:         rgbx[i+1] = (v&0x000ffc00) >> 12
    (__pyx_v_rgbx[(__pyx_v_i + 1)]) = ((__pyx_v_v & 0x000ffc00) >> 12);
+136:         rgbx[i]   = (v&0x3ff00000) >> 22
    (__pyx_v_rgbx[__pyx_v_i]) = ((__pyx_v_v & 0x3ff00000) >> 22);
+137:         rgbx[i+3] = 0xFF
    (__pyx_v_rgbx[(__pyx_v_i + 3)]) = 0xFF;
+138:         i = i + 4
    __pyx_v_i = (__pyx_v_i + 4);
  }
+139:     return memoryview(output_buf)
  __Pyx_XDECREF(__pyx_r);
  __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_memoryview); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 139, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_4, ((PyObject *)__pyx_v_output_buf)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 139, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_r = __pyx_t_3;
  __pyx_t_3 = 0;
  goto __pyx_L0;
 140: 
 141: 
+142: def r210_to_rgb(buf):
/* Python wrapper */
static PyObject *__pyx_pw_4xpra_6codecs_4argb_4argb_9r210_to_rgb(PyObject *__pyx_self, PyObject *__pyx_v_buf); /*proto*/
static PyMethodDef __pyx_mdef_4xpra_6codecs_4argb_4argb_9r210_to_rgb = {"r210_to_rgb", (PyCFunction)__pyx_pw_4xpra_6codecs_4argb_4argb_9r210_to_rgb, METH_O, 0};
static PyObject *__pyx_pw_4xpra_6codecs_4argb_4argb_9r210_to_rgb(PyObject *__pyx_self, PyObject *__pyx_v_buf) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("r210_to_rgb (wrapper)", 0);
  __pyx_r = __pyx_pf_4xpra_6codecs_4argb_4argb_8r210_to_rgb(__pyx_self, ((PyObject *)__pyx_v_buf));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4xpra_6codecs_4argb_4argb_8r210_to_rgb(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_buf) {
  unsigned int const *__pyx_v_cbuf;
  Py_ssize_t __pyx_v_cbuf_len;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("r210_to_rgb", 0);
/* … */
  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("xpra.codecs.argb.argb.r210_to_rgb", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
/* … */
  __pyx_tuple__10 = PyTuple_Pack(3, __pyx_n_s_buf, __pyx_n_s_cbuf, __pyx_n_s_cbuf_len); if (unlikely(!__pyx_tuple__10)) __PYX_ERR(0, 142, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__10);
  __Pyx_GIVEREF(__pyx_tuple__10);
/* … */
  __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_4xpra_6codecs_4argb_4argb_9r210_to_rgb, NULL, __pyx_n_s_xpra_codecs_argb_argb); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 142, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_r210_to_rgb, __pyx_t_1) < 0) __PYX_ERR(0, 142, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_codeobj__11 = (PyObject*)__Pyx_PyCode_New(1, 0, 3, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__10, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_xpra_codecs_argb_argb_pyx, __pyx_n_s_r210_to_rgb, 142, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__11)) __PYX_ERR(0, 142, __pyx_L1_error)
+143:     assert len(buf) % 4 == 0, "invalid buffer size: %s is not a multiple of 4" % len(buf)
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  if (unlikely(!Py_OptimizeFlag)) {
    __pyx_t_1 = PyObject_Length(__pyx_v_buf); if (unlikely(__pyx_t_1 == ((Py_ssize_t)-1))) __PYX_ERR(0, 143, __pyx_L1_error)
    if (unlikely(!(((__pyx_t_1 % 4) == 0) != 0))) {
      __pyx_t_2 = PyObject_Length(__pyx_v_buf); if (unlikely(__pyx_t_2 == ((Py_ssize_t)-1))) __PYX_ERR(0, 143, __pyx_L1_error)
      __pyx_t_3 = PyInt_FromSsize_t(__pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 143, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_4 = PyUnicode_Format(__pyx_kp_u_invalid_buffer_size_s_is_not_a_m_2, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 143, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      PyErr_SetObject(PyExc_AssertionError, __pyx_t_4);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __PYX_ERR(0, 143, __pyx_L1_error)
    }
  }
  #endif
 144:     # buf is a Python buffer object
+145:     cdef const unsigned int* cbuf = <const unsigned int *> 0
  __pyx_v_cbuf = ((unsigned int const *)0);
+146:     cdef Py_ssize_t cbuf_len = 0
  __pyx_v_cbuf_len = 0;
+147:     assert as_buffer(buf, <const void**> &cbuf, &cbuf_len)==0, "cannot convert %s to a readable buffer" % type(buf)
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  if (unlikely(!Py_OptimizeFlag)) {
    __pyx_t_5 = __pyx_f_4xpra_6codecs_4argb_4argb_as_buffer(__pyx_v_buf, ((void const **)(&__pyx_v_cbuf)), (&__pyx_v_cbuf_len)); if (unlikely(__pyx_t_5 == ((int)-1))) __PYX_ERR(0, 147, __pyx_L1_error)
    if (unlikely(!((__pyx_t_5 == 0) != 0))) {
      __pyx_t_4 = __Pyx_PyUnicode_FormatSafe(__pyx_kp_u_cannot_convert_s_to_a_readable_b, ((PyObject *)Py_TYPE(__pyx_v_buf))); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 147, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      PyErr_SetObject(PyExc_AssertionError, __pyx_t_4);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __PYX_ERR(0, 147, __pyx_L1_error)
    }
  }
  #endif
+148:     return r210data_to_rgb(cbuf, cbuf_len)
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_4 = __pyx_f_4xpra_6codecs_4argb_4argb_r210data_to_rgb(__pyx_v_cbuf, __pyx_v_cbuf_len); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 148, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_r = __pyx_t_4;
  __pyx_t_4 = 0;
  goto __pyx_L0;
 149: 
 150: #white:  3fffffff
 151: #red:    3ff00000
 152: #green:     ffc00
 153: #blue:        3ff
 154: #black:         0
+155: cdef r210data_to_rgb(const unsigned int* r210, const int r210_len):
static PyObject *__pyx_f_4xpra_6codecs_4argb_4argb_r210data_to_rgb(unsigned int const *__pyx_v_r210, int const __pyx_v_r210_len) {
  struct __pyx_obj_4xpra_7buffers_6membuf_MemBuf *__pyx_v_output_buf = 0;
  unsigned char *__pyx_v_rgb;
  int __pyx_v_s;
  int __pyx_v_d;
  unsigned int __pyx_v_v;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("r210data_to_rgb", 0);
/* … */
  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("xpra.codecs.argb.argb.r210data_to_rgb", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_output_buf);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
+156:     if r210_len <= 0:
  __pyx_t_1 = ((__pyx_v_r210_len <= 0) != 0);
  if (__pyx_t_1) {
/* … */
  }
+157:         return None
    __Pyx_XDECREF(__pyx_r);
    __pyx_r = Py_None; __Pyx_INCREF(Py_None);
    goto __pyx_L0;
+158:     assert r210_len>0 and r210_len % 4 == 0, "invalid buffer size: %s is not a multiple of 4" % r210_len
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  if (unlikely(!Py_OptimizeFlag)) {
    __pyx_t_2 = ((__pyx_v_r210_len > 0) != 0);
    if (__pyx_t_2) {
    } else {
      __pyx_t_1 = __pyx_t_2;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_2 = (((__pyx_v_r210_len % 4) == 0) != 0);
    __pyx_t_1 = __pyx_t_2;
    __pyx_L4_bool_binop_done:;
    if (unlikely(!__pyx_t_1)) {
      __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_r210_len); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 158, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_4 = PyUnicode_Format(__pyx_kp_u_invalid_buffer_size_s_is_not_a_m_2, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 158, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      PyErr_SetObject(PyExc_AssertionError, __pyx_t_4);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __PYX_ERR(0, 158, __pyx_L1_error)
    }
  }
  #endif
+159:     cdef MemBuf output_buf = padbuf(r210_len//4*3, 3)
  __pyx_t_4 = __pyx_f_4xpra_7buffers_6membuf_padbuf(((__pyx_v_r210_len / 4) * 3), 3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 159, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  if (!(likely(((__pyx_t_4) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_4, __pyx_ptype_4xpra_7buffers_6membuf_MemBuf))))) __PYX_ERR(0, 159, __pyx_L1_error)
  __pyx_v_output_buf = ((struct __pyx_obj_4xpra_7buffers_6membuf_MemBuf *)__pyx_t_4);
  __pyx_t_4 = 0;
+160:     cdef unsigned char* rgb = <unsigned char*> output_buf.get_mem()
  __pyx_v_rgb = ((unsigned char *)((struct __pyx_vtabstruct_4xpra_7buffers_6membuf_MemBuf *)__pyx_v_output_buf->__pyx_vtab)->get_mem(__pyx_v_output_buf));
 161:     #number of pixels:
+162:     cdef int s = 0
  __pyx_v_s = 0;
+163:     cdef int d = 0
  __pyx_v_d = 0;
 164:     cdef unsigned int v
+165:     while s < r210_len//4:
  while (1) {
    __pyx_t_1 = ((__pyx_v_s < (__pyx_v_r210_len / 4)) != 0);
    if (!__pyx_t_1) break;
+166:         v = r210[s]
    __pyx_v_v = (__pyx_v_r210[__pyx_v_s]);
+167:         rgb[d+2] = (v&0x000003ff) >> 2
    (__pyx_v_rgb[(__pyx_v_d + 2)]) = ((__pyx_v_v & 0x000003ff) >> 2);
+168:         rgb[d+1] = (v&0x000ffc00) >> 12
    (__pyx_v_rgb[(__pyx_v_d + 1)]) = ((__pyx_v_v & 0x000ffc00) >> 12);
+169:         rgb[d]   = (v&0x3ff00000) >> 22
    (__pyx_v_rgb[__pyx_v_d]) = ((__pyx_v_v & 0x3ff00000) >> 22);
+170:         s += 1
    __pyx_v_s = (__pyx_v_s + 1);
+171:         d += 3
    __pyx_v_d = (__pyx_v_d + 3);
  }
+172:     return memoryview(output_buf)
  __Pyx_XDECREF(__pyx_r);
  __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_memoryview); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 172, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_4, ((PyObject *)__pyx_v_output_buf)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 172, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_r = __pyx_t_3;
  __pyx_t_3 = 0;
  goto __pyx_L0;
 173: 
 174: 
+175: def argb_to_rgba(buf):
/* Python wrapper */
static PyObject *__pyx_pw_4xpra_6codecs_4argb_4argb_11argb_to_rgba(PyObject *__pyx_self, PyObject *__pyx_v_buf); /*proto*/
static PyMethodDef __pyx_mdef_4xpra_6codecs_4argb_4argb_11argb_to_rgba = {"argb_to_rgba", (PyCFunction)__pyx_pw_4xpra_6codecs_4argb_4argb_11argb_to_rgba, METH_O, 0};
static PyObject *__pyx_pw_4xpra_6codecs_4argb_4argb_11argb_to_rgba(PyObject *__pyx_self, PyObject *__pyx_v_buf) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("argb_to_rgba (wrapper)", 0);
  __pyx_r = __pyx_pf_4xpra_6codecs_4argb_4argb_10argb_to_rgba(__pyx_self, ((PyObject *)__pyx_v_buf));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4xpra_6codecs_4argb_4argb_10argb_to_rgba(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_buf) {
  unsigned char const *__pyx_v_cbuf;
  Py_ssize_t __pyx_v_cbuf_len;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("argb_to_rgba", 0);
/* … */
  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("xpra.codecs.argb.argb.argb_to_rgba", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
/* … */
  __pyx_tuple__12 = PyTuple_Pack(3, __pyx_n_s_buf, __pyx_n_s_cbuf, __pyx_n_s_cbuf_len); if (unlikely(!__pyx_tuple__12)) __PYX_ERR(0, 175, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__12);
  __Pyx_GIVEREF(__pyx_tuple__12);
/* … */
  __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_4xpra_6codecs_4argb_4argb_11argb_to_rgba, NULL, __pyx_n_s_xpra_codecs_argb_argb); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 175, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_argb_to_rgba, __pyx_t_1) < 0) __PYX_ERR(0, 175, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_codeobj__13 = (PyObject*)__Pyx_PyCode_New(1, 0, 3, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__12, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_xpra_codecs_argb_argb_pyx, __pyx_n_s_argb_to_rgba, 175, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__13)) __PYX_ERR(0, 175, __pyx_L1_error)
+176:     assert len(buf) % 4 == 0, "invalid buffer size: %s is not a multiple of 4" % len(buf)
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  if (unlikely(!Py_OptimizeFlag)) {
    __pyx_t_1 = PyObject_Length(__pyx_v_buf); if (unlikely(__pyx_t_1 == ((Py_ssize_t)-1))) __PYX_ERR(0, 176, __pyx_L1_error)
    if (unlikely(!(((__pyx_t_1 % 4) == 0) != 0))) {
      __pyx_t_2 = PyObject_Length(__pyx_v_buf); if (unlikely(__pyx_t_2 == ((Py_ssize_t)-1))) __PYX_ERR(0, 176, __pyx_L1_error)
      __pyx_t_3 = PyInt_FromSsize_t(__pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 176, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_4 = PyUnicode_Format(__pyx_kp_u_invalid_buffer_size_s_is_not_a_m_2, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 176, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      PyErr_SetObject(PyExc_AssertionError, __pyx_t_4);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __PYX_ERR(0, 176, __pyx_L1_error)
    }
  }
  #endif
 177:     # buf is a Python buffer object
+178:     cdef const unsigned char * cbuf = <unsigned char *> 0
  __pyx_v_cbuf = ((unsigned char *)0);
+179:     cdef Py_ssize_t cbuf_len = 0
  __pyx_v_cbuf_len = 0;
+180:     assert as_buffer(buf, <const void**> &cbuf, &cbuf_len)==0, "cannot convert %s to a readable buffer" % type(buf)
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  if (unlikely(!Py_OptimizeFlag)) {
    __pyx_t_5 = __pyx_f_4xpra_6codecs_4argb_4argb_as_buffer(__pyx_v_buf, ((void const **)(&__pyx_v_cbuf)), (&__pyx_v_cbuf_len)); if (unlikely(__pyx_t_5 == ((int)-1))) __PYX_ERR(0, 180, __pyx_L1_error)
    if (unlikely(!((__pyx_t_5 == 0) != 0))) {
      __pyx_t_4 = __Pyx_PyUnicode_FormatSafe(__pyx_kp_u_cannot_convert_s_to_a_readable_b, ((PyObject *)Py_TYPE(__pyx_v_buf))); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 180, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      PyErr_SetObject(PyExc_AssertionError, __pyx_t_4);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __PYX_ERR(0, 180, __pyx_L1_error)
    }
  }
  #endif
+181:     return argbdata_to_rgba(cbuf, cbuf_len)
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_4 = __pyx_f_4xpra_6codecs_4argb_4argb_argbdata_to_rgba(__pyx_v_cbuf, __pyx_v_cbuf_len); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 181, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_r = __pyx_t_4;
  __pyx_t_4 = 0;
  goto __pyx_L0;
 182: 
+183: cdef argbdata_to_rgba(const unsigned char* argb, const int argb_len):
static PyObject *__pyx_f_4xpra_6codecs_4argb_4argb_argbdata_to_rgba(unsigned char const *__pyx_v_argb, int const __pyx_v_argb_len) {
  struct __pyx_obj_4xpra_7buffers_6membuf_MemBuf *__pyx_v_output_buf = 0;
  unsigned char *__pyx_v_rgba;
  int __pyx_v_i;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("argbdata_to_rgba", 0);
/* … */
  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("xpra.codecs.argb.argb.argbdata_to_rgba", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_output_buf);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
+184:     if argb_len <= 0:
  __pyx_t_1 = ((__pyx_v_argb_len <= 0) != 0);
  if (__pyx_t_1) {
/* … */
  }
+185:         return None
    __Pyx_XDECREF(__pyx_r);
    __pyx_r = Py_None; __Pyx_INCREF(Py_None);
    goto __pyx_L0;
+186:     assert argb_len>0 and argb_len % 4 == 0, "invalid buffer size: %s is not a multiple of 4" % argb_len
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  if (unlikely(!Py_OptimizeFlag)) {
    __pyx_t_2 = ((__pyx_v_argb_len > 0) != 0);
    if (__pyx_t_2) {
    } else {
      __pyx_t_1 = __pyx_t_2;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_2 = (((__pyx_v_argb_len % 4) == 0) != 0);
    __pyx_t_1 = __pyx_t_2;
    __pyx_L4_bool_binop_done:;
    if (unlikely(!__pyx_t_1)) {
      __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_argb_len); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 186, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_4 = PyUnicode_Format(__pyx_kp_u_invalid_buffer_size_s_is_not_a_m_2, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 186, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      PyErr_SetObject(PyExc_AssertionError, __pyx_t_4);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __PYX_ERR(0, 186, __pyx_L1_error)
    }
  }
  #endif
+187:     cdef MemBuf output_buf = getbuf(argb_len)
  __pyx_t_4 = __pyx_f_4xpra_7buffers_6membuf_getbuf(__pyx_v_argb_len); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 187, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  if (!(likely(((__pyx_t_4) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_4, __pyx_ptype_4xpra_7buffers_6membuf_MemBuf))))) __PYX_ERR(0, 187, __pyx_L1_error)
  __pyx_v_output_buf = ((struct __pyx_obj_4xpra_7buffers_6membuf_MemBuf *)__pyx_t_4);
  __pyx_t_4 = 0;
+188:     cdef unsigned char* rgba = <unsigned char*> output_buf.get_mem()
  __pyx_v_rgba = ((unsigned char *)((struct __pyx_vtabstruct_4xpra_7buffers_6membuf_MemBuf *)__pyx_v_output_buf->__pyx_vtab)->get_mem(__pyx_v_output_buf));
 189:     #number of pixels:
+190:     cdef int i = 0
  __pyx_v_i = 0;
+191:     while i < argb_len:
  while (1) {
    __pyx_t_1 = ((__pyx_v_i < __pyx_v_argb_len) != 0);
    if (!__pyx_t_1) break;
+192:         rgba[i]    = argb[i+1]              #R
    (__pyx_v_rgba[__pyx_v_i]) = (__pyx_v_argb[(__pyx_v_i + 1)]);
+193:         rgba[i+1]  = argb[i+2]              #G
    (__pyx_v_rgba[(__pyx_v_i + 1)]) = (__pyx_v_argb[(__pyx_v_i + 2)]);
+194:         rgba[i+2]  = argb[i+3]              #B
    (__pyx_v_rgba[(__pyx_v_i + 2)]) = (__pyx_v_argb[(__pyx_v_i + 3)]);
+195:         rgba[i+3]  = argb[i]                #A
    (__pyx_v_rgba[(__pyx_v_i + 3)]) = (__pyx_v_argb[__pyx_v_i]);
+196:         i = i + 4
    __pyx_v_i = (__pyx_v_i + 4);
  }
+197:     return memoryview(output_buf)
  __Pyx_XDECREF(__pyx_r);
  __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_memoryview); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 197, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_4, ((PyObject *)__pyx_v_output_buf)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 197, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_r = __pyx_t_3;
  __pyx_t_3 = 0;
  goto __pyx_L0;
 198: 
+199: def argb_to_rgb(buf):
/* Python wrapper */
static PyObject *__pyx_pw_4xpra_6codecs_4argb_4argb_13argb_to_rgb(PyObject *__pyx_self, PyObject *__pyx_v_buf); /*proto*/
static PyMethodDef __pyx_mdef_4xpra_6codecs_4argb_4argb_13argb_to_rgb = {"argb_to_rgb", (PyCFunction)__pyx_pw_4xpra_6codecs_4argb_4argb_13argb_to_rgb, METH_O, 0};
static PyObject *__pyx_pw_4xpra_6codecs_4argb_4argb_13argb_to_rgb(PyObject *__pyx_self, PyObject *__pyx_v_buf) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("argb_to_rgb (wrapper)", 0);
  __pyx_r = __pyx_pf_4xpra_6codecs_4argb_4argb_12argb_to_rgb(__pyx_self, ((PyObject *)__pyx_v_buf));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4xpra_6codecs_4argb_4argb_12argb_to_rgb(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_buf) {
  unsigned char *__pyx_v_cbuf;
  Py_ssize_t __pyx_v_cbuf_len;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("argb_to_rgb", 0);
/* … */
  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("xpra.codecs.argb.argb.argb_to_rgb", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
/* … */
  __pyx_tuple__14 = PyTuple_Pack(3, __pyx_n_s_buf, __pyx_n_s_cbuf, __pyx_n_s_cbuf_len); if (unlikely(!__pyx_tuple__14)) __PYX_ERR(0, 199, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__14);
  __Pyx_GIVEREF(__pyx_tuple__14);
/* … */
  __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_4xpra_6codecs_4argb_4argb_13argb_to_rgb, NULL, __pyx_n_s_xpra_codecs_argb_argb); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 199, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_argb_to_rgb, __pyx_t_1) < 0) __PYX_ERR(0, 199, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_codeobj__15 = (PyObject*)__Pyx_PyCode_New(1, 0, 3, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__14, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_xpra_codecs_argb_argb_pyx, __pyx_n_s_argb_to_rgb, 199, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__15)) __PYX_ERR(0, 199, __pyx_L1_error)
+200:     assert len(buf) % 4 == 0, "invalid buffer size: %s is not a multiple of 4" % len(buf)
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  if (unlikely(!Py_OptimizeFlag)) {
    __pyx_t_1 = PyObject_Length(__pyx_v_buf); if (unlikely(__pyx_t_1 == ((Py_ssize_t)-1))) __PYX_ERR(0, 200, __pyx_L1_error)
    if (unlikely(!(((__pyx_t_1 % 4) == 0) != 0))) {
      __pyx_t_2 = PyObject_Length(__pyx_v_buf); if (unlikely(__pyx_t_2 == ((Py_ssize_t)-1))) __PYX_ERR(0, 200, __pyx_L1_error)
      __pyx_t_3 = PyInt_FromSsize_t(__pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 200, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_4 = PyUnicode_Format(__pyx_kp_u_invalid_buffer_size_s_is_not_a_m_2, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 200, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      PyErr_SetObject(PyExc_AssertionError, __pyx_t_4);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __PYX_ERR(0, 200, __pyx_L1_error)
    }
  }
  #endif
 201:     # buf is a Python buffer object
+202:     cdef unsigned char * cbuf = <unsigned char *> 0     #@DuplicateSignature
  __pyx_v_cbuf = ((unsigned char *)0);
+203:     cdef Py_ssize_t cbuf_len = 0                        #@DuplicateSignature
  __pyx_v_cbuf_len = 0;
+204:     assert as_buffer(buf, <const void**> &cbuf, &cbuf_len)==0, "cannot convert %s to a readable buffer" % type(buf)
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  if (unlikely(!Py_OptimizeFlag)) {
    __pyx_t_5 = __pyx_f_4xpra_6codecs_4argb_4argb_as_buffer(__pyx_v_buf, ((void const **)(&__pyx_v_cbuf)), (&__pyx_v_cbuf_len)); if (unlikely(__pyx_t_5 == ((int)-1))) __PYX_ERR(0, 204, __pyx_L1_error)
    if (unlikely(!((__pyx_t_5 == 0) != 0))) {
      __pyx_t_4 = __Pyx_PyUnicode_FormatSafe(__pyx_kp_u_cannot_convert_s_to_a_readable_b, ((PyObject *)Py_TYPE(__pyx_v_buf))); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 204, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      PyErr_SetObject(PyExc_AssertionError, __pyx_t_4);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __PYX_ERR(0, 204, __pyx_L1_error)
    }
  }
  #endif
+205:     return argbdata_to_rgb(cbuf, cbuf_len)
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_4 = __pyx_f_4xpra_6codecs_4argb_4argb_argbdata_to_rgb(__pyx_v_cbuf, __pyx_v_cbuf_len); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 205, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_r = __pyx_t_4;
  __pyx_t_4 = 0;
  goto __pyx_L0;
 206: 
+207: cdef argbdata_to_rgb(const unsigned char *argb, const int argb_len):
static PyObject *__pyx_f_4xpra_6codecs_4argb_4argb_argbdata_to_rgb(unsigned char const *__pyx_v_argb, int const __pyx_v_argb_len) {
  unsigned int __pyx_v_mi;
  struct __pyx_obj_4xpra_7buffers_6membuf_MemBuf *__pyx_v_output_buf = 0;
  unsigned char *__pyx_v_rgb;
  int __pyx_v_i;
  int __pyx_v_di;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("argbdata_to_rgb", 0);
/* … */
  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("xpra.codecs.argb.argb.argbdata_to_rgb", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_output_buf);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
+208:     if argb_len <= 0:
  __pyx_t_1 = ((__pyx_v_argb_len <= 0) != 0);
  if (__pyx_t_1) {
/* … */
  }
+209:         return None
    __Pyx_XDECREF(__pyx_r);
    __pyx_r = Py_None; __Pyx_INCREF(Py_None);
    goto __pyx_L0;
+210:     assert argb_len>0 and argb_len % 4 == 0, "invalid buffer size: %s is not a multiple of 4" % argb_len
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  if (unlikely(!Py_OptimizeFlag)) {
    __pyx_t_2 = ((__pyx_v_argb_len > 0) != 0);
    if (__pyx_t_2) {
    } else {
      __pyx_t_1 = __pyx_t_2;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_2 = (((__pyx_v_argb_len % 4) == 0) != 0);
    __pyx_t_1 = __pyx_t_2;
    __pyx_L4_bool_binop_done:;
    if (unlikely(!__pyx_t_1)) {
      __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_argb_len); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 210, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_4 = PyUnicode_Format(__pyx_kp_u_invalid_buffer_size_s_is_not_a_m_2, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 210, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      PyErr_SetObject(PyExc_AssertionError, __pyx_t_4);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __PYX_ERR(0, 210, __pyx_L1_error)
    }
  }
  #endif
 211:     #number of pixels:
+212:     cdef unsigned int mi = argb_len//4                #@DuplicateSignature
  __pyx_v_mi = (__pyx_v_argb_len / 4);
 213:     #3 bytes per pixel:
+214:     cdef MemBuf output_buf = padbuf(mi*3, 3)
  __pyx_t_4 = __pyx_f_4xpra_7buffers_6membuf_padbuf((__pyx_v_mi * 3), 3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 214, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  if (!(likely(((__pyx_t_4) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_4, __pyx_ptype_4xpra_7buffers_6membuf_MemBuf))))) __PYX_ERR(0, 214, __pyx_L1_error)
  __pyx_v_output_buf = ((struct __pyx_obj_4xpra_7buffers_6membuf_MemBuf *)__pyx_t_4);
  __pyx_t_4 = 0;
+215:     cdef unsigned char* rgb = <unsigned char*> output_buf.get_mem()
  __pyx_v_rgb = ((unsigned char *)((struct __pyx_vtabstruct_4xpra_7buffers_6membuf_MemBuf *)__pyx_v_output_buf->__pyx_vtab)->get_mem(__pyx_v_output_buf));
+216:     cdef int i = 0, di = 0                          #@DuplicateSignature
  __pyx_v_i = 0;
  __pyx_v_di = 0;
+217:     while i < argb_len:
  while (1) {
    __pyx_t_1 = ((__pyx_v_i < __pyx_v_argb_len) != 0);
    if (!__pyx_t_1) break;
+218:         rgb[di]   = argb[i+1]               #R
    (__pyx_v_rgb[__pyx_v_di]) = (__pyx_v_argb[(__pyx_v_i + 1)]);
+219:         rgb[di+1] = argb[i+2]               #G
    (__pyx_v_rgb[(__pyx_v_di + 1)]) = (__pyx_v_argb[(__pyx_v_i + 2)]);
+220:         rgb[di+2] = argb[i+3]               #B
    (__pyx_v_rgb[(__pyx_v_di + 2)]) = (__pyx_v_argb[(__pyx_v_i + 3)]);
+221:         di += 3
    __pyx_v_di = (__pyx_v_di + 3);
+222:         i += 4
    __pyx_v_i = (__pyx_v_i + 4);
  }
+223:     return memoryview(output_buf)
  __Pyx_XDECREF(__pyx_r);
  __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_memoryview); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 223, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_4, ((PyObject *)__pyx_v_output_buf)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 223, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_r = __pyx_t_3;
  __pyx_t_3 = 0;
  goto __pyx_L0;
 224: 
 225: 
+226: def bgra_to_rgb(buf):
/* Python wrapper */
static PyObject *__pyx_pw_4xpra_6codecs_4argb_4argb_15bgra_to_rgb(PyObject *__pyx_self, PyObject *__pyx_v_buf); /*proto*/
static PyMethodDef __pyx_mdef_4xpra_6codecs_4argb_4argb_15bgra_to_rgb = {"bgra_to_rgb", (PyCFunction)__pyx_pw_4xpra_6codecs_4argb_4argb_15bgra_to_rgb, METH_O, 0};
static PyObject *__pyx_pw_4xpra_6codecs_4argb_4argb_15bgra_to_rgb(PyObject *__pyx_self, PyObject *__pyx_v_buf) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("bgra_to_rgb (wrapper)", 0);
  __pyx_r = __pyx_pf_4xpra_6codecs_4argb_4argb_14bgra_to_rgb(__pyx_self, ((PyObject *)__pyx_v_buf));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4xpra_6codecs_4argb_4argb_14bgra_to_rgb(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_buf) {
  unsigned char *__pyx_v_bgra_buf;
  Py_ssize_t __pyx_v_bgra_buf_len;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("bgra_to_rgb", 0);
/* … */
  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("xpra.codecs.argb.argb.bgra_to_rgb", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
/* … */
  __pyx_tuple__16 = PyTuple_Pack(3, __pyx_n_s_buf, __pyx_n_s_bgra_buf, __pyx_n_s_bgra_buf_len); if (unlikely(!__pyx_tuple__16)) __PYX_ERR(0, 226, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__16);
  __Pyx_GIVEREF(__pyx_tuple__16);
/* … */
  __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_4xpra_6codecs_4argb_4argb_15bgra_to_rgb, NULL, __pyx_n_s_xpra_codecs_argb_argb); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 226, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_bgra_to_rgb, __pyx_t_1) < 0) __PYX_ERR(0, 226, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_codeobj__17 = (PyObject*)__Pyx_PyCode_New(1, 0, 3, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__16, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_xpra_codecs_argb_argb_pyx, __pyx_n_s_bgra_to_rgb, 226, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__17)) __PYX_ERR(0, 226, __pyx_L1_error)
+227:     assert len(buf) % 4 == 0, "invalid buffer size: %s is not a multiple of 4" % len(buf)
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  if (unlikely(!Py_OptimizeFlag)) {
    __pyx_t_1 = PyObject_Length(__pyx_v_buf); if (unlikely(__pyx_t_1 == ((Py_ssize_t)-1))) __PYX_ERR(0, 227, __pyx_L1_error)
    if (unlikely(!(((__pyx_t_1 % 4) == 0) != 0))) {
      __pyx_t_2 = PyObject_Length(__pyx_v_buf); if (unlikely(__pyx_t_2 == ((Py_ssize_t)-1))) __PYX_ERR(0, 227, __pyx_L1_error)
      __pyx_t_3 = PyInt_FromSsize_t(__pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 227, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_4 = PyUnicode_Format(__pyx_kp_u_invalid_buffer_size_s_is_not_a_m_2, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 227, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      PyErr_SetObject(PyExc_AssertionError, __pyx_t_4);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __PYX_ERR(0, 227, __pyx_L1_error)
    }
  }
  #endif
 228:     # buf is a Python buffer object
+229:     cdef unsigned char * bgra_buf = NULL    #@DuplicateSignature
  __pyx_v_bgra_buf = NULL;
+230:     cdef Py_ssize_t bgra_buf_len = 0        #@DuplicateSignature
  __pyx_v_bgra_buf_len = 0;
+231:     assert as_buffer(buf, <const void**> &bgra_buf, &bgra_buf_len)==0, "cannot convert %s to a readable buffer" % type(buf)
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  if (unlikely(!Py_OptimizeFlag)) {
    __pyx_t_5 = __pyx_f_4xpra_6codecs_4argb_4argb_as_buffer(__pyx_v_buf, ((void const **)(&__pyx_v_bgra_buf)), (&__pyx_v_bgra_buf_len)); if (unlikely(__pyx_t_5 == ((int)-1))) __PYX_ERR(0, 231, __pyx_L1_error)
    if (unlikely(!((__pyx_t_5 == 0) != 0))) {
      __pyx_t_4 = __Pyx_PyUnicode_FormatSafe(__pyx_kp_u_cannot_convert_s_to_a_readable_b, ((PyObject *)Py_TYPE(__pyx_v_buf))); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 231, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      PyErr_SetObject(PyExc_AssertionError, __pyx_t_4);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __PYX_ERR(0, 231, __pyx_L1_error)
    }
  }
  #endif
+232:     return bgradata_to_rgb(bgra_buf, bgra_buf_len)
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_4 = __pyx_f_4xpra_6codecs_4argb_4argb_bgradata_to_rgb(__pyx_v_bgra_buf, __pyx_v_bgra_buf_len); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 232, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_r = __pyx_t_4;
  __pyx_t_4 = 0;
  goto __pyx_L0;
 233: 
+234: cdef bgradata_to_rgb(const unsigned char* bgra, const int bgra_len):
static PyObject *__pyx_f_4xpra_6codecs_4argb_4argb_bgradata_to_rgb(unsigned char const *__pyx_v_bgra, int const __pyx_v_bgra_len) {
  int __pyx_v_mi;
  struct __pyx_obj_4xpra_7buffers_6membuf_MemBuf *__pyx_v_output_buf = 0;
  unsigned char *__pyx_v_rgb;
  int __pyx_v_di;
  int __pyx_v_si;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("bgradata_to_rgb", 0);
/* … */
  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("xpra.codecs.argb.argb.bgradata_to_rgb", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_output_buf);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
+235:     if bgra_len <= 0:
  __pyx_t_1 = ((__pyx_v_bgra_len <= 0) != 0);
  if (__pyx_t_1) {
/* … */
  }
+236:         return None
    __Pyx_XDECREF(__pyx_r);
    __pyx_r = Py_None; __Pyx_INCREF(Py_None);
    goto __pyx_L0;
+237:     assert bgra_len>0 and bgra_len % 4 == 0, "invalid buffer size: %s is not a multiple of 4" % bgra_len
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  if (unlikely(!Py_OptimizeFlag)) {
    __pyx_t_2 = ((__pyx_v_bgra_len > 0) != 0);
    if (__pyx_t_2) {
    } else {
      __pyx_t_1 = __pyx_t_2;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_2 = (((__pyx_v_bgra_len % 4) == 0) != 0);
    __pyx_t_1 = __pyx_t_2;
    __pyx_L4_bool_binop_done:;
    if (unlikely(!__pyx_t_1)) {
      __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_bgra_len); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 237, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_4 = PyUnicode_Format(__pyx_kp_u_invalid_buffer_size_s_is_not_a_m_2, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 237, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      PyErr_SetObject(PyExc_AssertionError, __pyx_t_4);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __PYX_ERR(0, 237, __pyx_L1_error)
    }
  }
  #endif
 238:     #number of pixels:
+239:     cdef int mi = bgra_len//4                #@DuplicateSignature
  __pyx_v_mi = (__pyx_v_bgra_len / 4);
 240:     #3 bytes per pixel:
+241:     cdef MemBuf output_buf = padbuf(mi*3, 3)
  __pyx_t_4 = __pyx_f_4xpra_7buffers_6membuf_padbuf((__pyx_v_mi * 3), 3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 241, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  if (!(likely(((__pyx_t_4) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_4, __pyx_ptype_4xpra_7buffers_6membuf_MemBuf))))) __PYX_ERR(0, 241, __pyx_L1_error)
  __pyx_v_output_buf = ((struct __pyx_obj_4xpra_7buffers_6membuf_MemBuf *)__pyx_t_4);
  __pyx_t_4 = 0;
+242:     cdef unsigned char* rgb = <unsigned char*> output_buf.get_mem()
  __pyx_v_rgb = ((unsigned char *)((struct __pyx_vtabstruct_4xpra_7buffers_6membuf_MemBuf *)__pyx_v_output_buf->__pyx_vtab)->get_mem(__pyx_v_output_buf));
+243:     cdef int di = 0, si = 0                  #@DuplicateSignature
  __pyx_v_di = 0;
  __pyx_v_si = 0;
+244:     while si < bgra_len:
  while (1) {
    __pyx_t_1 = ((__pyx_v_si < __pyx_v_bgra_len) != 0);
    if (!__pyx_t_1) break;
+245:         rgb[di]   = bgra[si+2]              #R
    (__pyx_v_rgb[__pyx_v_di]) = (__pyx_v_bgra[(__pyx_v_si + 2)]);
+246:         rgb[di+1] = bgra[si+1]              #G
    (__pyx_v_rgb[(__pyx_v_di + 1)]) = (__pyx_v_bgra[(__pyx_v_si + 1)]);
+247:         rgb[di+2] = bgra[si]                #B
    (__pyx_v_rgb[(__pyx_v_di + 2)]) = (__pyx_v_bgra[__pyx_v_si]);
+248:         di += 3
    __pyx_v_di = (__pyx_v_di + 3);
+249:         si += 4
    __pyx_v_si = (__pyx_v_si + 4);
  }
+250:     return memoryview(output_buf)
  __Pyx_XDECREF(__pyx_r);
  __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_memoryview); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 250, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_4, ((PyObject *)__pyx_v_output_buf)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 250, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_r = __pyx_t_3;
  __pyx_t_3 = 0;
  goto __pyx_L0;
 251: 
+252: def bgra_to_rgba(buf):
/* Python wrapper */
static PyObject *__pyx_pw_4xpra_6codecs_4argb_4argb_17bgra_to_rgba(PyObject *__pyx_self, PyObject *__pyx_v_buf); /*proto*/
static PyMethodDef __pyx_mdef_4xpra_6codecs_4argb_4argb_17bgra_to_rgba = {"bgra_to_rgba", (PyCFunction)__pyx_pw_4xpra_6codecs_4argb_4argb_17bgra_to_rgba, METH_O, 0};
static PyObject *__pyx_pw_4xpra_6codecs_4argb_4argb_17bgra_to_rgba(PyObject *__pyx_self, PyObject *__pyx_v_buf) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("bgra_to_rgba (wrapper)", 0);
  __pyx_r = __pyx_pf_4xpra_6codecs_4argb_4argb_16bgra_to_rgba(__pyx_self, ((PyObject *)__pyx_v_buf));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4xpra_6codecs_4argb_4argb_16bgra_to_rgba(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_buf) {
  unsigned char *__pyx_v_bgra_buf2;
  Py_ssize_t __pyx_v_bgra_buf_len2;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("bgra_to_rgba", 0);
/* … */
  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("xpra.codecs.argb.argb.bgra_to_rgba", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
/* … */
  __pyx_tuple__18 = PyTuple_Pack(3, __pyx_n_s_buf, __pyx_n_s_bgra_buf2, __pyx_n_s_bgra_buf_len2); if (unlikely(!__pyx_tuple__18)) __PYX_ERR(0, 252, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__18);
  __Pyx_GIVEREF(__pyx_tuple__18);
/* … */
  __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_4xpra_6codecs_4argb_4argb_17bgra_to_rgba, NULL, __pyx_n_s_xpra_codecs_argb_argb); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 252, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_bgra_to_rgba, __pyx_t_1) < 0) __PYX_ERR(0, 252, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_codeobj__19 = (PyObject*)__Pyx_PyCode_New(1, 0, 3, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__18, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_xpra_codecs_argb_argb_pyx, __pyx_n_s_bgra_to_rgba, 252, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__19)) __PYX_ERR(0, 252, __pyx_L1_error)
+253:     assert len(buf) % 4 == 0, "invalid buffer size: %s is not a multiple of 4" % len(buf)
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  if (unlikely(!Py_OptimizeFlag)) {
    __pyx_t_1 = PyObject_Length(__pyx_v_buf); if (unlikely(__pyx_t_1 == ((Py_ssize_t)-1))) __PYX_ERR(0, 253, __pyx_L1_error)
    if (unlikely(!(((__pyx_t_1 % 4) == 0) != 0))) {
      __pyx_t_2 = PyObject_Length(__pyx_v_buf); if (unlikely(__pyx_t_2 == ((Py_ssize_t)-1))) __PYX_ERR(0, 253, __pyx_L1_error)
      __pyx_t_3 = PyInt_FromSsize_t(__pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 253, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_4 = PyUnicode_Format(__pyx_kp_u_invalid_buffer_size_s_is_not_a_m_2, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 253, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      PyErr_SetObject(PyExc_AssertionError, __pyx_t_4);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __PYX_ERR(0, 253, __pyx_L1_error)
    }
  }
  #endif
 254:     # buf is a Python buffer object
+255:     cdef unsigned char * bgra_buf2 = NULL
  __pyx_v_bgra_buf2 = NULL;
+256:     cdef Py_ssize_t bgra_buf_len2 = 0
  __pyx_v_bgra_buf_len2 = 0;
+257:     assert as_buffer(buf, <const void**> &bgra_buf2, &bgra_buf_len2)==0, "cannot convert %s to a readable buffer" % type(buf)
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  if (unlikely(!Py_OptimizeFlag)) {
    __pyx_t_5 = __pyx_f_4xpra_6codecs_4argb_4argb_as_buffer(__pyx_v_buf, ((void const **)(&__pyx_v_bgra_buf2)), (&__pyx_v_bgra_buf_len2)); if (unlikely(__pyx_t_5 == ((int)-1))) __PYX_ERR(0, 257, __pyx_L1_error)
    if (unlikely(!((__pyx_t_5 == 0) != 0))) {
      __pyx_t_4 = __Pyx_PyUnicode_FormatSafe(__pyx_kp_u_cannot_convert_s_to_a_readable_b, ((PyObject *)Py_TYPE(__pyx_v_buf))); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 257, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      PyErr_SetObject(PyExc_AssertionError, __pyx_t_4);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __PYX_ERR(0, 257, __pyx_L1_error)
    }
  }
  #endif
+258:     return bgradata_to_rgba(bgra_buf2, bgra_buf_len2)
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_4 = __pyx_f_4xpra_6codecs_4argb_4argb_bgradata_to_rgba(__pyx_v_bgra_buf2, __pyx_v_bgra_buf_len2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 258, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_r = __pyx_t_4;
  __pyx_t_4 = 0;
  goto __pyx_L0;
 259: 
+260: cdef bgradata_to_rgba(const unsigned char* bgra, const int bgra_len):
static PyObject *__pyx_f_4xpra_6codecs_4argb_4argb_bgradata_to_rgba(unsigned char const *__pyx_v_bgra, int const __pyx_v_bgra_len) {
  struct __pyx_obj_4xpra_7buffers_6membuf_MemBuf *__pyx_v_output_buf = 0;
  unsigned char *__pyx_v_rgba;
  int __pyx_v_i;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("bgradata_to_rgba", 0);
/* … */
  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("xpra.codecs.argb.argb.bgradata_to_rgba", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_output_buf);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
+261:     if bgra_len <= 0:
  __pyx_t_1 = ((__pyx_v_bgra_len <= 0) != 0);
  if (__pyx_t_1) {
/* … */
  }
+262:         return None
    __Pyx_XDECREF(__pyx_r);
    __pyx_r = Py_None; __Pyx_INCREF(Py_None);
    goto __pyx_L0;
+263:     assert bgra_len>0 and bgra_len % 4 == 0, "invalid buffer size: %s is not a multiple of 4" % bgra_len
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  if (unlikely(!Py_OptimizeFlag)) {
    __pyx_t_2 = ((__pyx_v_bgra_len > 0) != 0);
    if (__pyx_t_2) {
    } else {
      __pyx_t_1 = __pyx_t_2;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_2 = (((__pyx_v_bgra_len % 4) == 0) != 0);
    __pyx_t_1 = __pyx_t_2;
    __pyx_L4_bool_binop_done:;
    if (unlikely(!__pyx_t_1)) {
      __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_bgra_len); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 263, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_4 = PyUnicode_Format(__pyx_kp_u_invalid_buffer_size_s_is_not_a_m_2, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 263, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      PyErr_SetObject(PyExc_AssertionError, __pyx_t_4);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __PYX_ERR(0, 263, __pyx_L1_error)
    }
  }
  #endif
 264:     #same number of bytes:
+265:     cdef MemBuf output_buf = getbuf(bgra_len)
  __pyx_t_4 = __pyx_f_4xpra_7buffers_6membuf_getbuf(__pyx_v_bgra_len); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 265, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  if (!(likely(((__pyx_t_4) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_4, __pyx_ptype_4xpra_7buffers_6membuf_MemBuf))))) __PYX_ERR(0, 265, __pyx_L1_error)
  __pyx_v_output_buf = ((struct __pyx_obj_4xpra_7buffers_6membuf_MemBuf *)__pyx_t_4);
  __pyx_t_4 = 0;
+266:     cdef unsigned char* rgba = <unsigned char*> output_buf.get_mem()
  __pyx_v_rgba = ((unsigned char *)((struct __pyx_vtabstruct_4xpra_7buffers_6membuf_MemBuf *)__pyx_v_output_buf->__pyx_vtab)->get_mem(__pyx_v_output_buf));
+267:     cdef int i = 0                      #@DuplicateSignature
  __pyx_v_i = 0;
+268:     while i < bgra_len:
  while (1) {
    __pyx_t_1 = ((__pyx_v_i < __pyx_v_bgra_len) != 0);
    if (!__pyx_t_1) break;
+269:         rgba[i]   = bgra[i+2]           #R
    (__pyx_v_rgba[__pyx_v_i]) = (__pyx_v_bgra[(__pyx_v_i + 2)]);
+270:         rgba[i+1] = bgra[i+1]           #G
    (__pyx_v_rgba[(__pyx_v_i + 1)]) = (__pyx_v_bgra[(__pyx_v_i + 1)]);
+271:         rgba[i+2] = bgra[i]             #B
    (__pyx_v_rgba[(__pyx_v_i + 2)]) = (__pyx_v_bgra[__pyx_v_i]);
+272:         rgba[i+3] = bgra[i+3]           #A
    (__pyx_v_rgba[(__pyx_v_i + 3)]) = (__pyx_v_bgra[(__pyx_v_i + 3)]);
+273:         i += 4
    __pyx_v_i = (__pyx_v_i + 4);
  }
+274:     return memoryview(output_buf)
  __Pyx_XDECREF(__pyx_r);
  __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_memoryview); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 274, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_4, ((PyObject *)__pyx_v_output_buf)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 274, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_r = __pyx_t_3;
  __pyx_t_3 = 0;
  goto __pyx_L0;
 275: 
+276: def rgba_to_bgra(buf):
/* Python wrapper */
static PyObject *__pyx_pw_4xpra_6codecs_4argb_4argb_19rgba_to_bgra(PyObject *__pyx_self, PyObject *__pyx_v_buf); /*proto*/
static PyMethodDef __pyx_mdef_4xpra_6codecs_4argb_4argb_19rgba_to_bgra = {"rgba_to_bgra", (PyCFunction)__pyx_pw_4xpra_6codecs_4argb_4argb_19rgba_to_bgra, METH_O, 0};
static PyObject *__pyx_pw_4xpra_6codecs_4argb_4argb_19rgba_to_bgra(PyObject *__pyx_self, PyObject *__pyx_v_buf) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("rgba_to_bgra (wrapper)", 0);
  __pyx_r = __pyx_pf_4xpra_6codecs_4argb_4argb_18rgba_to_bgra(__pyx_self, ((PyObject *)__pyx_v_buf));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4xpra_6codecs_4argb_4argb_18rgba_to_bgra(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_buf) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("rgba_to_bgra", 0);
/* … */
  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("xpra.codecs.argb.argb.rgba_to_bgra", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
/* … */
  __pyx_tuple__20 = PyTuple_Pack(1, __pyx_n_s_buf); if (unlikely(!__pyx_tuple__20)) __PYX_ERR(0, 276, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__20);
  __Pyx_GIVEREF(__pyx_tuple__20);
/* … */
  __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_4xpra_6codecs_4argb_4argb_19rgba_to_bgra, NULL, __pyx_n_s_xpra_codecs_argb_argb); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 276, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_rgba_to_bgra, __pyx_t_1) < 0) __PYX_ERR(0, 276, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_codeobj__21 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__20, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_xpra_codecs_argb_argb_pyx, __pyx_n_s_rgba_to_bgra, 276, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__21)) __PYX_ERR(0, 276, __pyx_L1_error)
 277:     #same: just a swap
+278:     return bgra_to_rgba(buf)
  __Pyx_XDECREF(__pyx_r);
  __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_bgra_to_rgba); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 278, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  __pyx_t_1 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_3, __pyx_v_buf) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v_buf);
  __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 278, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;
 279: 
 280: 
+281: def premultiply_argb_in_place(buf):
/* Python wrapper */
static PyObject *__pyx_pw_4xpra_6codecs_4argb_4argb_21premultiply_argb_in_place(PyObject *__pyx_self, PyObject *__pyx_v_buf); /*proto*/
static PyMethodDef __pyx_mdef_4xpra_6codecs_4argb_4argb_21premultiply_argb_in_place = {"premultiply_argb_in_place", (PyCFunction)__pyx_pw_4xpra_6codecs_4argb_4argb_21premultiply_argb_in_place, METH_O, 0};
static PyObject *__pyx_pw_4xpra_6codecs_4argb_4argb_21premultiply_argb_in_place(PyObject *__pyx_self, PyObject *__pyx_v_buf) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("premultiply_argb_in_place (wrapper)", 0);
  __pyx_r = __pyx_pf_4xpra_6codecs_4argb_4argb_20premultiply_argb_in_place(__pyx_self, ((PyObject *)__pyx_v_buf));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4xpra_6codecs_4argb_4argb_20premultiply_argb_in_place(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_buf) {
  unsigned int *__pyx_v_cbuf;
  Py_ssize_t __pyx_v_cbuf_len;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("premultiply_argb_in_place", 0);
/* … */
  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("xpra.codecs.argb.argb.premultiply_argb_in_place", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
/* … */
  __pyx_tuple__22 = PyTuple_Pack(3, __pyx_n_s_buf, __pyx_n_s_cbuf, __pyx_n_s_cbuf_len); if (unlikely(!__pyx_tuple__22)) __PYX_ERR(0, 281, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__22);
  __Pyx_GIVEREF(__pyx_tuple__22);
/* … */
  __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_4xpra_6codecs_4argb_4argb_21premultiply_argb_in_place, NULL, __pyx_n_s_xpra_codecs_argb_argb); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 281, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_premultiply_argb_in_place, __pyx_t_1) < 0) __PYX_ERR(0, 281, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_codeobj__23 = (PyObject*)__Pyx_PyCode_New(1, 0, 3, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__22, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_xpra_codecs_argb_argb_pyx, __pyx_n_s_premultiply_argb_in_place, 281, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__23)) __PYX_ERR(0, 281, __pyx_L1_error)
 282:     # b is a Python buffer object
+283:     cdef unsigned int * cbuf = <unsigned int *> 0
  __pyx_v_cbuf = ((unsigned int *)0);
+284:     cdef Py_ssize_t cbuf_len = 0                #@DuplicateSignature
  __pyx_v_cbuf_len = 0;
+285:     assert len(buf) % 4 == 0, "invalid buffer size: %s is not a multiple of 4" % len(buf)
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  if (unlikely(!Py_OptimizeFlag)) {
    __pyx_t_1 = PyObject_Length(__pyx_v_buf); if (unlikely(__pyx_t_1 == ((Py_ssize_t)-1))) __PYX_ERR(0, 285, __pyx_L1_error)
    if (unlikely(!(((__pyx_t_1 % 4) == 0) != 0))) {
      __pyx_t_2 = PyObject_Length(__pyx_v_buf); if (unlikely(__pyx_t_2 == ((Py_ssize_t)-1))) __PYX_ERR(0, 285, __pyx_L1_error)
      __pyx_t_3 = PyInt_FromSsize_t(__pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 285, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_4 = PyUnicode_Format(__pyx_kp_u_invalid_buffer_size_s_is_not_a_m_2, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 285, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      PyErr_SetObject(PyExc_AssertionError, __pyx_t_4);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __PYX_ERR(0, 285, __pyx_L1_error)
    }
  }
  #endif
+286:     assert object_as_write_buffer(buf, <void **>&cbuf, &cbuf_len)==0
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  if (unlikely(!Py_OptimizeFlag)) {
    if (unlikely(!((__pyx_f_4xpra_7buffers_6membuf_object_as_write_buffer(__pyx_v_buf, ((void **)(&__pyx_v_cbuf)), (&__pyx_v_cbuf_len)) == 0) != 0))) {
      PyErr_SetNone(PyExc_AssertionError);
      __PYX_ERR(0, 286, __pyx_L1_error)
    }
  }
  #endif
+287:     do_premultiply_argb_in_place(cbuf, cbuf_len)
  __pyx_t_4 = __pyx_f_4xpra_6codecs_4argb_4argb_do_premultiply_argb_in_place(__pyx_v_cbuf, __pyx_v_cbuf_len); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 287, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
 288: 
+289: cdef do_premultiply_argb_in_place(unsigned int *buf, Py_ssize_t argb_len):
static PyObject *__pyx_f_4xpra_6codecs_4argb_4argb_do_premultiply_argb_in_place(unsigned int *__pyx_v_buf, Py_ssize_t __pyx_v_argb_len) {
  unsigned char __pyx_v_a;
  unsigned char __pyx_v_r;
  unsigned char __pyx_v_g;
  unsigned char __pyx_v_b;
  unsigned int __pyx_v_argb;
  int __pyx_v_i;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("do_premultiply_argb_in_place", 0);
/* … */
  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("xpra.codecs.argb.argb.do_premultiply_argb_in_place", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
 290:     # cbuf contains non-premultiplied ARGB32 data in native-endian.
 291:     # We convert to premultiplied ARGB32 data, in-place.
 292:     cdef unsigned char a, r, g, b
 293:     cdef unsigned int argb
+294:     assert argb_len>0 and argb_len % 4 == 0, "invalid buffer size: %s is not a multiple of 4" % argb_len
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  if (unlikely(!Py_OptimizeFlag)) {
    __pyx_t_2 = ((__pyx_v_argb_len > 0) != 0);
    if (__pyx_t_2) {
    } else {
      __pyx_t_1 = __pyx_t_2;
      goto __pyx_L3_bool_binop_done;
    }
    __pyx_t_2 = (((__pyx_v_argb_len % 4) == 0) != 0);
    __pyx_t_1 = __pyx_t_2;
    __pyx_L3_bool_binop_done:;
    if (unlikely(!__pyx_t_1)) {
      __pyx_t_3 = PyInt_FromSsize_t(__pyx_v_argb_len); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 294, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_4 = PyUnicode_Format(__pyx_kp_u_invalid_buffer_size_s_is_not_a_m_2, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 294, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      PyErr_SetObject(PyExc_AssertionError, __pyx_t_4);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __PYX_ERR(0, 294, __pyx_L1_error)
    }
  }
  #endif
 295:     cdef int i
+296:     for 0 <= i < argb_len / 4:
  __pyx_t_5 = (__pyx_v_argb_len / 4);
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_5; __pyx_v_i++) {
+297:         argb = buf[i]
    __pyx_v_argb = (__pyx_v_buf[__pyx_v_i]);
+298:         a = (argb >> 24) & 0xff
    __pyx_v_a = ((__pyx_v_argb >> 24) & 0xff);
+299:         r = (argb >> 16) & 0xff
    __pyx_v_r = ((__pyx_v_argb >> 16) & 0xff);
+300:         r = r * a // 255
    __pyx_v_r = ((__pyx_v_r * __pyx_v_a) / 0xFF);
+301:         g = (argb >> 8) & 0xff
    __pyx_v_g = ((__pyx_v_argb >> 8) & 0xff);
+302:         g = g * a // 255
    __pyx_v_g = ((__pyx_v_g * __pyx_v_a) / 0xFF);
+303:         b = (argb >> 0) & 0xff
    __pyx_v_b = ((__pyx_v_argb >> 0) & 0xff);
+304:         b = b * a // 255
    __pyx_v_b = ((__pyx_v_b * __pyx_v_a) / 0xFF);
+305:         buf[i] = (a << 24) | (r << 16) | (g << 8) | (b << 0)
    (__pyx_v_buf[__pyx_v_i]) = ((((__pyx_v_a << 24) | (__pyx_v_r << 16)) | (__pyx_v_g << 8)) | (__pyx_v_b << 0));
  }
 306: 
+307: def unpremultiply_argb_in_place(buf):
/* Python wrapper */
static PyObject *__pyx_pw_4xpra_6codecs_4argb_4argb_23unpremultiply_argb_in_place(PyObject *__pyx_self, PyObject *__pyx_v_buf); /*proto*/
static PyMethodDef __pyx_mdef_4xpra_6codecs_4argb_4argb_23unpremultiply_argb_in_place = {"unpremultiply_argb_in_place", (PyCFunction)__pyx_pw_4xpra_6codecs_4argb_4argb_23unpremultiply_argb_in_place, METH_O, 0};
static PyObject *__pyx_pw_4xpra_6codecs_4argb_4argb_23unpremultiply_argb_in_place(PyObject *__pyx_self, PyObject *__pyx_v_buf) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("unpremultiply_argb_in_place (wrapper)", 0);
  __pyx_r = __pyx_pf_4xpra_6codecs_4argb_4argb_22unpremultiply_argb_in_place(__pyx_self, ((PyObject *)__pyx_v_buf));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4xpra_6codecs_4argb_4argb_22unpremultiply_argb_in_place(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_buf) {
  unsigned int *__pyx_v_cbuf;
  Py_ssize_t __pyx_v_cbuf_len;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("unpremultiply_argb_in_place", 0);
/* … */
  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("xpra.codecs.argb.argb.unpremultiply_argb_in_place", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
/* … */
  __pyx_tuple__24 = PyTuple_Pack(3, __pyx_n_s_buf, __pyx_n_s_cbuf, __pyx_n_s_cbuf_len); if (unlikely(!__pyx_tuple__24)) __PYX_ERR(0, 307, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__24);
  __Pyx_GIVEREF(__pyx_tuple__24);
/* … */
  __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_4xpra_6codecs_4argb_4argb_23unpremultiply_argb_in_place, NULL, __pyx_n_s_xpra_codecs_argb_argb); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 307, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_unpremultiply_argb_in_place, __pyx_t_1) < 0) __PYX_ERR(0, 307, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_codeobj__25 = (PyObject*)__Pyx_PyCode_New(1, 0, 3, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__24, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_xpra_codecs_argb_argb_pyx, __pyx_n_s_unpremultiply_argb_in_place, 307, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__25)) __PYX_ERR(0, 307, __pyx_L1_error)
 308:     # b is a Python buffer object
+309:     cdef unsigned int * cbuf = <unsigned int *> 0   #@DuplicateSignature
  __pyx_v_cbuf = ((unsigned int *)0);
+310:     cdef Py_ssize_t cbuf_len = 0                    #@DuplicateSignature
  __pyx_v_cbuf_len = 0;
+311:     assert len(buf) % 4 == 0, "invalid buffer size: %s is not a multiple of 4" % len(buf)
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  if (unlikely(!Py_OptimizeFlag)) {
    __pyx_t_1 = PyObject_Length(__pyx_v_buf); if (unlikely(__pyx_t_1 == ((Py_ssize_t)-1))) __PYX_ERR(0, 311, __pyx_L1_error)
    if (unlikely(!(((__pyx_t_1 % 4) == 0) != 0))) {
      __pyx_t_2 = PyObject_Length(__pyx_v_buf); if (unlikely(__pyx_t_2 == ((Py_ssize_t)-1))) __PYX_ERR(0, 311, __pyx_L1_error)
      __pyx_t_3 = PyInt_FromSsize_t(__pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 311, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_4 = PyUnicode_Format(__pyx_kp_u_invalid_buffer_size_s_is_not_a_m_2, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 311, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      PyErr_SetObject(PyExc_AssertionError, __pyx_t_4);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __PYX_ERR(0, 311, __pyx_L1_error)
    }
  }
  #endif
+312:     assert object_as_write_buffer(buf, <void **>&cbuf, &cbuf_len)==0, "cannot convert %s to a writable buffer" % type(buf)
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  if (unlikely(!Py_OptimizeFlag)) {
    if (unlikely(!((__pyx_f_4xpra_7buffers_6membuf_object_as_write_buffer(__pyx_v_buf, ((void **)(&__pyx_v_cbuf)), (&__pyx_v_cbuf_len)) == 0) != 0))) {
      __pyx_t_4 = __Pyx_PyUnicode_FormatSafe(__pyx_kp_u_cannot_convert_s_to_a_writable_b, ((PyObject *)Py_TYPE(__pyx_v_buf))); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 312, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      PyErr_SetObject(PyExc_AssertionError, __pyx_t_4);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __PYX_ERR(0, 312, __pyx_L1_error)
    }
  }
  #endif
+313:     do_unpremultiply_argb_in_place(cbuf, cbuf_len)
  __pyx_t_4 = __pyx_f_4xpra_6codecs_4argb_4argb_do_unpremultiply_argb_in_place(__pyx_v_cbuf, __pyx_v_cbuf_len); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 313, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
 314: 
+315: cdef do_unpremultiply_argb_in_place(unsigned int * buf, Py_ssize_t buf_len):
static PyObject *__pyx_f_4xpra_6codecs_4argb_4argb_do_unpremultiply_argb_in_place(unsigned int *__pyx_v_buf, Py_ssize_t __pyx_v_buf_len) {
  unsigned char __pyx_v_a;
  unsigned char __pyx_v_r;
  unsigned char __pyx_v_g;
  unsigned char __pyx_v_b;
  unsigned int __pyx_v_argb;
  int __pyx_v_i;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("do_unpremultiply_argb_in_place", 0);
/* … */
  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("xpra.codecs.argb.argb.do_unpremultiply_argb_in_place", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
 316:     # cbuf contains non-premultiplied ARGB32 data in native-endian.
 317:     # We convert to premultiplied ARGB32 data, in-place.
 318:     cdef unsigned char a, r, g, b                   #@DuplicateSignature
 319:     cdef unsigned int argb                          #@DuplicateSignature
+320:     assert buf_len>0 and buf_len % 4 == 0, "invalid buffer size: %s is not a multiple of 4" % buf_len
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  if (unlikely(!Py_OptimizeFlag)) {
    __pyx_t_2 = ((__pyx_v_buf_len > 0) != 0);
    if (__pyx_t_2) {
    } else {
      __pyx_t_1 = __pyx_t_2;
      goto __pyx_L3_bool_binop_done;
    }
    __pyx_t_2 = (((__pyx_v_buf_len % 4) == 0) != 0);
    __pyx_t_1 = __pyx_t_2;
    __pyx_L3_bool_binop_done:;
    if (unlikely(!__pyx_t_1)) {
      __pyx_t_3 = PyInt_FromSsize_t(__pyx_v_buf_len); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 320, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_4 = PyUnicode_Format(__pyx_kp_u_invalid_buffer_size_s_is_not_a_m_2, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 320, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      PyErr_SetObject(PyExc_AssertionError, __pyx_t_4);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __PYX_ERR(0, 320, __pyx_L1_error)
    }
  }
  #endif
 321:     cdef int i                                      #@DuplicateSignature
+322:     for 0 <= i < buf_len // 4:
  __pyx_t_5 = (__pyx_v_buf_len / 4);
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_5; __pyx_v_i++) {
+323:         argb = buf[i]
    __pyx_v_argb = (__pyx_v_buf[__pyx_v_i]);
+324:         a = (argb >> 24) & 0xff
    __pyx_v_a = ((__pyx_v_argb >> 24) & 0xff);
+325:         if a==0:
    __pyx_t_1 = ((__pyx_v_a == 0) != 0);
    if (__pyx_t_1) {
/* … */
    }
+326:             buf[i] = 0
      (__pyx_v_buf[__pyx_v_i]) = 0;
+327:             continue
      goto __pyx_L5_continue;
+328:         r = clamp(((argb >> 16) & 0xff) * 255 // a)
    __pyx_v_r = __pyx_f_4xpra_6codecs_4argb_4argb_clamp(((((__pyx_v_argb >> 16) & 0xff) * 0xFF) / __pyx_v_a));
+329:         g = clamp(((argb >> 8) & 0xff) * 255 // a)
    __pyx_v_g = __pyx_f_4xpra_6codecs_4argb_4argb_clamp(((((__pyx_v_argb >> 8) & 0xff) * 0xFF) / __pyx_v_a));
+330:         b = clamp(((argb >> 0) & 0xff) * 255 // a)
    __pyx_v_b = __pyx_f_4xpra_6codecs_4argb_4argb_clamp(((((__pyx_v_argb >> 0) & 0xff) * 0xFF) / __pyx_v_a));
+331:         buf[i] = (a << 24) | (r << 16) | (g << 8) | (b << 0)
    (__pyx_v_buf[__pyx_v_i]) = ((((__pyx_v_a << 24) | (__pyx_v_r << 16)) | (__pyx_v_g << 8)) | (__pyx_v_b << 0));
    __pyx_L5_continue:;
  }
 332: 
+333: def unpremultiply_argb(buf):
/* Python wrapper */
static PyObject *__pyx_pw_4xpra_6codecs_4argb_4argb_25unpremultiply_argb(PyObject *__pyx_self, PyObject *__pyx_v_buf); /*proto*/
static PyMethodDef __pyx_mdef_4xpra_6codecs_4argb_4argb_25unpremultiply_argb = {"unpremultiply_argb", (PyCFunction)__pyx_pw_4xpra_6codecs_4argb_4argb_25unpremultiply_argb, METH_O, 0};
static PyObject *__pyx_pw_4xpra_6codecs_4argb_4argb_25unpremultiply_argb(PyObject *__pyx_self, PyObject *__pyx_v_buf) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("unpremultiply_argb (wrapper)", 0);
  __pyx_r = __pyx_pf_4xpra_6codecs_4argb_4argb_24unpremultiply_argb(__pyx_self, ((PyObject *)__pyx_v_buf));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4xpra_6codecs_4argb_4argb_24unpremultiply_argb(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_buf) {
  unsigned int *__pyx_v_argb;
  Py_ssize_t __pyx_v_argb_len;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("unpremultiply_argb", 0);
/* … */
  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("xpra.codecs.argb.argb.unpremultiply_argb", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
/* … */
  __pyx_tuple__26 = PyTuple_Pack(3, __pyx_n_s_buf, __pyx_n_s_argb, __pyx_n_s_argb_len); if (unlikely(!__pyx_tuple__26)) __PYX_ERR(0, 333, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__26);
  __Pyx_GIVEREF(__pyx_tuple__26);
/* … */
  __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_4xpra_6codecs_4argb_4argb_25unpremultiply_argb, NULL, __pyx_n_s_xpra_codecs_argb_argb); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 333, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_unpremultiply_argb, __pyx_t_1) < 0) __PYX_ERR(0, 333, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_codeobj__27 = (PyObject*)__Pyx_PyCode_New(1, 0, 3, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__26, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_xpra_codecs_argb_argb_pyx, __pyx_n_s_unpremultiply_argb, 333, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__27)) __PYX_ERR(0, 333, __pyx_L1_error)
 334:     # b is a Python buffer object
+335:     cdef unsigned int * argb = <unsigned int *> 0   #@DuplicateSignature
  __pyx_v_argb = ((unsigned int *)0);
+336:     cdef Py_ssize_t argb_len = 0                    #@DuplicateSignature
  __pyx_v_argb_len = 0;
+337:     assert len(buf) % 4 == 0, "invalid buffer size: %s is not a multiple of 4" % len(buf)
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  if (unlikely(!Py_OptimizeFlag)) {
    __pyx_t_1 = PyObject_Length(__pyx_v_buf); if (unlikely(__pyx_t_1 == ((Py_ssize_t)-1))) __PYX_ERR(0, 337, __pyx_L1_error)
    if (unlikely(!(((__pyx_t_1 % 4) == 0) != 0))) {
      __pyx_t_2 = PyObject_Length(__pyx_v_buf); if (unlikely(__pyx_t_2 == ((Py_ssize_t)-1))) __PYX_ERR(0, 337, __pyx_L1_error)
      __pyx_t_3 = PyInt_FromSsize_t(__pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 337, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_4 = PyUnicode_Format(__pyx_kp_u_invalid_buffer_size_s_is_not_a_m_2, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 337, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      PyErr_SetObject(PyExc_AssertionError, __pyx_t_4);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __PYX_ERR(0, 337, __pyx_L1_error)
    }
  }
  #endif
+338:     assert as_buffer(buf, <const void **>&argb, &argb_len)==0
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  if (unlikely(!Py_OptimizeFlag)) {
    __pyx_t_5 = __pyx_f_4xpra_6codecs_4argb_4argb_as_buffer(__pyx_v_buf, ((void const **)(&__pyx_v_argb)), (&__pyx_v_argb_len)); if (unlikely(__pyx_t_5 == ((int)-1))) __PYX_ERR(0, 338, __pyx_L1_error)
    if (unlikely(!((__pyx_t_5 == 0) != 0))) {
      PyErr_SetNone(PyExc_AssertionError);
      __PYX_ERR(0, 338, __pyx_L1_error)
    }
  }
  #endif
+339:     return do_unpremultiply_argb(argb, argb_len)
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_4 = __pyx_f_4xpra_6codecs_4argb_4argb_do_unpremultiply_argb(__pyx_v_argb, __pyx_v_argb_len); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 339, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_r = __pyx_t_4;
  __pyx_t_4 = 0;
  goto __pyx_L0;
 340: 
 341: 
 342: #precalculate indexes in native endianness:
+343: tmp = struct.pack(b"=L", 0 + 1*(2**8) + 2*(2**16) + 3*(2**24))
  __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_struct); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 343, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_pack); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 343, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_tuple__28, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 343, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_tmp, __pyx_t_1) < 0) __PYX_ERR(0, 343, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
/* … */
  __pyx_tuple__28 = PyTuple_Pack(2, __pyx_kp_b_L, __pyx_int_50462976); if (unlikely(!__pyx_tuple__28)) __PYX_ERR(0, 343, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__28);
  __Pyx_GIVEREF(__pyx_tuple__28);
 344: #little endian will give 0, 1, 2, 3
 345: #big endian should give 3, 2, 1, 0 (untested)
+346: cdef unsigned char B = tmp.index(b'\0')
  __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_tmp); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 346, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_index); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 346, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_tuple__30, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 346, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_3 = __Pyx_PyInt_As_unsigned_char(__pyx_t_1); if (unlikely((__pyx_t_3 == (unsigned char)-1) && PyErr_Occurred())) __PYX_ERR(0, 346, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_4xpra_6codecs_4argb_4argb_B = __pyx_t_3;
/* … */
  __pyx_tuple__30 = PyTuple_Pack(1, __pyx_kp_b__29); if (unlikely(!__pyx_tuple__30)) __PYX_ERR(0, 346, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__30);
  __Pyx_GIVEREF(__pyx_tuple__30);
+347: cdef unsigned char G = tmp.index(b'\1')
  __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_tmp); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 347, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_index); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 347, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_tuple__32, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 347, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_3 = __Pyx_PyInt_As_unsigned_char(__pyx_t_1); if (unlikely((__pyx_t_3 == (unsigned char)-1) && PyErr_Occurred())) __PYX_ERR(0, 347, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_4xpra_6codecs_4argb_4argb_G = __pyx_t_3;
/* … */
  __pyx_tuple__32 = PyTuple_Pack(1, __pyx_kp_b__31); if (unlikely(!__pyx_tuple__32)) __PYX_ERR(0, 347, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__32);
  __Pyx_GIVEREF(__pyx_tuple__32);
+348: cdef unsigned char R = tmp.index(b'\2')
  __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_tmp); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 348, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_index); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 348, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_tuple__34, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 348, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_3 = __Pyx_PyInt_As_unsigned_char(__pyx_t_1); if (unlikely((__pyx_t_3 == (unsigned char)-1) && PyErr_Occurred())) __PYX_ERR(0, 348, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_4xpra_6codecs_4argb_4argb_R = __pyx_t_3;
/* … */
  __pyx_tuple__34 = PyTuple_Pack(1, __pyx_kp_b__33); if (unlikely(!__pyx_tuple__34)) __PYX_ERR(0, 348, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__34);
  __Pyx_GIVEREF(__pyx_tuple__34);
+349: cdef unsigned char A = tmp.index(b'\3')
  __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_tmp); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 349, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_index); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 349, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_tuple__36, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 349, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_3 = __Pyx_PyInt_As_unsigned_char(__pyx_t_1); if (unlikely((__pyx_t_3 == (unsigned char)-1) && PyErr_Occurred())) __PYX_ERR(0, 349, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_4xpra_6codecs_4argb_4argb_A = __pyx_t_3;
/* … */
  __pyx_tuple__36 = PyTuple_Pack(1, __pyx_kp_b__35); if (unlikely(!__pyx_tuple__36)) __PYX_ERR(0, 349, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__36);
  __Pyx_GIVEREF(__pyx_tuple__36);
 350: 
+351: cdef do_unpremultiply_argb(unsigned int * argb_in, Py_ssize_t argb_len):
static PyObject *__pyx_f_4xpra_6codecs_4argb_4argb_do_unpremultiply_argb(unsigned int *__pyx_v_argb_in, Py_ssize_t __pyx_v_argb_len) {
  unsigned char __pyx_v_a;
  unsigned char __pyx_v_r;
  unsigned char __pyx_v_g;
  unsigned char __pyx_v_b;
  unsigned int __pyx_v_argb;
  struct __pyx_obj_4xpra_7buffers_6membuf_MemBuf *__pyx_v_output_buf = 0;
  unsigned char *__pyx_v_argb_out;
  int __pyx_v_i;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("do_unpremultiply_argb", 0);
/* … */
  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("xpra.codecs.argb.argb.do_unpremultiply_argb", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_output_buf);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
 352:     # cbuf contains non-premultiplied ARGB32 data in native-endian.
 353:     # We convert to premultiplied ARGB32 data
 354:     cdef unsigned char a, r, g, b                #@DuplicateSignature
 355:     cdef unsigned int argb                      #@DuplicateSignature
+356:     assert argb_len>0 and argb_len % 4 == 0, "invalid buffer size: %s is not a multiple of 4" % argb_len
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  if (unlikely(!Py_OptimizeFlag)) {
    __pyx_t_2 = ((__pyx_v_argb_len > 0) != 0);
    if (__pyx_t_2) {
    } else {
      __pyx_t_1 = __pyx_t_2;
      goto __pyx_L3_bool_binop_done;
    }
    __pyx_t_2 = (((__pyx_v_argb_len % 4) == 0) != 0);
    __pyx_t_1 = __pyx_t_2;
    __pyx_L3_bool_binop_done:;
    if (unlikely(!__pyx_t_1)) {
      __pyx_t_3 = PyInt_FromSsize_t(__pyx_v_argb_len); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 356, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_4 = PyUnicode_Format(__pyx_kp_u_invalid_buffer_size_s_is_not_a_m_2, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 356, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      PyErr_SetObject(PyExc_AssertionError, __pyx_t_4);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __PYX_ERR(0, 356, __pyx_L1_error)
    }
  }
  #endif
+357:     cdef MemBuf output_buf = getbuf(argb_len)
  __pyx_t_4 = __pyx_f_4xpra_7buffers_6membuf_getbuf(__pyx_v_argb_len); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 357, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  if (!(likely(((__pyx_t_4) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_4, __pyx_ptype_4xpra_7buffers_6membuf_MemBuf))))) __PYX_ERR(0, 357, __pyx_L1_error)
  __pyx_v_output_buf = ((struct __pyx_obj_4xpra_7buffers_6membuf_MemBuf *)__pyx_t_4);
  __pyx_t_4 = 0;
+358:     cdef unsigned char* argb_out = <unsigned char*> output_buf.get_mem()
  __pyx_v_argb_out = ((unsigned char *)((struct __pyx_vtabstruct_4xpra_7buffers_6membuf_MemBuf *)__pyx_v_output_buf->__pyx_vtab)->get_mem(__pyx_v_output_buf));
 359:     cdef int i                                  #@DuplicateSignature
+360:     for 0 <= i < argb_len // 4:
  __pyx_t_5 = (__pyx_v_argb_len / 4);
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_5; __pyx_v_i++) {
+361:         argb = argb_in[i]
    __pyx_v_argb = (__pyx_v_argb_in[__pyx_v_i]);
+362:         a = (argb >> 24) & 0xff
    __pyx_v_a = ((__pyx_v_argb >> 24) & 0xff);
+363:         r = (argb >> 16) & 0xff
    __pyx_v_r = ((__pyx_v_argb >> 16) & 0xff);
+364:         g = (argb >> 8) & 0xff
    __pyx_v_g = ((__pyx_v_argb >> 8) & 0xff);
+365:         b = (argb >> 0) & 0xff
    __pyx_v_b = ((__pyx_v_argb >> 0) & 0xff);
+366:         if a!=0:
    __pyx_t_1 = ((__pyx_v_a != 0) != 0);
    if (__pyx_t_1) {
/* … */
      goto __pyx_L7;
    }
+367:             r = clamp(r * 255 // a)
      __pyx_v_r = __pyx_f_4xpra_6codecs_4argb_4argb_clamp(((__pyx_v_r * 0xFF) / __pyx_v_a));
+368:             g = clamp(g * 255 // a)
      __pyx_v_g = __pyx_f_4xpra_6codecs_4argb_4argb_clamp(((__pyx_v_g * 0xFF) / __pyx_v_a));
+369:             b = clamp(b * 255 // a)
      __pyx_v_b = __pyx_f_4xpra_6codecs_4argb_4argb_clamp(((__pyx_v_b * 0xFF) / __pyx_v_a));
 370:         else:
+371:             r = 0
    /*else*/ {
      __pyx_v_r = 0;
+372:             g = 0
      __pyx_v_g = 0;
+373:             b = 0
      __pyx_v_b = 0;
    }
    __pyx_L7:;
 374:         #we could use struct pack to avoid endianness issues
 375:         #but this is python 2.5 onwards only and is probably slower:
 376:         #struct.pack_into(b"=BBBB", argb_out, i*4, b, g, r, a)
+377:         argb_out[i*4+B] = b
    (__pyx_v_argb_out[((__pyx_v_i * 4) + __pyx_v_4xpra_6codecs_4argb_4argb_B)]) = __pyx_v_b;
+378:         argb_out[i*4+G] = g
    (__pyx_v_argb_out[((__pyx_v_i * 4) + __pyx_v_4xpra_6codecs_4argb_4argb_G)]) = __pyx_v_g;
+379:         argb_out[i*4+R] = r
    (__pyx_v_argb_out[((__pyx_v_i * 4) + __pyx_v_4xpra_6codecs_4argb_4argb_R)]) = __pyx_v_r;
+380:         argb_out[i*4+A] = a
    (__pyx_v_argb_out[((__pyx_v_i * 4) + __pyx_v_4xpra_6codecs_4argb_4argb_A)]) = __pyx_v_a;
  }
+381:     return memoryview(output_buf)
  __Pyx_XDECREF(__pyx_r);
  __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_memoryview); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 381, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_4, ((PyObject *)__pyx_v_output_buf)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 381, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_r = __pyx_t_3;
  __pyx_t_3 = 0;
  goto __pyx_L0;
 382: 
 383: 
+384: def argb_swap(image, rgb_formats, supports_transparency):
/* Python wrapper */
static PyObject *__pyx_pw_4xpra_6codecs_4argb_4argb_27argb_swap(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4xpra_6codecs_4argb_4argb_26argb_swap[] = " use the argb codec to do the RGB byte swapping ";
static PyMethodDef __pyx_mdef_4xpra_6codecs_4argb_4argb_27argb_swap = {"argb_swap", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4xpra_6codecs_4argb_4argb_27argb_swap, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4xpra_6codecs_4argb_4argb_26argb_swap};
static PyObject *__pyx_pw_4xpra_6codecs_4argb_4argb_27argb_swap(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_image = 0;
  PyObject *__pyx_v_rgb_formats = 0;
  PyObject *__pyx_v_supports_transparency = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("argb_swap (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_image,&__pyx_n_s_rgb_formats,&__pyx_n_s_supports_transparency,0};
    PyObject* values[3] = {0,0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_image)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_rgb_formats)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("argb_swap", 1, 3, 3, 1); __PYX_ERR(0, 384, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_supports_transparency)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("argb_swap", 1, 3, 3, 2); __PYX_ERR(0, 384, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "argb_swap") < 0)) __PYX_ERR(0, 384, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 3) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
    }
    __pyx_v_image = values[0];
    __pyx_v_rgb_formats = values[1];
    __pyx_v_supports_transparency = values[2];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("argb_swap", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 384, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("xpra.codecs.argb.argb.argb_swap", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4xpra_6codecs_4argb_4argb_26argb_swap(__pyx_self, __pyx_v_image, __pyx_v_rgb_formats, __pyx_v_supports_transparency);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4xpra_6codecs_4argb_4argb_26argb_swap(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_image, PyObject *__pyx_v_rgb_formats, PyObject *__pyx_v_supports_transparency) {
  PyObject *__pyx_v_pixel_format = NULL;
  PyObject *__pyx_v_pixels = NULL;
  PyObject *__pyx_v_rs = NULL;
  PyObject *__pyx_v_warning_key = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("argb_swap", 0);
/* … */
  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("xpra.codecs.argb.argb.argb_swap", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_pixel_format);
  __Pyx_XDECREF(__pyx_v_pixels);
  __Pyx_XDECREF(__pyx_v_rs);
  __Pyx_XDECREF(__pyx_v_warning_key);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
/* … */
  __pyx_tuple__37 = PyTuple_Pack(7, __pyx_n_s_image, __pyx_n_s_rgb_formats, __pyx_n_s_supports_transparency, __pyx_n_s_pixel_format, __pyx_n_s_pixels, __pyx_n_s_rs, __pyx_n_s_warning_key); if (unlikely(!__pyx_tuple__37)) __PYX_ERR(0, 384, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__37);
  __Pyx_GIVEREF(__pyx_tuple__37);
/* … */
  __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_4xpra_6codecs_4argb_4argb_27argb_swap, NULL, __pyx_n_s_xpra_codecs_argb_argb); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 384, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_argb_swap, __pyx_t_1) < 0) __PYX_ERR(0, 384, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
 385:     """ use the argb codec to do the RGB byte swapping """
+386:     pixel_format = bytestostr(image.get_pixel_format())
  __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_bytestostr); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 386, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_image, __pyx_n_s_get_pixel_format); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 386, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
    __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
    if (likely(__pyx_t_5)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
      __Pyx_INCREF(__pyx_t_5);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_4, function);
    }
  }
  __pyx_t_3 = (__pyx_t_5) ? __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_5) : __Pyx_PyObject_CallNoArg(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
  if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 386, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_4)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  __pyx_t_1 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_4, __pyx_t_3) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 386, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_pixel_format = __pyx_t_1;
  __pyx_t_1 = 0;
 387:     #try to fallback to argb module
 388:     #if we have one of the target pixel formats:
+389:     pixels = image.get_pixels()
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_image, __pyx_n_s_get_pixels); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 389, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  __pyx_t_1 = (__pyx_t_3) ? __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3) : __Pyx_PyObject_CallNoArg(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 389, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_pixels = __pyx_t_1;
  __pyx_t_1 = 0;
+390:     assert pixels, "failed to get pixels from %s" % image
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  if (unlikely(!Py_OptimizeFlag)) {
    __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_v_pixels); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(0, 390, __pyx_L1_error)
    if (unlikely(!__pyx_t_6)) {
      __pyx_t_1 = __Pyx_PyUnicode_FormatSafe(__pyx_kp_u_failed_to_get_pixels_from_s, __pyx_v_image); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 390, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      PyErr_SetObject(PyExc_AssertionError, __pyx_t_1);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __PYX_ERR(0, 390, __pyx_L1_error)
    }
  }
  #endif
+391:     rs = image.get_rowstride()
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_image, __pyx_n_s_get_rowstride); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 391, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  __pyx_t_1 = (__pyx_t_3) ? __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3) : __Pyx_PyObject_CallNoArg(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 391, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_rs = __pyx_t_1;
  __pyx_t_1 = 0;
+392:     if pixel_format=="r210":
  __pyx_t_6 = (__Pyx_PyUnicode_Equals(__pyx_v_pixel_format, __pyx_n_u_r210, Py_EQ)); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(0, 392, __pyx_L1_error)
  if (__pyx_t_6) {
/* … */
    goto __pyx_L3;
  }
 393:         #r210 never contains any transparency at present
 394:         #if supports_transparency and "RGBA" in rgb_formats:
 395:         #    log("argb_swap: r210_to_rgba for %s on %s", pixel_format, type(pixels))
 396:         #    image.set_pixels(r210_to_rgba(pixels))
 397:         #    image.set_pixel_format("RGBA")
 398:         #    return True
+399:         if "RGB" in rgb_formats:
    __pyx_t_6 = (__Pyx_PySequence_ContainsTF(__pyx_n_u_RGB, __pyx_v_rgb_formats, Py_EQ)); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(0, 399, __pyx_L1_error)
    __pyx_t_7 = (__pyx_t_6 != 0);
    if (__pyx_t_7) {
/* … */
    }
+400:             log("argb_swap: r210_to_rgb for %s on %s", pixel_format, type(pixels))
      __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_log); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 400, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_3 = NULL;
      __pyx_t_8 = 0;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
        __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
        if (likely(__pyx_t_3)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
          __Pyx_INCREF(__pyx_t_3);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_2, function);
          __pyx_t_8 = 1;
        }
      }
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_2)) {
        PyObject *__pyx_temp[4] = {__pyx_t_3, __pyx_kp_u_argb_swap_r210_to_rgb_for_s_on_s, __pyx_v_pixel_format, ((PyObject *)Py_TYPE(__pyx_v_pixels))};
        __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_8, 3+__pyx_t_8); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 400, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
        __Pyx_GOTREF(__pyx_t_1);
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
        PyObject *__pyx_temp[4] = {__pyx_t_3, __pyx_kp_u_argb_swap_r210_to_rgb_for_s_on_s, __pyx_v_pixel_format, ((PyObject *)Py_TYPE(__pyx_v_pixels))};
        __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_8, 3+__pyx_t_8); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 400, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
        __Pyx_GOTREF(__pyx_t_1);
      } else
      #endif
      {
        __pyx_t_4 = PyTuple_New(3+__pyx_t_8); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 400, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        if (__pyx_t_3) {
          __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3); __pyx_t_3 = NULL;
        }
        __Pyx_INCREF(__pyx_kp_u_argb_swap_r210_to_rgb_for_s_on_s);
        __Pyx_GIVEREF(__pyx_kp_u_argb_swap_r210_to_rgb_for_s_on_s);
        PyTuple_SET_ITEM(__pyx_t_4, 0+__pyx_t_8, __pyx_kp_u_argb_swap_r210_to_rgb_for_s_on_s);
        __Pyx_INCREF(__pyx_v_pixel_format);
        __Pyx_GIVEREF(__pyx_v_pixel_format);
        PyTuple_SET_ITEM(__pyx_t_4, 1+__pyx_t_8, __pyx_v_pixel_format);
        __Pyx_INCREF(((PyObject *)Py_TYPE(__pyx_v_pixels)));
        __Pyx_GIVEREF(((PyObject *)Py_TYPE(__pyx_v_pixels)));
        PyTuple_SET_ITEM(__pyx_t_4, 2+__pyx_t_8, ((PyObject *)Py_TYPE(__pyx_v_pixels)));
        __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 400, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      }
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+401:             image.set_pixels(r210_to_rgb(pixels))
      __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_image, __pyx_n_s_set_pixels); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 401, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_r210_to_rgb); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 401, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_5 = NULL;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
        __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_3);
        if (likely(__pyx_t_5)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
          __Pyx_INCREF(__pyx_t_5);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_3, function);
        }
      }
      __pyx_t_4 = (__pyx_t_5) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_5, __pyx_v_pixels) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_pixels);
      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
      if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 401, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_3 = NULL;
      if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
        __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
        if (likely(__pyx_t_3)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
          __Pyx_INCREF(__pyx_t_3);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_2, function);
        }
      }
      __pyx_t_1 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_3, __pyx_t_4) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_4);
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 401, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+402:             image.set_pixel_format("RGB")
      __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_image, __pyx_n_s_set_pixel_format); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 402, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_4 = NULL;
      if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
        __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_2);
        if (likely(__pyx_t_4)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
          __Pyx_INCREF(__pyx_t_4);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_2, function);
        }
      }
      __pyx_t_1 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_4, __pyx_n_u_RGB) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_n_u_RGB);
      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
      if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 402, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+403:             image.set_rowstride(rs*3//4)
      __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_image, __pyx_n_s_set_rowstride); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 403, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_4 = PyNumber_Multiply(__pyx_v_rs, __pyx_int_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 403, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_3 = __Pyx_PyInt_FloorDivideObjC(__pyx_t_4, __pyx_int_4, 4, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 403, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_4 = NULL;
      if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
        __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_2);
        if (likely(__pyx_t_4)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
          __Pyx_INCREF(__pyx_t_4);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_2, function);
        }
      }
      __pyx_t_1 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_4, __pyx_t_3) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3);
      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 403, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+404:             return True
      __Pyx_XDECREF(__pyx_r);
      __Pyx_INCREF(Py_True);
      __pyx_r = Py_True;
      goto __pyx_L0;
+405:         if "RGBX" in rgb_formats:
    __pyx_t_7 = (__Pyx_PySequence_ContainsTF(__pyx_n_u_RGBX, __pyx_v_rgb_formats, Py_EQ)); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 405, __pyx_L1_error)
    __pyx_t_6 = (__pyx_t_7 != 0);
    if (__pyx_t_6) {
/* … */
    }
+406:             log("argb_swap: r210_to_rgbx for %s on %s", pixel_format, type(pixels))
      __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_log); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 406, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_3 = NULL;
      __pyx_t_8 = 0;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
        __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
        if (likely(__pyx_t_3)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
          __Pyx_INCREF(__pyx_t_3);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_2, function);
          __pyx_t_8 = 1;
        }
      }
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_2)) {
        PyObject *__pyx_temp[4] = {__pyx_t_3, __pyx_kp_u_argb_swap_r210_to_rgbx_for_s_on, __pyx_v_pixel_format, ((PyObject *)Py_TYPE(__pyx_v_pixels))};
        __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_8, 3+__pyx_t_8); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 406, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
        __Pyx_GOTREF(__pyx_t_1);
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
        PyObject *__pyx_temp[4] = {__pyx_t_3, __pyx_kp_u_argb_swap_r210_to_rgbx_for_s_on, __pyx_v_pixel_format, ((PyObject *)Py_TYPE(__pyx_v_pixels))};
        __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_8, 3+__pyx_t_8); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 406, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
        __Pyx_GOTREF(__pyx_t_1);
      } else
      #endif
      {
        __pyx_t_4 = PyTuple_New(3+__pyx_t_8); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 406, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        if (__pyx_t_3) {
          __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3); __pyx_t_3 = NULL;
        }
        __Pyx_INCREF(__pyx_kp_u_argb_swap_r210_to_rgbx_for_s_on);
        __Pyx_GIVEREF(__pyx_kp_u_argb_swap_r210_to_rgbx_for_s_on);
        PyTuple_SET_ITEM(__pyx_t_4, 0+__pyx_t_8, __pyx_kp_u_argb_swap_r210_to_rgbx_for_s_on);
        __Pyx_INCREF(__pyx_v_pixel_format);
        __Pyx_GIVEREF(__pyx_v_pixel_format);
        PyTuple_SET_ITEM(__pyx_t_4, 1+__pyx_t_8, __pyx_v_pixel_format);
        __Pyx_INCREF(((PyObject *)Py_TYPE(__pyx_v_pixels)));
        __Pyx_GIVEREF(((PyObject *)Py_TYPE(__pyx_v_pixels)));
        PyTuple_SET_ITEM(__pyx_t_4, 2+__pyx_t_8, ((PyObject *)Py_TYPE(__pyx_v_pixels)));
        __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 406, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      }
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+407:             image.set_pixels(r210_to_rgbx(pixels))
      __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_image, __pyx_n_s_set_pixels); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 407, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_r210_to_rgbx); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 407, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_5 = NULL;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
        __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_3);
        if (likely(__pyx_t_5)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
          __Pyx_INCREF(__pyx_t_5);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_3, function);
        }
      }
      __pyx_t_4 = (__pyx_t_5) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_5, __pyx_v_pixels) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_pixels);
      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
      if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 407, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_3 = NULL;
      if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
        __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
        if (likely(__pyx_t_3)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
          __Pyx_INCREF(__pyx_t_3);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_2, function);
        }
      }
      __pyx_t_1 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_3, __pyx_t_4) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_4);
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 407, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+408:             image.set_pixel_format("RGBX")
      __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_image, __pyx_n_s_set_pixel_format); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 408, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_4 = NULL;
      if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
        __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_2);
        if (likely(__pyx_t_4)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
          __Pyx_INCREF(__pyx_t_4);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_2, function);
        }
      }
      __pyx_t_1 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_4, __pyx_n_u_RGBX) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_n_u_RGBX);
      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
      if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 408, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+409:             return True
      __Pyx_XDECREF(__pyx_r);
      __Pyx_INCREF(Py_True);
      __pyx_r = Py_True;
      goto __pyx_L0;
+410:     elif pixel_format=="BGR565":
  __pyx_t_6 = (__Pyx_PyUnicode_Equals(__pyx_v_pixel_format, __pyx_n_u_BGR565, Py_EQ)); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(0, 410, __pyx_L1_error)
  if (__pyx_t_6) {
/* … */
    goto __pyx_L3;
  }
+411:         if "RGB" in rgb_formats:
    __pyx_t_6 = (__Pyx_PySequence_ContainsTF(__pyx_n_u_RGB, __pyx_v_rgb_formats, Py_EQ)); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(0, 411, __pyx_L1_error)
    __pyx_t_7 = (__pyx_t_6 != 0);
    if (__pyx_t_7) {
/* … */
    }
+412:             log("argb_swap: bgr565_to_rgb for %s on %s", pixel_format, type(pixels))
      __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_log); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 412, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_4 = NULL;
      __pyx_t_8 = 0;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
        __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_2);
        if (likely(__pyx_t_4)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
          __Pyx_INCREF(__pyx_t_4);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_2, function);
          __pyx_t_8 = 1;
        }
      }
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_2)) {
        PyObject *__pyx_temp[4] = {__pyx_t_4, __pyx_kp_u_argb_swap_bgr565_to_rgb_for_s_on, __pyx_v_pixel_format, ((PyObject *)Py_TYPE(__pyx_v_pixels))};
        __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_8, 3+__pyx_t_8); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 412, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_GOTREF(__pyx_t_1);
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
        PyObject *__pyx_temp[4] = {__pyx_t_4, __pyx_kp_u_argb_swap_bgr565_to_rgb_for_s_on, __pyx_v_pixel_format, ((PyObject *)Py_TYPE(__pyx_v_pixels))};
        __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_8, 3+__pyx_t_8); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 412, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_GOTREF(__pyx_t_1);
      } else
      #endif
      {
        __pyx_t_3 = PyTuple_New(3+__pyx_t_8); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 412, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        if (__pyx_t_4) {
          __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_4); __pyx_t_4 = NULL;
        }
        __Pyx_INCREF(__pyx_kp_u_argb_swap_bgr565_to_rgb_for_s_on);
        __Pyx_GIVEREF(__pyx_kp_u_argb_swap_bgr565_to_rgb_for_s_on);
        PyTuple_SET_ITEM(__pyx_t_3, 0+__pyx_t_8, __pyx_kp_u_argb_swap_bgr565_to_rgb_for_s_on);
        __Pyx_INCREF(__pyx_v_pixel_format);
        __Pyx_GIVEREF(__pyx_v_pixel_format);
        PyTuple_SET_ITEM(__pyx_t_3, 1+__pyx_t_8, __pyx_v_pixel_format);
        __Pyx_INCREF(((PyObject *)Py_TYPE(__pyx_v_pixels)));
        __Pyx_GIVEREF(((PyObject *)Py_TYPE(__pyx_v_pixels)));
        PyTuple_SET_ITEM(__pyx_t_3, 2+__pyx_t_8, ((PyObject *)Py_TYPE(__pyx_v_pixels)));
        __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_3, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 412, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      }
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+413:             image.set_pixels(bgr565_to_rgb(pixels))
      __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_image, __pyx_n_s_set_pixels); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 413, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_bgr565_to_rgb); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 413, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_5 = NULL;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) {
        __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
        if (likely(__pyx_t_5)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
          __Pyx_INCREF(__pyx_t_5);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_4, function);
        }
      }
      __pyx_t_3 = (__pyx_t_5) ? __Pyx_PyObject_Call2Args(__pyx_t_4, __pyx_t_5, __pyx_v_pixels) : __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_v_pixels);
      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
      if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 413, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_4 = NULL;
      if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
        __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_2);
        if (likely(__pyx_t_4)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
          __Pyx_INCREF(__pyx_t_4);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_2, function);
        }
      }
      __pyx_t_1 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_4, __pyx_t_3) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3);
      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 413, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+414:             image.set_pixel_format("RGB")
      __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_image, __pyx_n_s_set_pixel_format); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 414, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_3 = NULL;
      if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
        __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
        if (likely(__pyx_t_3)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
          __Pyx_INCREF(__pyx_t_3);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_2, function);
        }
      }
      __pyx_t_1 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_3, __pyx_n_u_RGB) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_n_u_RGB);
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 414, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+415:             image.set_rowstride(rs*3//2)
      __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_image, __pyx_n_s_set_rowstride); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 415, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_3 = PyNumber_Multiply(__pyx_v_rs, __pyx_int_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 415, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_4 = __Pyx_PyInt_FloorDivideObjC(__pyx_t_3, __pyx_int_2, 2, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 415, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_3 = NULL;
      if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
        __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
        if (likely(__pyx_t_3)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
          __Pyx_INCREF(__pyx_t_3);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_2, function);
        }
      }
      __pyx_t_1 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_3, __pyx_t_4) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_4);
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 415, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+416:             return True
      __Pyx_XDECREF(__pyx_r);
      __Pyx_INCREF(Py_True);
      __pyx_r = Py_True;
      goto __pyx_L0;
+417:         if "RGBX" in rgb_formats:
    __pyx_t_7 = (__Pyx_PySequence_ContainsTF(__pyx_n_u_RGBX, __pyx_v_rgb_formats, Py_EQ)); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 417, __pyx_L1_error)
    __pyx_t_6 = (__pyx_t_7 != 0);
    if (__pyx_t_6) {
/* … */
    }
+418:             log("argb_swap: bgr565_to_rgbx for %s on %s", pixel_format, type(pixels))
      __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_log); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 418, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_4 = NULL;
      __pyx_t_8 = 0;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
        __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_2);
        if (likely(__pyx_t_4)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
          __Pyx_INCREF(__pyx_t_4);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_2, function);
          __pyx_t_8 = 1;
        }
      }
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_2)) {
        PyObject *__pyx_temp[4] = {__pyx_t_4, __pyx_kp_u_argb_swap_bgr565_to_rgbx_for_s_o, __pyx_v_pixel_format, ((PyObject *)Py_TYPE(__pyx_v_pixels))};
        __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_8, 3+__pyx_t_8); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 418, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_GOTREF(__pyx_t_1);
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
        PyObject *__pyx_temp[4] = {__pyx_t_4, __pyx_kp_u_argb_swap_bgr565_to_rgbx_for_s_o, __pyx_v_pixel_format, ((PyObject *)Py_TYPE(__pyx_v_pixels))};
        __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_8, 3+__pyx_t_8); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 418, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_GOTREF(__pyx_t_1);
      } else
      #endif
      {
        __pyx_t_3 = PyTuple_New(3+__pyx_t_8); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 418, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        if (__pyx_t_4) {
          __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_4); __pyx_t_4 = NULL;
        }
        __Pyx_INCREF(__pyx_kp_u_argb_swap_bgr565_to_rgbx_for_s_o);
        __Pyx_GIVEREF(__pyx_kp_u_argb_swap_bgr565_to_rgbx_for_s_o);
        PyTuple_SET_ITEM(__pyx_t_3, 0+__pyx_t_8, __pyx_kp_u_argb_swap_bgr565_to_rgbx_for_s_o);
        __Pyx_INCREF(__pyx_v_pixel_format);
        __Pyx_GIVEREF(__pyx_v_pixel_format);
        PyTuple_SET_ITEM(__pyx_t_3, 1+__pyx_t_8, __pyx_v_pixel_format);
        __Pyx_INCREF(((PyObject *)Py_TYPE(__pyx_v_pixels)));
        __Pyx_GIVEREF(((PyObject *)Py_TYPE(__pyx_v_pixels)));
        PyTuple_SET_ITEM(__pyx_t_3, 2+__pyx_t_8, ((PyObject *)Py_TYPE(__pyx_v_pixels)));
        __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_3, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 418, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      }
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+419:             image.set_pixels(bgr565_to_rgbx(pixels))
      __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_image, __pyx_n_s_set_pixels); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 419, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_bgr565_to_rgbx); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 419, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_5 = NULL;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) {
        __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
        if (likely(__pyx_t_5)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
          __Pyx_INCREF(__pyx_t_5);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_4, function);
        }
      }
      __pyx_t_3 = (__pyx_t_5) ? __Pyx_PyObject_Call2Args(__pyx_t_4, __pyx_t_5, __pyx_v_pixels) : __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_v_pixels);
      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
      if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 419, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_4 = NULL;
      if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
        __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_2);
        if (likely(__pyx_t_4)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
          __Pyx_INCREF(__pyx_t_4);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_2, function);
        }
      }
      __pyx_t_1 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_4, __pyx_t_3) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3);
      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 419, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+420:             image.set_pixel_format("RGBX")
      __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_image, __pyx_n_s_set_pixel_format); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 420, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_3 = NULL;
      if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
        __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
        if (likely(__pyx_t_3)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
          __Pyx_INCREF(__pyx_t_3);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_2, function);
        }
      }
      __pyx_t_1 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_3, __pyx_n_u_RGBX) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_n_u_RGBX);
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 420, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+421:             image.set_rowstride(rs*2)
      __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_image, __pyx_n_s_set_rowstride); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 421, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_3 = PyNumber_Multiply(__pyx_v_rs, __pyx_int_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 421, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_4 = NULL;
      if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
        __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_2);
        if (likely(__pyx_t_4)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
          __Pyx_INCREF(__pyx_t_4);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_2, function);
        }
      }
      __pyx_t_1 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_4, __pyx_t_3) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3);
      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 421, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+422:             return True
      __Pyx_XDECREF(__pyx_r);
      __Pyx_INCREF(Py_True);
      __pyx_r = Py_True;
      goto __pyx_L0;
+423:     elif pixel_format in ("BGRX", "BGRA"):
  __Pyx_INCREF(__pyx_v_pixel_format);
  __pyx_t_1 = __pyx_v_pixel_format;
  __pyx_t_7 = (__Pyx_PyUnicode_Equals(__pyx_t_1, __pyx_n_u_BGRX, Py_EQ)); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 423, __pyx_L1_error)
  if (!__pyx_t_7) {
  } else {
    __pyx_t_6 = __pyx_t_7;
    goto __pyx_L8_bool_binop_done;
  }
  __pyx_t_7 = (__Pyx_PyUnicode_Equals(__pyx_t_1, __pyx_n_u_BGRA, Py_EQ)); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 423, __pyx_L1_error)
  __pyx_t_6 = __pyx_t_7;
  __pyx_L8_bool_binop_done:;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_7 = (__pyx_t_6 != 0);
  if (__pyx_t_7) {
/* … */
    goto __pyx_L3;
  }
+424:         if supports_transparency and "RGBA" in rgb_formats:
    __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_v_supports_transparency); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(0, 424, __pyx_L1_error)
    if (__pyx_t_6) {
    } else {
      __pyx_t_7 = __pyx_t_6;
      goto __pyx_L11_bool_binop_done;
    }
    __pyx_t_6 = (__Pyx_PySequence_ContainsTF(__pyx_n_u_RGBA, __pyx_v_rgb_formats, Py_EQ)); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(0, 424, __pyx_L1_error)
    __pyx_t_9 = (__pyx_t_6 != 0);
    __pyx_t_7 = __pyx_t_9;
    __pyx_L11_bool_binop_done:;
    if (__pyx_t_7) {
/* … */
    }
+425:             log("argb_swap: bgra_to_rgba for %s on %s", pixel_format, type(pixels))
      __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_log); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 425, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_3 = NULL;
      __pyx_t_8 = 0;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
        __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
        if (likely(__pyx_t_3)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
          __Pyx_INCREF(__pyx_t_3);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_2, function);
          __pyx_t_8 = 1;
        }
      }
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_2)) {
        PyObject *__pyx_temp[4] = {__pyx_t_3, __pyx_kp_u_argb_swap_bgra_to_rgba_for_s_on, __pyx_v_pixel_format, ((PyObject *)Py_TYPE(__pyx_v_pixels))};
        __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_8, 3+__pyx_t_8); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 425, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
        __Pyx_GOTREF(__pyx_t_1);
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
        PyObject *__pyx_temp[4] = {__pyx_t_3, __pyx_kp_u_argb_swap_bgra_to_rgba_for_s_on, __pyx_v_pixel_format, ((PyObject *)Py_TYPE(__pyx_v_pixels))};
        __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_8, 3+__pyx_t_8); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 425, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
        __Pyx_GOTREF(__pyx_t_1);
      } else
      #endif
      {
        __pyx_t_4 = PyTuple_New(3+__pyx_t_8); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 425, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        if (__pyx_t_3) {
          __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3); __pyx_t_3 = NULL;
        }
        __Pyx_INCREF(__pyx_kp_u_argb_swap_bgra_to_rgba_for_s_on);
        __Pyx_GIVEREF(__pyx_kp_u_argb_swap_bgra_to_rgba_for_s_on);
        PyTuple_SET_ITEM(__pyx_t_4, 0+__pyx_t_8, __pyx_kp_u_argb_swap_bgra_to_rgba_for_s_on);
        __Pyx_INCREF(__pyx_v_pixel_format);
        __Pyx_GIVEREF(__pyx_v_pixel_format);
        PyTuple_SET_ITEM(__pyx_t_4, 1+__pyx_t_8, __pyx_v_pixel_format);
        __Pyx_INCREF(((PyObject *)Py_TYPE(__pyx_v_pixels)));
        __Pyx_GIVEREF(((PyObject *)Py_TYPE(__pyx_v_pixels)));
        PyTuple_SET_ITEM(__pyx_t_4, 2+__pyx_t_8, ((PyObject *)Py_TYPE(__pyx_v_pixels)));
        __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 425, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      }
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+426:             image.set_pixels(bgra_to_rgba(pixels))
      __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_image, __pyx_n_s_set_pixels); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 426, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_bgra_to_rgba); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 426, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_5 = NULL;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
        __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_3);
        if (likely(__pyx_t_5)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
          __Pyx_INCREF(__pyx_t_5);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_3, function);
        }
      }
      __pyx_t_4 = (__pyx_t_5) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_5, __pyx_v_pixels) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_pixels);
      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
      if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 426, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_3 = NULL;
      if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
        __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
        if (likely(__pyx_t_3)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
          __Pyx_INCREF(__pyx_t_3);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_2, function);
        }
      }
      __pyx_t_1 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_3, __pyx_t_4) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_4);
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 426, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+427:             image.set_pixel_format("RGBA")
      __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_image, __pyx_n_s_set_pixel_format); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 427, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_4 = NULL;
      if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
        __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_2);
        if (likely(__pyx_t_4)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
          __Pyx_INCREF(__pyx_t_4);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_2, function);
        }
      }
      __pyx_t_1 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_4, __pyx_n_u_RGBA) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_n_u_RGBA);
      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
      if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 427, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+428:             return True
      __Pyx_XDECREF(__pyx_r);
      __Pyx_INCREF(Py_True);
      __pyx_r = Py_True;
      goto __pyx_L0;
+429:         if "RGB" in rgb_formats:
    __pyx_t_7 = (__Pyx_PySequence_ContainsTF(__pyx_n_u_RGB, __pyx_v_rgb_formats, Py_EQ)); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 429, __pyx_L1_error)
    __pyx_t_9 = (__pyx_t_7 != 0);
    if (__pyx_t_9) {
/* … */
    }
+430:             log("argb_swap: bgra_to_rgb for %s on %s", pixel_format, type(pixels))
      __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_log); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 430, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_4 = NULL;
      __pyx_t_8 = 0;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
        __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_2);
        if (likely(__pyx_t_4)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
          __Pyx_INCREF(__pyx_t_4);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_2, function);
          __pyx_t_8 = 1;
        }
      }
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_2)) {
        PyObject *__pyx_temp[4] = {__pyx_t_4, __pyx_kp_u_argb_swap_bgra_to_rgb_for_s_on_s, __pyx_v_pixel_format, ((PyObject *)Py_TYPE(__pyx_v_pixels))};
        __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_8, 3+__pyx_t_8); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 430, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_GOTREF(__pyx_t_1);
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
        PyObject *__pyx_temp[4] = {__pyx_t_4, __pyx_kp_u_argb_swap_bgra_to_rgb_for_s_on_s, __pyx_v_pixel_format, ((PyObject *)Py_TYPE(__pyx_v_pixels))};
        __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_8, 3+__pyx_t_8); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 430, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_GOTREF(__pyx_t_1);
      } else
      #endif
      {
        __pyx_t_3 = PyTuple_New(3+__pyx_t_8); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 430, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        if (__pyx_t_4) {
          __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_4); __pyx_t_4 = NULL;
        }
        __Pyx_INCREF(__pyx_kp_u_argb_swap_bgra_to_rgb_for_s_on_s);
        __Pyx_GIVEREF(__pyx_kp_u_argb_swap_bgra_to_rgb_for_s_on_s);
        PyTuple_SET_ITEM(__pyx_t_3, 0+__pyx_t_8, __pyx_kp_u_argb_swap_bgra_to_rgb_for_s_on_s);
        __Pyx_INCREF(__pyx_v_pixel_format);
        __Pyx_GIVEREF(__pyx_v_pixel_format);
        PyTuple_SET_ITEM(__pyx_t_3, 1+__pyx_t_8, __pyx_v_pixel_format);
        __Pyx_INCREF(((PyObject *)Py_TYPE(__pyx_v_pixels)));
        __Pyx_GIVEREF(((PyObject *)Py_TYPE(__pyx_v_pixels)));
        PyTuple_SET_ITEM(__pyx_t_3, 2+__pyx_t_8, ((PyObject *)Py_TYPE(__pyx_v_pixels)));
        __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_3, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 430, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      }
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+431:             image.set_pixels(bgra_to_rgb(pixels))
      __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_image, __pyx_n_s_set_pixels); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 431, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_bgra_to_rgb); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 431, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_5 = NULL;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) {
        __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
        if (likely(__pyx_t_5)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
          __Pyx_INCREF(__pyx_t_5);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_4, function);
        }
      }
      __pyx_t_3 = (__pyx_t_5) ? __Pyx_PyObject_Call2Args(__pyx_t_4, __pyx_t_5, __pyx_v_pixels) : __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_v_pixels);
      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
      if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 431, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_4 = NULL;
      if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
        __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_2);
        if (likely(__pyx_t_4)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
          __Pyx_INCREF(__pyx_t_4);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_2, function);
        }
      }
      __pyx_t_1 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_4, __pyx_t_3) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3);
      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 431, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+432:             image.set_pixel_format("RGB")
      __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_image, __pyx_n_s_set_pixel_format); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 432, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_3 = NULL;
      if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
        __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
        if (likely(__pyx_t_3)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
          __Pyx_INCREF(__pyx_t_3);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_2, function);
        }
      }
      __pyx_t_1 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_3, __pyx_n_u_RGB) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_n_u_RGB);
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 432, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+433:             image.set_rowstride(rs*3//4)
      __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_image, __pyx_n_s_set_rowstride); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 433, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_3 = PyNumber_Multiply(__pyx_v_rs, __pyx_int_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 433, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_4 = __Pyx_PyInt_FloorDivideObjC(__pyx_t_3, __pyx_int_4, 4, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 433, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_3 = NULL;
      if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
        __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
        if (likely(__pyx_t_3)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
          __Pyx_INCREF(__pyx_t_3);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_2, function);
        }
      }
      __pyx_t_1 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_3, __pyx_t_4) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_4);
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 433, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+434:             return True
      __Pyx_XDECREF(__pyx_r);
      __Pyx_INCREF(Py_True);
      __pyx_r = Py_True;
      goto __pyx_L0;
+435:     elif pixel_format in ("XRGB", "ARGB"):
  __Pyx_INCREF(__pyx_v_pixel_format);
  __pyx_t_1 = __pyx_v_pixel_format;
  __pyx_t_7 = (__Pyx_PyUnicode_Equals(__pyx_t_1, __pyx_n_u_XRGB, Py_EQ)); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 435, __pyx_L1_error)
  if (!__pyx_t_7) {
  } else {
    __pyx_t_9 = __pyx_t_7;
    goto __pyx_L14_bool_binop_done;
  }
  __pyx_t_7 = (__Pyx_PyUnicode_Equals(__pyx_t_1, __pyx_n_u_ARGB, Py_EQ)); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 435, __pyx_L1_error)
  __pyx_t_9 = __pyx_t_7;
  __pyx_L14_bool_binop_done:;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_7 = (__pyx_t_9 != 0);
  if (__pyx_t_7) {
/* … */
  }
  __pyx_L3:;
+436:         if supports_transparency and "RGBA" in rgb_formats:
    __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_v_supports_transparency); if (unlikely(__pyx_t_9 < 0)) __PYX_ERR(0, 436, __pyx_L1_error)
    if (__pyx_t_9) {
    } else {
      __pyx_t_7 = __pyx_t_9;
      goto __pyx_L17_bool_binop_done;
    }
    __pyx_t_9 = (__Pyx_PySequence_ContainsTF(__pyx_n_u_RGBA, __pyx_v_rgb_formats, Py_EQ)); if (unlikely(__pyx_t_9 < 0)) __PYX_ERR(0, 436, __pyx_L1_error)
    __pyx_t_6 = (__pyx_t_9 != 0);
    __pyx_t_7 = __pyx_t_6;
    __pyx_L17_bool_binop_done:;
    if (__pyx_t_7) {
/* … */
    }
+437:             log("argb_swap: argb_to_rgba for %s on %s", pixel_format, type(pixels))
      __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_log); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 437, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_4 = NULL;
      __pyx_t_8 = 0;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
        __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_2);
        if (likely(__pyx_t_4)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
          __Pyx_INCREF(__pyx_t_4);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_2, function);
          __pyx_t_8 = 1;
        }
      }
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_2)) {
        PyObject *__pyx_temp[4] = {__pyx_t_4, __pyx_kp_u_argb_swap_argb_to_rgba_for_s_on, __pyx_v_pixel_format, ((PyObject *)Py_TYPE(__pyx_v_pixels))};
        __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_8, 3+__pyx_t_8); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 437, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_GOTREF(__pyx_t_1);
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
        PyObject *__pyx_temp[4] = {__pyx_t_4, __pyx_kp_u_argb_swap_argb_to_rgba_for_s_on, __pyx_v_pixel_format, ((PyObject *)Py_TYPE(__pyx_v_pixels))};
        __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_8, 3+__pyx_t_8); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 437, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_GOTREF(__pyx_t_1);
      } else
      #endif
      {
        __pyx_t_3 = PyTuple_New(3+__pyx_t_8); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 437, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        if (__pyx_t_4) {
          __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_4); __pyx_t_4 = NULL;
        }
        __Pyx_INCREF(__pyx_kp_u_argb_swap_argb_to_rgba_for_s_on);
        __Pyx_GIVEREF(__pyx_kp_u_argb_swap_argb_to_rgba_for_s_on);
        PyTuple_SET_ITEM(__pyx_t_3, 0+__pyx_t_8, __pyx_kp_u_argb_swap_argb_to_rgba_for_s_on);
        __Pyx_INCREF(__pyx_v_pixel_format);
        __Pyx_GIVEREF(__pyx_v_pixel_format);
        PyTuple_SET_ITEM(__pyx_t_3, 1+__pyx_t_8, __pyx_v_pixel_format);
        __Pyx_INCREF(((PyObject *)Py_TYPE(__pyx_v_pixels)));
        __Pyx_GIVEREF(((PyObject *)Py_TYPE(__pyx_v_pixels)));
        PyTuple_SET_ITEM(__pyx_t_3, 2+__pyx_t_8, ((PyObject *)Py_TYPE(__pyx_v_pixels)));
        __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_3, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 437, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      }
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+438:             image.set_pixels(argb_to_rgba(pixels))
      __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_image, __pyx_n_s_set_pixels); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 438, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_argb_to_rgba); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 438, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_5 = NULL;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) {
        __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
        if (likely(__pyx_t_5)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
          __Pyx_INCREF(__pyx_t_5);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_4, function);
        }
      }
      __pyx_t_3 = (__pyx_t_5) ? __Pyx_PyObject_Call2Args(__pyx_t_4, __pyx_t_5, __pyx_v_pixels) : __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_v_pixels);
      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
      if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 438, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_4 = NULL;
      if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
        __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_2);
        if (likely(__pyx_t_4)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
          __Pyx_INCREF(__pyx_t_4);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_2, function);
        }
      }
      __pyx_t_1 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_4, __pyx_t_3) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3);
      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 438, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+439:             image.set_pixel_format("RGBA")
      __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_image, __pyx_n_s_set_pixel_format); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 439, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_3 = NULL;
      if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
        __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
        if (likely(__pyx_t_3)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
          __Pyx_INCREF(__pyx_t_3);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_2, function);
        }
      }
      __pyx_t_1 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_3, __pyx_n_u_RGBA) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_n_u_RGBA);
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 439, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+440:             return True
      __Pyx_XDECREF(__pyx_r);
      __Pyx_INCREF(Py_True);
      __pyx_r = Py_True;
      goto __pyx_L0;
+441:         if "RGB" in rgb_formats:
    __pyx_t_7 = (__Pyx_PySequence_ContainsTF(__pyx_n_u_RGB, __pyx_v_rgb_formats, Py_EQ)); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 441, __pyx_L1_error)
    __pyx_t_6 = (__pyx_t_7 != 0);
    if (__pyx_t_6) {
/* … */
    }
+442:             log("argb_swap: argb_to_rgb for %s on %s", pixel_format, type(pixels))
      __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_log); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 442, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_3 = NULL;
      __pyx_t_8 = 0;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
        __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
        if (likely(__pyx_t_3)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
          __Pyx_INCREF(__pyx_t_3);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_2, function);
          __pyx_t_8 = 1;
        }
      }
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_2)) {
        PyObject *__pyx_temp[4] = {__pyx_t_3, __pyx_kp_u_argb_swap_argb_to_rgb_for_s_on_s, __pyx_v_pixel_format, ((PyObject *)Py_TYPE(__pyx_v_pixels))};
        __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_8, 3+__pyx_t_8); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 442, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
        __Pyx_GOTREF(__pyx_t_1);
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
        PyObject *__pyx_temp[4] = {__pyx_t_3, __pyx_kp_u_argb_swap_argb_to_rgb_for_s_on_s, __pyx_v_pixel_format, ((PyObject *)Py_TYPE(__pyx_v_pixels))};
        __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_8, 3+__pyx_t_8); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 442, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
        __Pyx_GOTREF(__pyx_t_1);
      } else
      #endif
      {
        __pyx_t_4 = PyTuple_New(3+__pyx_t_8); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 442, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        if (__pyx_t_3) {
          __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3); __pyx_t_3 = NULL;
        }
        __Pyx_INCREF(__pyx_kp_u_argb_swap_argb_to_rgb_for_s_on_s);
        __Pyx_GIVEREF(__pyx_kp_u_argb_swap_argb_to_rgb_for_s_on_s);
        PyTuple_SET_ITEM(__pyx_t_4, 0+__pyx_t_8, __pyx_kp_u_argb_swap_argb_to_rgb_for_s_on_s);
        __Pyx_INCREF(__pyx_v_pixel_format);
        __Pyx_GIVEREF(__pyx_v_pixel_format);
        PyTuple_SET_ITEM(__pyx_t_4, 1+__pyx_t_8, __pyx_v_pixel_format);
        __Pyx_INCREF(((PyObject *)Py_TYPE(__pyx_v_pixels)));
        __Pyx_GIVEREF(((PyObject *)Py_TYPE(__pyx_v_pixels)));
        PyTuple_SET_ITEM(__pyx_t_4, 2+__pyx_t_8, ((PyObject *)Py_TYPE(__pyx_v_pixels)));
        __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 442, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      }
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+443:             image.set_pixels(argb_to_rgb(pixels))
      __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_image, __pyx_n_s_set_pixels); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 443, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_argb_to_rgb); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 443, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_5 = NULL;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
        __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_3);
        if (likely(__pyx_t_5)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
          __Pyx_INCREF(__pyx_t_5);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_3, function);
        }
      }
      __pyx_t_4 = (__pyx_t_5) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_5, __pyx_v_pixels) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_pixels);
      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
      if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 443, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_3 = NULL;
      if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
        __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
        if (likely(__pyx_t_3)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
          __Pyx_INCREF(__pyx_t_3);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_2, function);
        }
      }
      __pyx_t_1 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_3, __pyx_t_4) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_4);
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 443, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+444:             image.set_pixel_format("RGB")
      __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_image, __pyx_n_s_set_pixel_format); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 444, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_4 = NULL;
      if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
        __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_2);
        if (likely(__pyx_t_4)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
          __Pyx_INCREF(__pyx_t_4);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_2, function);
        }
      }
      __pyx_t_1 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_4, __pyx_n_u_RGB) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_n_u_RGB);
      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
      if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 444, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+445:             image.set_rowstride(rs*3//4)
      __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_image, __pyx_n_s_set_rowstride); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 445, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_4 = PyNumber_Multiply(__pyx_v_rs, __pyx_int_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 445, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_3 = __Pyx_PyInt_FloorDivideObjC(__pyx_t_4, __pyx_int_4, 4, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 445, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_4 = NULL;
      if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
        __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_2);
        if (likely(__pyx_t_4)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
          __Pyx_INCREF(__pyx_t_4);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_2, function);
        }
      }
      __pyx_t_1 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_4, __pyx_t_3) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3);
      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 445, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+446:             return True
      __Pyx_XDECREF(__pyx_r);
      __Pyx_INCREF(Py_True);
      __pyx_r = Py_True;
      goto __pyx_L0;
+447:     warning_key = "format-not-handled-%s" % bytestostr(pixel_format)
  __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_bytestostr); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 447, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  __pyx_t_1 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_3, __pyx_v_pixel_format) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v_pixel_format);
  __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 447, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyUnicode_FormatSafe(__pyx_kp_u_format_not_handled_s, __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 447, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_warning_key = ((PyObject*)__pyx_t_2);
  __pyx_t_2 = 0;
+448:     if first_time(warning_key):
  __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_first_time); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 448, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_1);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_1, function);
    }
  }
  __pyx_t_2 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_1, __pyx_t_3, __pyx_v_warning_key) : __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_v_warning_key);
  __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 448, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(0, 448, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (__pyx_t_6) {
/* … */
  }
+449:         log.warn("Warning: no matching argb function,")
    __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_log); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 449, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_warn); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 449, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = NULL;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
      __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_3);
      if (likely(__pyx_t_1)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
        __Pyx_INCREF(__pyx_t_1);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_3, function);
      }
    }
    __pyx_t_2 = (__pyx_t_1) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_1, __pyx_kp_u_Warning_no_matching_argb_functio) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_kp_u_Warning_no_matching_argb_functio);
    __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
    if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 449, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+450:         log.warn(" cannot convert %s to one of: %s", pixel_format, rgb_formats)
    __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_log); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 450, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_warn); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 450, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = NULL;
    __pyx_t_8 = 0;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) {
      __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_1);
      if (likely(__pyx_t_3)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
        __Pyx_INCREF(__pyx_t_3);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_1, function);
        __pyx_t_8 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_1)) {
      PyObject *__pyx_temp[4] = {__pyx_t_3, __pyx_kp_u_cannot_convert_s_to_one_of_s, __pyx_v_pixel_format, __pyx_v_rgb_formats};
      __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_8, 3+__pyx_t_8); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 450, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_GOTREF(__pyx_t_2);
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_1)) {
      PyObject *__pyx_temp[4] = {__pyx_t_3, __pyx_kp_u_cannot_convert_s_to_one_of_s, __pyx_v_pixel_format, __pyx_v_rgb_formats};
      __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_8, 3+__pyx_t_8); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 450, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_GOTREF(__pyx_t_2);
    } else
    #endif
    {
      __pyx_t_4 = PyTuple_New(3+__pyx_t_8); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 450, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      if (__pyx_t_3) {
        __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3); __pyx_t_3 = NULL;
      }
      __Pyx_INCREF(__pyx_kp_u_cannot_convert_s_to_one_of_s);
      __Pyx_GIVEREF(__pyx_kp_u_cannot_convert_s_to_one_of_s);
      PyTuple_SET_ITEM(__pyx_t_4, 0+__pyx_t_8, __pyx_kp_u_cannot_convert_s_to_one_of_s);
      __Pyx_INCREF(__pyx_v_pixel_format);
      __Pyx_GIVEREF(__pyx_v_pixel_format);
      PyTuple_SET_ITEM(__pyx_t_4, 1+__pyx_t_8, __pyx_v_pixel_format);
      __Pyx_INCREF(__pyx_v_rgb_formats);
      __Pyx_GIVEREF(__pyx_v_rgb_formats);
      PyTuple_SET_ITEM(__pyx_t_4, 2+__pyx_t_8, __pyx_v_rgb_formats);
      __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_4, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 450, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+451:     return False
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(Py_False);
  __pyx_r = Py_False;
  goto __pyx_L0;