in src/graphics/REagerGraphicsDevice.cpp [299:335]
void REagerGraphicsDevice::drawRaster(unsigned int *raster,
int w,
int h,
double x,
double y,
double width,
double height,
double rotation,
Rboolean interpolate,
pGEcontext context)
{
isDeviceBlank = false;
auto slave = getSlave();
if (!inMemory && slave != nullptr) {
slave->raster(raster, w, h, x, y, width, height, rotation, interpolate, context, slave);
}
if (isProxy) {
auto pixels = reinterpret_cast<uint32_t*>(raster); // ensure it's exactly 4 bytes
auto byteCount = w * h * sizeof(uint32_t);
auto dataPtr = Ptr<uint8_t>(new uint8_t[byteCount], std::default_delete<uint8_t[]>());
auto data = dataPtr.get();
// Convert to little-endian uint32[] of ARGB
for (auto i = 0; i < w * h; i++) {
auto abgr = pixels[i];
auto byteIndex = i * sizeof(uint32_t);
data[byteIndex + 2U] = abgr & 0xffU; // r
data[byteIndex + 1U] = (abgr >> 8U) & 0xffU; // g
data[byteIndex + 0U] = (abgr >> 16U) & 0xffU; // b
data[byteIndex + 3U] = abgr >> 24U; // a
}
auto bottomLeft = Point{x, y};
auto topRight = bottomLeft + Point{width, height};
auto rectangle = Rectangle::make(bottomLeft, topRight);
record<RasterAction>(RasterImage{w, h, dataPtr}, normalize(rectangle), rotation, interpolate == TRUE);
}
complexity += w * h / 8;
}