AutomationEngine: fix regression with screenshots.
This commit is contained in:
@@ -129,7 +129,7 @@ TEST_F(BackendTest, ReadPixels) {
|
||||
const size_t width = readRect.width, height = readRect.height;
|
||||
LinearImage image(width, height, 4);
|
||||
if (format == PixelDataFormat::RGBA && type == PixelDataType::UBYTE) {
|
||||
image = toLinear<uint8_t>(width, height, width * 4, (uint8_t*) pixelData);
|
||||
image = toLinearWithAlpha<uint8_t>(width, height, width * 4, (uint8_t*) pixelData);
|
||||
}
|
||||
if (format == PixelDataFormat::RGBA && type == PixelDataType::FLOAT) {
|
||||
memcpy(image.getPixelRef(), pixelData, width * height * sizeof(math::float4));
|
||||
|
||||
@@ -347,7 +347,7 @@ inline LinearImage fromLinearToRGBM(const LinearImage& image) {
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
static LinearImage toLinear(size_t w, size_t h, size_t bpr, const uint8_t* src) {
|
||||
static LinearImage toLinearWithAlpha(size_t w, size_t h, size_t bpr, const uint8_t* src) {
|
||||
LinearImage result(w, h, 4);
|
||||
filament::math::float4* d = reinterpret_cast<filament::math::float4*>(result.getPixelRef(0, 0));
|
||||
for (size_t y = 0; y < h; ++y) {
|
||||
@@ -361,6 +361,21 @@ static LinearImage toLinear(size_t w, size_t h, size_t bpr, const uint8_t* src)
|
||||
return result;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
static LinearImage toLinear(size_t w, size_t h, size_t bpr, const uint8_t* src) {
|
||||
LinearImage result(w, h, 3);
|
||||
filament::math::float3* d = reinterpret_cast<filament::math::float3*>(result.getPixelRef(0, 0));
|
||||
for (size_t y = 0; y < h; ++y) {
|
||||
T const* p = reinterpret_cast<T const*>(src + y * bpr);
|
||||
for (size_t x = 0; x < w; ++x, p += 3) {
|
||||
filament::math::float3 sRGB(p[0], p[1], p[2]);
|
||||
sRGB /= std::numeric_limits<T>::max();
|
||||
*d++ = sRGBToLinear(sRGB);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
} // namespace Image
|
||||
|
||||
#endif // IMAGE_COLORTRANSFORM_H_
|
||||
|
||||
Reference in New Issue
Block a user