MCPcopy Create free account
hub / github.com/AcademySoftwareFoundation/OpenColorIO / Extract

Function Extract

src/apps/ociolutimage/main.cpp:99–131  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

97
98
99void Extract(int cubesize, int maxwidth,
100 const std::string & inputfile,
101 const std::string & outputfile)
102{
103 OCIO::ImageIO img(inputfile);
104
105 int width = 0;
106 int height = 0;
107 GetLutImageSize(width, height, cubesize, maxwidth);
108
109 if (img.getWidth() != width || img.getHeight() != height)
110 {
111 std::ostringstream os;
112 os << "Image does not have expected dimensions. ";
113 os << "Expected " << width << "x" << height << ", ";
114 os << "Found " << img.getWidth() << "x" << img.getHeight();
115 throw OCIO::Exception(os.str().c_str());
116 }
117
118 if (img.getNumChannels() != 3)
119 {
120 throw OCIO::Exception("Image must have 3 channels.");
121 }
122
123 int lut3DNumPixels = cubesize*cubesize*cubesize;
124
125 if (img.getWidth() * img.getHeight() < lut3DNumPixels)
126 {
127 throw OCIO::Exception("Image is not large enough to contain expected 3D LUT.");
128 }
129
130 WriteLut3D(outputfile, (float*) img.getData(), cubesize);
131}
132
133
134

Callers 1

mainFunction · 0.85

Calls 6

GetLutImageSizeFunction · 0.85
WriteLut3DFunction · 0.85
getWidthMethod · 0.45
getHeightMethod · 0.45
getNumChannelsMethod · 0.45
getDataMethod · 0.45

Tested by

no test coverage detected