-
Notifications
You must be signed in to change notification settings - Fork 624
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Converting code-blocks to literalincludes in ReadingAndWritingImageFi…
…les.rst
- Loading branch information
Showing
16 changed files
with
531 additions
and
240 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
|
||
int width, height; | ||
// [begin setCompression] | ||
Header header (width, height); | ||
header.channels().insert ("G", Channel (HALF)); | ||
header.channels().insert ("Z", Channel (FLOAT)); | ||
header.compression() = ZIP_COMPRESSION; | ||
header.zipCompressionLevel() = 6; | ||
// [end setCompression] | ||
|
||
// [begin setCompressionDefault] | ||
setDefaultZipCompressionLevel (6); | ||
setDefaultDwaCompressionLevel (45.0f); | ||
// [end setCompressionDefault] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
|
||
char fileName[100]; | ||
// [begin hasEnvmap] | ||
RgbaInputFile file (fileName); | ||
|
||
if (hasEnvmap (file.header())) | ||
{ | ||
Envmap type = envmap (file.header()); | ||
// ... | ||
} | ||
// [end hasEnvmap] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
char fileName[100]; | ||
// [begin main thread create] | ||
// main, before application threads are created: | ||
|
||
setGlobalThreadCount (4); | ||
// [begin applications input thread] | ||
// application's input thread | ||
|
||
InputFile in (fileName); | ||
|
||
// ... | ||
// [end applications input thread] | ||
|
||
Header header = in.header(); | ||
// [begin applications output thread] | ||
// application's output thread | ||
|
||
OutputFile out (fileName, header, 2); | ||
|
||
// ... | ||
// [end applications output thread] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
void | ||
accessPreviewImage (const char fileName[]) | ||
{ | ||
// [begin accessPreviewImage] | ||
RgbaInputFile file (fileName); | ||
|
||
if (file.header().hasPreviewImage()) | ||
{ | ||
const PreviewImage &preview = file.header().previewImage(); | ||
|
||
for (int y = 0; y < preview.height(); ++y) | ||
{ | ||
for (int x = 0; x < preview.width(); ++x) | ||
{ | ||
|
||
const PreviewRgba &pixel = preview.pixel (x, y); | ||
|
||
// ... | ||
|
||
} | ||
} | ||
} | ||
// [end accessPreviewImage] | ||
} | ||
|
||
// [begin gamma] | ||
unsigned char | ||
gamma (float x) | ||
{ | ||
x = pow (5.5555f * max (0.f, x), 0.4545f) * 84.66f; | ||
return (unsigned char) clamp (x, 0.f, 255.f); | ||
} | ||
// [end gamma] | ||
|
||
// [begin makePreviewImage] | ||
void | ||
makePreviewImage ( | ||
const Array2D<Rgba>& pixels, | ||
int width, | ||
int height, | ||
Array2D<PreviewRgba>& previewPixels, | ||
int& previewWidth, | ||
int& previewHeight) | ||
{ | ||
const int N = 8; | ||
|
||
previewWidth = width / N; | ||
previewHeight = height / N; | ||
|
||
previewPixels.resizeErase (previewHeight, previewWidth); | ||
|
||
for (int y = 0; y < previewHeight; ++y) | ||
{ | ||
for (int x = 0; x < previewWidth; ++x) | ||
{ | ||
|
||
const Rgba& inPixel = pixels[y * N][x * N]; | ||
PreviewRgba& outPixel = previewPixels[y][x]; | ||
|
||
outPixel.r = gamma (inPixel.r); | ||
outPixel.g = gamma (inPixel.g); | ||
outPixel.b = gamma (inPixel.b); | ||
outPixel.a = static_cast<int> (clamp (inPixel.a * 255.f, 0.f, 255.f) + 0.5f); | ||
} | ||
} | ||
} | ||
// [end makePreviewImage] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
void | ||
readChannels(const char fileName[]) | ||
{ | ||
InputFile file (fileName); | ||
|
||
// [begin useIterator] | ||
const ChannelList &channels = file.header().channels(); | ||
|
||
for (ChannelList::ConstIterator i = channels.begin(); i != channels.end(); ++i) | ||
{ | ||
const Channel &channel = i.channel(); | ||
// ... | ||
} | ||
// [end useIterator] | ||
|
||
// [begin directAccess] | ||
// const ChannelList &channels = file.header().channels(); | ||
|
||
const Channel &channel = channels["G"]; | ||
|
||
const Channel *channelPtr = channels.findChannel("G"); | ||
// [end directAccess] | ||
|
||
} | ||
|
||
void | ||
readLayers (const char fileName[]) | ||
{ | ||
InputFile file (fileName); | ||
|
||
// [begin layers] | ||
const ChannelList &channels = file.header().channels(); ; | ||
|
||
std::set<string> layerNames; | ||
|
||
channels.layers (layerNames); | ||
|
||
for (std::set<std::string>::const_iterator i = layerNames.begin(); i != layerNames.end(); ++i) | ||
{ | ||
cout << "layer " << *i << endl; | ||
|
||
ChannelList::ConstIterator layerBegin, layerEnd; | ||
channels.channelsInLayer (*i, layerBegin, layerEnd); | ||
for (ChannelList::ConstIterator j = layerBegin; j != layerEnd; ++j) | ||
{ | ||
cout << "tchannel " << j.name() << endl; | ||
} | ||
} | ||
// [end layers] | ||
} | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -51,4 +51,4 @@ readGZ1 ( | |
|
||
file.setFrameBuffer (frameBuffer); | ||
file.readPixels (dw.min.y, dw.max.y); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// [Rgba definition begin] | ||
struct Rgba | ||
{ | ||
half r; // red | ||
half g; // green | ||
half b; // blue | ||
half a; // alpha (opacity) | ||
}; | ||
// [Rgba definition end] | ||
|
||
// [GZ definition begin] | ||
struct GZ | ||
{ | ||
half g; | ||
float z; | ||
}; | ||
// [GZ definition end] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// Enums defined in ImfTileDescription.h | ||
// enum LevelMode | ||
// { | ||
// ONE_LEVEL, | ||
// MIPMAP_LEVELS, | ||
// RIPMAP_LEVELS | ||
// }; | ||
|
||
// enum LevelRoundingMode | ||
// { | ||
// ROUND_DOWN, | ||
// ROUND_UP | ||
// }; | ||
|
||
class TileDescription | ||
{ | ||
public: | ||
unsigned int xSize; // size of a tile in the x dimension | ||
unsigned int ySize; // size of a tile in the y dimension | ||
LevelMode mode; | ||
LevelRoundingMode roundingMode; | ||
// ... (methods omitted) | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
char fileName[100]; | ||
const Rgba* pixels; | ||
int width; | ||
int height; | ||
// [begin] | ||
try | ||
{ | ||
writeRgba1 (fileName, pixels, width, height); | ||
} | ||
catch (const std::exception &exc) | ||
{ | ||
std::cerr << exc.what() << std::endl; | ||
} | ||
// [end] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#include <fstream> | ||
// [begin validFileCheck] | ||
bool | ||
isThisAnOpenExrFile (const char fileName[]) | ||
{ | ||
std::ifstream f (fileName, std::ios_base::binary); | ||
|
||
char b[4]; | ||
f.read (b, sizeof (b)); | ||
|
||
return !!f && b[0] == 0x76 && b[1] == 0x2f && b[2] == 0x31 && b[3] == 0x01; | ||
} | ||
// [end validFileCheck] | ||
// [begin completeFileCheck] | ||
bool | ||
isComplete (const char fileName[]) | ||
{ | ||
InputFile in (fileName); | ||
return in.isComplete(); | ||
} | ||
// [end completeFileCheck] | ||
|
||
// [begin otherValidFileChecks] | ||
bool isOpenExrFile (const char fileName[], bool &isTiled); | ||
|
||
bool isOpenExrFile (const char fileName[]); | ||
|
||
bool isTiledOpenExrFile (const char fileName[]); | ||
|
||
bool isOpenExrFile (IStream &is, bool &isTiled); | ||
|
||
bool isOpenExrFile (IStream &is); | ||
|
||
bool isTiledOpenExrFile (IStream &is); | ||
// [end otherValidFileChecks] |
Oops, something went wrong.