Skip to content

Commit

Permalink
Addressed review comments
Browse files Browse the repository at this point in the history
Signed-off-by: Megha S <[email protected]>
  • Loading branch information
MeghaS94 committed Dec 8, 2023
1 parent 0afbe0e commit 8ca895f
Show file tree
Hide file tree
Showing 11 changed files with 31 additions and 67 deletions.
13 changes: 9 additions & 4 deletions website/ReadingAndWritingImageFiles.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Document Purpose and Audience
=============================

This document shows how to write C++ code that reads and writes OpenEXR
3.0 image files.
2.0 image files.

The text assumes that the reader is familiar with OpenEXR terms like
“channel”, “attribute”, “data window” or “deep data”. For an explanation
Expand Down Expand Up @@ -126,6 +126,9 @@ Writing a simple RGBA image file is fairly straightforward:
.. literalinclude:: src/writeRgba1.cpp
:language: c++
:linenos:
:dedent:
:start-after: [begin writeRgba1]
:end-before: [end writeRgba1]

Construction of an RgbaOutputFile object, on line 4, creates an OpenEXR header,
sets the header's attributes, opens the file with the specified name, and stores
Expand Down Expand Up @@ -189,12 +192,12 @@ to get right than with error return values. For instance, a program that
calls our ``writeRgba1()`` function can handle all possible error
conditions with a single try/catch block:

.. literalinclude:: src/tryCatchExample.cpp
.. literalinclude:: src/writeRgba1.cpp
:language: c++
:linenos:
:dedent:
:start-after: [begin]
:end-before: [end]
:start-after: [begin tryCatchExample]
:end-before: [end tryCatchExample]

Writing a Cropped RGBA Image
----------------------------
Expand Down Expand Up @@ -1024,6 +1027,8 @@ tiles we want to read.

.. literalinclude:: src/readTiled1.cpp
:language: c++
:linenos:
:dedent:
:start-after: [begin readTiled1]
:end-before: [end readTiled1]

Expand Down
5 changes: 0 additions & 5 deletions website/src/all.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,11 +118,6 @@ void structDefinitions()
#include "structDefinitions.cpp"
}

void tryCatchWriteRgba1()
{
#include "tryCatchExample.cpp"
}

void multithreading()
{
#include "multithreading.cpp"
Expand Down
2 changes: 1 addition & 1 deletion website/src/compression.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

int width, height;
int width=1; int height=1;
// [begin setCompression]
Header header (width, height);
header.channels().insert ("G", Channel (HALF));
Expand Down
2 changes: 1 addition & 1 deletion website/src/envmap.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

char fileName[100];
char fileName[] = "";
// [begin hasEnvmap]
RgbaInputFile file (fileName);

Expand Down
7 changes: 0 additions & 7 deletions website/src/gamma.cpp

This file was deleted.

31 changes: 0 additions & 31 deletions website/src/makePreviewImage.cpp

This file was deleted.

2 changes: 1 addition & 1 deletion website/src/multithreading.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
char fileName[100];
char fileName[] = "";
// [begin main thread create]
// main, before application threads are created:

Expand Down
4 changes: 2 additions & 2 deletions website/src/previewImageExamples.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ 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);
return (unsigned char) std::clamp (x, 0.f, 255.f);
}
// [end gamma]

Expand Down Expand Up @@ -60,7 +60,7 @@ makePreviewImage (
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);
outPixel.a = static_cast<int> (std::clamp (inPixel.a * 255.f, 0.f, 255.f) + 0.5f);
}
}
}
Expand Down
14 changes: 0 additions & 14 deletions website/src/tryCatchExample.cpp

This file was deleted.

16 changes: 16 additions & 0 deletions website/src/writeRgba1.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,23 @@
// [begin writeRgba1]
void
writeRgba1 (const char fileName[], const Rgba* pixels, int width, int height)
{
RgbaOutputFile file (fileName, width, height, WRITE_RGBA); // 1
file.setFrameBuffer (pixels, 1, width); // 2
file.writePixels (height); // 3
}
// [end writeRgba1]

void
tryCatchExample (const char fileName[], const Rgba* pixels, int width, int height) {
// [begin tryCatchExample]
try
{
writeRgba1 (fileName, pixels, width, height);
}
catch (const std::exception &exc)
{
std::cerr << exc.what() << std::endl;
}
// [end tryCatchExample]
}
2 changes: 1 addition & 1 deletion website/src/writeRgbaWithPreview2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ writeRgbaWithPreview2 (const char fileName[], int width, int height)
outPixel.r = gamma (inPixel.r);
outPixel.g = gamma (inPixel.g);
outPixel.b = gamma (inPixel.b);
outPixel.a = int (clamp (inPixel.a * 255.f, 0.f, 255.f) + 0.5f);
outPixel.a = int (std::clamp (inPixel.a * 255.f, 0.f, 255.f) + 0.5f);
}
}
}
Expand Down

0 comments on commit 8ca895f

Please sign in to comment.