代码拉取完成,页面将自动刷新
同步操作将从 src-openEuler/OpenEXR 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
From 7f8c2414d8fa0cc2ccfdcb236697f4bd806d81a6 Mon Sep 17 00:00:00 2001
From: wang_yue111 <[email protected]>
Date: Tue, 6 Apr 2021 15:16:42 +0800
Subject: [PATCH] lighter weight reading of Luma-only images via RgbaInputFile
(#827)
Signed-off-by: Peter Hillman <[email protected]>
Co-authored-by: Cary Phillips <[email protected]>
---
IlmImf/ImfRgbaFile.cpp | 89 ++++++++++++++++++++++++++++++------------
IlmImfTest/testYca.cpp | 1 +
2 files changed, 64 insertions(+), 26 deletions(-)
diff --git a/IlmImf/ImfRgbaFile.cpp b/IlmImf/ImfRgbaFile.cpp
index c2b604a..2ebfbed 100644
--- a/IlmImf/ImfRgbaFile.cpp
+++ b/IlmImf/ImfRgbaFile.cpp
@@ -1169,7 +1169,7 @@ RgbaInputFile::RgbaInputFile (const char name[], int numThreads):
{
RgbaChannels rgbaChannels = channels();
- if (rgbaChannels & (WRITE_Y | WRITE_C))
+ if (rgbaChannels & WRITE_C)
_fromYca = new FromYca (*_inputFile, rgbaChannels);
}
@@ -1181,7 +1181,7 @@ RgbaInputFile::RgbaInputFile (OPENEXR_IMF_INTERNAL_NAMESPACE::IStream &is, int n
{
RgbaChannels rgbaChannels = channels();
- if (rgbaChannels & (WRITE_Y | WRITE_C))
+ if (rgbaChannels & WRITE_C)
_fromYca = new FromYca (*_inputFile, rgbaChannels);
}
@@ -1196,7 +1196,7 @@ RgbaInputFile::RgbaInputFile (const char name[],
{
RgbaChannels rgbaChannels = channels();
- if (rgbaChannels & (WRITE_Y | WRITE_C))
+ if (rgbaChannels & WRITE_C)
_fromYca = new FromYca (*_inputFile, rgbaChannels);
}
@@ -1211,7 +1211,7 @@ RgbaInputFile::RgbaInputFile (OPENEXR_IMF_INTERNAL_NAMESPACE::IStream &is,
{
RgbaChannels rgbaChannels = channels();
- if (rgbaChannels & (WRITE_Y | WRITE_C))
+ if (rgbaChannels & WRITE_C)
_fromYca = new FromYca (*_inputFile, rgbaChannels);
}
@@ -1238,27 +1238,42 @@ RgbaInputFile::setFrameBuffer (Rgba *base, size_t xStride, size_t yStride)
FrameBuffer fb;
- fb.insert (_channelNamePrefix + "R",
- Slice (HALF,
- (char *) &base[0].r,
- xs, ys,
- 1, 1, // xSampling, ySampling
- 0.0)); // fillValue
-
- fb.insert (_channelNamePrefix + "G",
- Slice (HALF,
- (char *) &base[0].g,
- xs, ys,
- 1, 1, // xSampling, ySampling
- 0.0)); // fillValue
-
- fb.insert (_channelNamePrefix + "B",
- Slice (HALF,
- (char *) &base[0].b,
- xs, ys,
- 1, 1, // xSampling, ySampling
- 0.0)); // fillValue
-
+ if( channels() & WRITE_Y )
+ {
+ fb.insert (_channelNamePrefix + "Y",
+ Slice (HALF,
+ (char *) &base[0].r,
+ xs, ys,
+ 1, 1, // xSampling, ySampling
+ 0.0)); // fillValue
+ }
+ else
+ {
+
+
+ fb.insert (_channelNamePrefix + "R",
+ Slice (HALF,
+ (char *) &base[0].r,
+ xs, ys,
+ 1, 1, // xSampling, ySampling
+ 0.0)); // fillValue
+
+
+
+ fb.insert (_channelNamePrefix + "G",
+ Slice (HALF,
+ (char *) &base[0].g,
+ xs, ys,
+ 1, 1, // xSampling, ySampling
+ 0.0)); // fillValue
+
+ fb.insert (_channelNamePrefix + "B",
+ Slice (HALF,
+ (char *) &base[0].b,
+ xs, ys,
+ 1, 1, // xSampling, ySampling
+ 0.0)); // fillValue
+ }
fb.insert (_channelNamePrefix + "A",
Slice (HALF,
(char *) &base[0].a,
@@ -1281,7 +1296,7 @@ RgbaInputFile::setLayerName (const string &layerName)
RgbaChannels rgbaChannels = channels();
- if (rgbaChannels & (WRITE_Y | WRITE_C))
+ if (rgbaChannels & WRITE_C)
_fromYca = new FromYca (*_inputFile, rgbaChannels);
FrameBuffer fb;
@@ -1300,6 +1315,28 @@ RgbaInputFile::readPixels (int scanLine1, int scanLine2)
else
{
_inputFile->readPixels (scanLine1, scanLine2);
+
+ if (channels() & WRITE_Y)
+ {
+ //
+ // Luma channel has been written into red channel
+ // Duplicate into green and blue channel to create gray image
+ //
+ const Slice* s = _inputFile->frameBuffer().findSlice(_channelNamePrefix + "Y");
+ Box2i dataWindow = _inputFile->header().dataWindow();
+
+ for( int scanLine = scanLine1 ; scanLine <= scanLine2 ; scanLine++ )
+ {
+ char* rowBase = s->base + scanLine*s->yStride;
+ for(int x = dataWindow.min.x ; x <= dataWindow.max.x ; ++x )
+ {
+ Rgba* pixel = reinterpret_cast<Rgba*>(rowBase+x*s->xStride);
+ pixel->g = pixel->r;
+ pixel->b = pixel->r;
+ }
+
+ }
+ }
}
}
diff --git a/IlmImfTest/testYca.cpp b/IlmImfTest/testYca.cpp
index 0d3459e..3007552 100644
--- a/IlmImfTest/testYca.cpp
+++ b/IlmImfTest/testYca.cpp
@@ -187,6 +187,7 @@ writeReadYca (const char fileName[],
else
{
assert (p1.g == p2.g);
+ assert (p1.b == p2.b);
}
if (channels & WRITE_A)
--
2.23.0
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。