Skip to content

Commit

Permalink
Process list-based palette correctly in encode.encode_bytes()
Browse files Browse the repository at this point in the history
  • Loading branch information
saitoha committed May 1, 2016
1 parent 0f9272d commit 19f7cff
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions python/libsixel/__init__.py
Expand Up @@ -20,7 +20,7 @@
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#

from ctypes import cdll, c_void_p, c_int, c_char_p, POINTER, byref
from ctypes import cdll, c_void_p, c_int, c_byte, c_char_p, POINTER, byref
from ctypes.util import find_library

SIXEL_OK = 0x0000
Expand Down Expand Up @@ -429,14 +429,11 @@ def sixel_encoder_encode_bytes(encoder, buf, width, height, pixelformat, palette
cbuf = c_void_p.from_buffer(buf)

if palette:
if not hasattr(palette, "readonly") or buf.readonly:
cpalette = c_void_p.from_buffer_copy(palette)
else:
cpalette = c_void_p.from_buffer(palette)
cpalettelen = len(palette)
cpalette = (c_byte * cpalettelen)(*palette)
else:
cpalette = None
cpalettelen = None
cpalette = None

_sixel.sixel_encoder_encode_bytes.restype = c_int
_sixel.sixel_encoder_encode.argtypes = [c_void_p, c_void_p, c_int, c_int, c_int, c_void_p, c_int]
Expand Down

0 comments on commit 19f7cff

Please sign in to comment.