49 lines
1.8 KiB
Diff
49 lines
1.8 KiB
Diff
From 3fe3b45dd22b97525caa22678f8927d0ddf352ca Mon Sep 17 00:00:00 2001
|
|
From: Elliott Sales de Andrade <quantum.analyst@gmail.com>
|
|
Date: Tue, 4 Aug 2020 05:54:38 -0400
|
|
Subject: [PATCH 1/2] Byte swap `agg_capture` output on big-endian systems.
|
|
|
|
R expects colours to be integers of ABGR, which on little-endian
|
|
machines maps to singular bytes in RGBA order, but maps to ABGR order on
|
|
bit-endian machines.
|
|
|
|
Signed-off-by: Elliott Sales de Andrade <quantum.analyst@gmail.com>
|
|
---
|
|
src/AggDeviceCapture.h | 4 +++-
|
|
src/ragg.h | 2 ++
|
|
2 files changed, 5 insertions(+), 1 deletion(-)
|
|
|
|
diff --git a/src/AggDeviceCapture.h b/src/AggDeviceCapture.h
|
|
index 02f76a4..86f7cc4 100644
|
|
--- a/src/AggDeviceCapture.h
|
|
+++ b/src/AggDeviceCapture.h
|
|
@@ -21,7 +21,9 @@ public:
|
|
}
|
|
SEXP capture() {
|
|
SEXP raster = PROTECT(Rf_allocVector(INTSXP, this->width * this->height));
|
|
- memcpy(INTEGER(raster), this->buffer, this->width * this->height * 4);
|
|
+ agg::rendering_buffer caprbuf(reinterpret_cast<agg::int8u*>(INTEGER(raster)),
|
|
+ this->width, this->height, this->width * 4);
|
|
+ agg::convert<pixfmt_r_capture, pixfmt_type_32>(&caprbuf, &this->rbuf);
|
|
SEXP dims = PROTECT(Rf_allocVector(INTSXP, 2));
|
|
INTEGER(dims)[0] = this->height;
|
|
INTEGER(dims)[1] = this->width;
|
|
diff --git a/src/ragg.h b/src/ragg.h
|
|
index 7a66d8b..0fca0a5 100644
|
|
--- a/src/ragg.h
|
|
+++ b/src/ragg.h
|
|
@@ -36,8 +36,10 @@ typedef agg::pixfmt_rgba64_pre pixfmt_type_64;
|
|
|
|
#ifdef __BIG_ENDIAN__
|
|
typedef agg::pixfmt_abgr32_plain pixfmt_r_raster;
|
|
+typedef agg::pixfmt_abgr32_pre pixfmt_r_capture;
|
|
#else
|
|
typedef agg::pixfmt_rgba32_plain pixfmt_r_raster;
|
|
+typedef agg::pixfmt_rgba32_pre pixfmt_r_capture;
|
|
#endif
|
|
|
|
// pixfmt agnosting demultiplying
|
|
--
|
|
2.25.4
|
|
|