Blame 0002-Fix-RGBA-processing-on-big-endian-machines.patch

5de3037
From dfb31cdc3ca614f97d843c8d799e35504ad6b826 Mon Sep 17 00:00:00 2001
5de3037
From: Elliott Sales de Andrade <quantum.analyst@gmail.com>
5de3037
Date: Sun, 11 Apr 2021 02:13:41 -0400
5de3037
Subject: [PATCH 2/2] Fix RGBA processing on big-endian machines.
5de3037
5de3037
Signed-off-by: Elliott Sales de Andrade <quantum.analyst@gmail.com>
5de3037
---
5de3037
 src/_mplcairo.cpp | 4 ++--
5de3037
 1 file changed, 2 insertions(+), 2 deletions(-)
5de3037
5de3037
diff --git a/src/_mplcairo.cpp b/src/_mplcairo.cpp
5de3037
index 8f16841..fc90572 100644
5de3037
--- a/src/_mplcairo.cpp
5de3037
+++ b/src/_mplcairo.cpp
5de3037
@@ -129,7 +129,7 @@ py::bytes Region::get_straight_argb32_bytes() {
5de3037
     }
5de3037
   } else {  // big-endian
5de3037
     auto u32_ptr = static_cast<uint32_t*>(buf.ptr);
5de3037
-    for (auto i = 0; i < size; i += 4) {
5de3037
+    for (auto i = 0; i < size / 4; i++) {
5de3037
       u32_ptr[i] = (u32_ptr[i] >> 8) + (u32_ptr[i] << 24);  // RGBA->ARGB
5de3037
     }
5de3037
   }
5de3037
@@ -1816,7 +1816,7 @@ py::array_t<uint8_t, py::array::c_style> cairo_to_premultiplied_rgba8888(
5de3037
     }
5de3037
   } else {  // big-endian
5de3037
     auto u32_ptr = reinterpret_cast<uint32_t*>(u8.mutable_data());
5de3037
-    for (auto i = 0; i < size; i += 4) {
5de3037
+    for (auto i = 0; i < size / 4; i++) {
5de3037
       u32_ptr[i] = (u32_ptr[i] << 8) + (u32_ptr[i] >> 24);  // ARGB->RGBA
5de3037
     }
5de3037
   }
5de3037
-- 
5de3037
2.29.2
5de3037