| 97 | |
| 98 | |
| 99 | void 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 |
no test coverage detected