Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions enable/qt4/celiagg.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class Window(BaseWindow):
# Keep a buffer around for converting RGBA -> BGRA
_shuffle_buffer = Array(shape=(None, None, 4), dtype=np.uint8)

def _create_gc(self, size, pix_format="rgba32"):
def _create_gc(self, size, pix_format="bgra32"):
gc = GraphicsContext(
(size[0] + 1, size[1] + 1),
pix_format=pix_format,
Expand Down Expand Up @@ -58,7 +58,7 @@ def _shuffle_copy(self):

Qt's Format_RGB32 is actually BGR. So, Yeah...
"""
src = self._gc.gc.array
src = self._gc.bmp_array
dst = self._shuffle_buffer
src_fmt = self._gc.pix_format

Expand Down
13 changes: 8 additions & 5 deletions kiva/celiagg.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ def __init__(self, size, *args, **kwargs):
super(GraphicsContext, self).__init__()
self._width = size[0]
self._height = size[1]
self.pix_format = kwargs.get('pix_format', 'rgba32')
self.pix_format = kwargs.get('pix_format', 'bgra32')

shape = (self._height, self._width, 4)
buffer = np.zeros(shape, dtype=np.uint8)
Expand All @@ -113,6 +113,9 @@ def __init__(self, size, *args, **kwargs):
self.base_scale = kwargs.pop('base_pixel_scale', 1)
self.transform.scale(self.base_scale, self.base_scale)

# Make this look like a kiva.agg GC
self.bmp_array = buffer

# ----------------------------------------------------------------
# Size info
# ----------------------------------------------------------------
Expand Down Expand Up @@ -584,16 +587,16 @@ def normalize_image(img):
elif isinstance(img, Image.Image):
img, img_format = normalize_image(img)
img_array = np.array(img)
elif isinstance(img, GraphicsContext):
img_array = img.gc.array
img_format = pix_formats[img.pix_format]
elif hasattr(img, 'bmp_array'):
# An offscreen kiva context
# An offscreen kiva.agg context
# XXX: Use a copy to kill the read-only flag which plays havoc
# with the Cython memoryviews used by celiagg
img = Image.fromarray(img.bmp_array)
img, img_format = normalize_image(img)
img_array = np.array(img)
elif isinstance(img, GraphicsContext):
img_array = img.gc.array
img_format = pix_formats[img.pix_format]
else:
msg = "Cannot render image of type '{}' into celiagg context."
warnings.warn(msg.format(type(img)))
Expand Down