From 9a91275981ecaaed9a54ebeee2189abf432b8986 Mon Sep 17 00:00:00 2001 From: Cary Phillips Date: Tue, 1 Aug 2023 17:39:17 -0700 Subject: [PATCH] Add website example source files to the CMake build for validation - Include all .cpp files in `docs/src` in `docs/src/all.cpp` and add it as a build dependency. This validates that it compiles, although there's no execution so it still doesn't validate correct behavior. - Move larger code-blocks from ReadingAndWritingImageFiles.rst into individual files in `docs/src` Signed-off-by: Cary Phillips --- docs/CMakeLists.txt | 9 +- docs/ReadingAndWritingImageFiles.rst | 233 ++---------------- docs/src/CMakeLists.txt | 11 + docs/src/C_IStream.cpp | 15 ++ docs/src/C_IStream_clear.cpp | 5 + docs/src/C_IStream_read.cpp | 18 ++ docs/src/C_IStream_seekg.cpp | 7 + docs/src/C_IStream_tellg.cpp | 6 + docs/src/IStream.cpp | 20 ++ docs/src/MemoryMappedIStream.cpp | 21 ++ docs/src/MemoryMappedIStream_constructor.cpp | 23 ++ docs/src/MemoryMappedIStream_destructor.cpp | 5 + .../MemoryMappedIStream_isMemoryMapped.cpp | 4 + docs/src/MemoryMappedIStream_read.cpp | 29 +++ .../MemoryMappedIStream_readMemoryMapped.cpp | 17 ++ docs/src/all.cpp | 101 ++++++++ docs/src/file.cpp | 55 ----- docs/src/makePreviewImage.cpp | 2 +- ...nlineFile.cpp => readDeepScanLineFile.cpp} | 2 +- docs/src/readRgba2.cpp | 1 - ...lineFile.cpp => writeDeepScanLineFile.cpp} | 2 +- docs/src/writeTiledRgbaMIP1.cpp | 4 +- 22 files changed, 318 insertions(+), 272 deletions(-) create mode 100644 docs/src/CMakeLists.txt create mode 100644 docs/src/C_IStream.cpp create mode 100644 docs/src/C_IStream_clear.cpp create mode 100644 docs/src/C_IStream_read.cpp create mode 100644 docs/src/C_IStream_seekg.cpp create mode 100644 docs/src/C_IStream_tellg.cpp create mode 100644 docs/src/IStream.cpp create mode 100644 docs/src/MemoryMappedIStream.cpp create mode 100644 docs/src/MemoryMappedIStream_constructor.cpp create mode 100644 docs/src/MemoryMappedIStream_destructor.cpp create mode 100644 docs/src/MemoryMappedIStream_isMemoryMapped.cpp create mode 100644 docs/src/MemoryMappedIStream_read.cpp create mode 100644 docs/src/MemoryMappedIStream_readMemoryMapped.cpp create mode 100644 docs/src/all.cpp delete mode 100644 docs/src/file.cpp rename docs/src/{readDeepScanlineFile.cpp => readDeepScanLineFile.cpp} (98%) rename docs/src/{writeDeepScanlineFile.cpp => writeDeepScanLineFile.cpp} (98%) diff --git a/docs/CMakeLists.txt b/docs/CMakeLists.txt index 5e778007b9..9204acb39f 100644 --- a/docs/CMakeLists.txt +++ b/docs/CMakeLists.txt @@ -102,11 +102,14 @@ define_manpage(exrmultipart "combine or split multipart exr images") define_manpage(exrmultiview "convert between single/multi-view exr images") define_manpage(exrstdattr "set exr image metadata") +add_subdirectory(src) + add_custom_target(docs ALL DEPENDS ${SPHINX_INDEX_FILE} ${DOXYGEN_INDEX_FILE} ${TEST_IMAGE_INDEX_FILE} - ${manpage_files}) + ${manpage_files} + ${CMAKE_BINARY_DIR}/bin/docs_src) # Add a target to install the manpages, but *not* the html @@ -114,3 +117,7 @@ if(INSTALL_DOCS) include(GNUInstallDirs) install(DIRECTORY ${MANPAGE_OUTPUT_DIR}/man1 DESTINATION ${CMAKE_INSTALL_MANDIR}) endif() + +# build the example code to verify that it compiles + + diff --git a/docs/ReadingAndWritingImageFiles.rst b/docs/ReadingAndWritingImageFiles.rst index 94d921d0e3..975ede1b03 100644 --- a/docs/ReadingAndWritingImageFiles.rst +++ b/docs/ReadingAndWritingImageFiles.rst @@ -214,22 +214,9 @@ is indicated by the display window, ``(0,0) - (width-1, height-1)``, and the data window specifies the region for which valid pixel data exist. Only the pixels in the data window are stored in the file. -.. code-block:: +.. literalinclude:: src/writeRgba2.cpp :linenos: - void - writeRgba2 (const char fileName[], - const Rgba *pixels, - int width, - int height, - const Box2i &dataWindow) - { - Box2i displayWindow (V2i (0, 0), V2i (width - 1, height - 1)); - RgbaOutputFile file (fileName, displayWindow, dataWindow, WRITE_RGBA); - file.setFrameBuffer (pixels, 1, width); - file.writePixels (dataWindow.max.y - dataWindow.min.y + 1); - } - The code above is similar to that in `Writing an RGBA Image File`_, where the whole image was stored in the file. Two things are different, however: When the ``RgbaOutputFile`` object is created, the data window and the display window are @@ -682,7 +669,7 @@ an array of structs, which are defined like this: .. code-block:: - typedef struct GZ + struct GZ { half g; float z; @@ -1121,7 +1108,7 @@ demonstrates how to write a deep scan line file with two channels: The size of the image is ``width`` by ``height`` pixels. -.. literalinclude:: src/writeDeepScanlineFile.cpp +.. literalinclude:: src/writeDeepScanLineFile.cpp :language: c++ :linenos: @@ -1171,7 +1158,7 @@ Reading a Deep Scan Line File An example of reading a deep scan line file created by previous code. -.. literalinclude:: src/readDeepScanlineFile.cpp +.. literalinclude:: src/readDeepScanLineFile.cpp :language: c++ :linenos: @@ -1196,8 +1183,8 @@ Writing a Deep Tiled File This example creates an deep tiled file with two channels. It demonstrates how to write a deep tiled file with two channels: -1. type ``FLOAT``, is called Z, and is used for storing sample depth, and -2. type ``HALF``, is called A and is used for storing sample opacity. +1. ``Z``, of type ``FLOAT``, and is used for storing sample depth, and +2. ``A``, type ``HALF``, and is used for storing sample opacity. The size of the image is ``width`` by ``height`` pixels. @@ -1205,11 +1192,11 @@ The size of the image is ``width`` by ``height`` pixels. :language: c++ :linenos: -Here, getSampleCountForTile is a user-supplied function that sets each -item in sampleCount array to the correct sampleCount for each pixel in -the tile, and getSampleDataForTile is a user-supplied function that -set the pointers in dataZ and dataA arrays to point to the correct -data +Here, ``getSampleCountForTile`` is a user-supplied function that sets +each item in ``sampleCount`` array to the correct ``sampleCount`` for +each pixel in the tile, and ``getSampleDataForTile`` is a +user-supplied function that set the pointers in ``dataZ`` and +``dataA`` arrays to point to the correct data The interface for deep tiled files is similar to tiled files. The differences are: @@ -1400,115 +1387,43 @@ stdio file (of type ``FILE``) that has already been opened. To do this, we derive a new class, ``C_IStream``, from ``IStream``. The declaration of class ``IStream`` looks like this: -.. code-block:: +.. literalinclude:: src/IStream.cpp :linenos: - class IStream - { - public: - virtual ~IStream (); - - virtual bool read (char c[], int n) = 0; - virtual uint64_t tellg () = 0; - virtual void seekg (uint64_t pos) = 0; - virtual void clear (); - const char * fileName () const; - virtual bool isMemoryMapped () const; - virtual char * readMemoryMapped (int n); - - protected: - IStream (const char fileName[]); - private: - ... - }; - Our derived class needs a public constructor, and it must override four methods: -.. code-block:: +.. literalinclude:: src/C_IStream.cpp :linenos: - class C_IStream: public IStream - { - public: - C_IStream (FILE *file, const char fileName[]): - IStream (fileName), _file (file) {} - - virtual bool read (char c[], int n); - virtual uint64_t tellg (); - virtual void seekg (uint64_t pos); - virtual void clear (); - - private: - - FILE * _file; - }; - ``read(c,n)`` reads ``n`` bytes from the file, and stores them in array ``c``. If reading hits the end of the file before ``n`` bytes have been read, or if an I/O error occurs, ``read(c,n)`` throws an exception. If ``read(c,n)`` hits the end of the file after reading ``n`` bytes, it returns ``false``, otherwise it returns ``true``: -.. code-block:: +.. literalinclude:: src/C_IStream_read.cpp :linenos: - bool - C_IStream::read (char c[], int n) - { - if (n != fread (c, 1, n, _file)) - { - // fread() failed, but the return value does not distinguish - // between I/O errors and end of file, so we call ferror() to - // determine what happened. - - if (ferror (_file)) - Iex::throwErrnoExc(); - else - throw Iex::InputExc ("Unexpected end of file."); - } - - return !feof (_file); - } - ``tellg()`` returns the current reading position, in bytes, from the beginning of the file. The next ``read()`` call will begin reading at the indicated position: -.. code-block:: +.. literalinclude:: src/C_IStream_tellg.cpp :linenos: - uint64_t - C_IStream::tellg () - { - return ftell (_file); - } - ``seekg(pos)`` sets the current reading position to ``pos`` bytes from the beginning of the file: -.. code-block:: +.. literalinclude:: src/C_IStream_seekg.cpp :linenos: - void - C_IStream::seekg (uint64_t pos) - { - clearerr (_file); - fseek (_file, pos, SEEK_SET); - } - ``clear()`` clears any error flags that may be set on the file after a ``read()`` or ``seekg()`` operation has failed: -.. code-block:: +.. literalinclude:: src/C_IStream_clear.cpp :linenos: - void - C_IStream::clear () - { - clearerr (_file); - } - In order to read an RGBA image from an open C stdio file, we first make a ``C_IStream`` object. Then we create an ``RgbaInputFile``, passing the ``C_IStream`` instead of a file name to the @@ -1543,149 +1458,47 @@ input. In order to do this, a derived class must override two virtual functions, ``isMemoryMapped()`` and ``readMemoryMapped()``, in addition to the functions needed for regular, non-memory-mapped input: -.. code-block:: +.. literalinclude:: src/MemoryMappedIStream.cpp :linenos: - class MemoryMappedIStream: public IStream - { - public: - MemoryMappedIStream (const char fileName[]); - - virtual ~MemoryMappedIStream (); - - virtual bool isMemoryMapped () const; - virtual char * readMemoryMapped (int n); - virtual bool read (char c[], int n); - virtual uint64_t tellg (); - - virtual void seekg (uint64_t pos); - - private: - - char * _buffer; - uint64_t _fileLength; - uint64_t _readPosition; - }; - The constructor for class ``MemoryMappedIStream`` maps the contents of the input file into the program's address space. Memory mapping is not portable across operating systems. The example shown here uses the POSIX ``mmap()`` system call. On Windows files can be memory-mapped by calling ``CreateFileMapping()`` and ``MapViewOfFile()``: -.. code-block:: +.. literalinclude:: src/MemoryMappedIStream_constructor.cpp :linenos: - MemoryMappedIStream::MemoryMappedIStream (const char fileName[]) - : IStream (fileName), - _buffer (0), - _fileLength (0), - _readPosition (0) - { - int file = open (fileName, O_RDONLY); - - if (file < 0) - THROW_ERRNO ("Cannot open file \"" << fileName << "\"."); - - struct stat stat; - fstat (file, &stat); - - _fileLength = stat.st_size; - - _buffer = (char *) mmap (0, _fileLength, PROT_READ, MAP_PRIVATE, file, 0); - - close (file); - - if (_buffer == MAP_FAILED) - THROW_ERRNO ("Cannot memory-map file \"" << fileName << "\"."); - } - The destructor frees the address range associated with the file by un-mapping the file. The POSIX version shown here uses ``munmap()``. A Windows version would call ``UnmapViewOfFile()`` and ``CloseHandle()``: -.. code-block:: +.. literalinclude:: src/MemoryMappedIStream_destructor.cpp :linenos: - MemoryMappedIStream::~MemoryMappedIStream () - { - munmap (_buffer, _fileLength); - } - Function ``isMemoryMapped()`` returns ``true`` to indicate that memory-mapped input is supported. This allows the OpenEXR library to call ``readMemoryMapped()`` instead of ``read()``: -.. code-block:: +.. literalinclude:: src/MemoryMappedIStream_isMemoryMapped.cpp :linenos: - bool - MemoryMappedIStream::isMemoryMapped () const - { - return true; - } - ``readMemoryMapped()`` is analogous to ``read()``, but instead of copying data into a buffer supplied by the caller, ``readMemoryMapped()`` returns a pointer into the memory-mapped file, thus avoiding the copy operation: -.. code-block:: +.. literalinclude:: src/MemoryMappedIStream_readMemoryMapped.cpp :linenos: - char * - MemoryMappedIStream::readMemoryMapped (int n) - { - if (_readPosition >= _fileLength) - throw Iex::InputExc ("Unexpected end of file."); - - if (_readPosition + n > _fileLength) - throw Iex::InputExc ("Reading past end of file."); - - char *data = _buffer + _readPosition; - - _readPosition += n; - - return data; - - } - The ``MemoryMappedIStream`` class must also implement the regular ``read()`` function, as well as ``tellg()`` and ``seekg()``: -.. code-block:: +.. literalinclude:: src/MemoryMappedIStream_read.cpp :linenos: - bool - MemoryMappedIStream::read (char c[], int n) - { - if (_readPosition >= _fileLength) - throw Iex::InputExc ("Unexpected end of file."); - - if (_readPosition + n > _fileLength) - throw Iex::InputExc ("Reading past end of file."); - - memcpy (c, _buffer + _readPosition, n); - - _readPosition += n; - - return _readPosition < _fileLength; - - } - - uint64_t - MemoryMappedIStream::tellg () - { - return _readPosition; - } - - void - MemoryMappedIStream::seekg (uint64_t pos) - { - _readPosition = pos; - } - Class ``MemoryMappedIStream`` does not need a ``clear()`` function. Since the memory-mapped file has no error flags that need to be cleared, the ``clear()`` method provided by class ``IStream``, diff --git a/docs/src/CMakeLists.txt b/docs/src/CMakeLists.txt new file mode 100644 index 0000000000..c46a0f9b71 --- /dev/null +++ b/docs/src/CMakeLists.txt @@ -0,0 +1,11 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright (c) Contributors to the OpenEXR Project. + +add_executable(docs_src all.cpp) +target_link_libraries(docs_src OpenEXR::OpenEXR) +set_target_properties(docs_src PROPERTIES + RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin" +) +if(WIN32 AND BUILD_SHARED_LIBS) + target_compile_definitions(docs_src PRIVATE OPENEXR_DLL) +endif() diff --git a/docs/src/C_IStream.cpp b/docs/src/C_IStream.cpp new file mode 100644 index 0000000000..502c89cb2c --- /dev/null +++ b/docs/src/C_IStream.cpp @@ -0,0 +1,15 @@ +class C_IStream: public IStream +{ + public: + C_IStream (FILE *file, const char fileName[]): + IStream (fileName), _file (file) {} + + virtual bool read (char c[], int n); + virtual uint64_t tellg (); + virtual void seekg (uint64_t pos); + virtual void clear (); + + private: + + FILE * _file; +}; diff --git a/docs/src/C_IStream_clear.cpp b/docs/src/C_IStream_clear.cpp new file mode 100644 index 0000000000..b38c42fe54 --- /dev/null +++ b/docs/src/C_IStream_clear.cpp @@ -0,0 +1,5 @@ +void +C_IStream::clear () +{ + clearerr (_file); +} diff --git a/docs/src/C_IStream_read.cpp b/docs/src/C_IStream_read.cpp new file mode 100644 index 0000000000..7e277db1bf --- /dev/null +++ b/docs/src/C_IStream_read.cpp @@ -0,0 +1,18 @@ +bool +C_IStream::read (char c[], int n) +{ + if (n != static_cast (fread (c, 1, n, _file))) + { + // fread() failed, but the return value does not distinguish + // between I/O errors and end of file, so we call ferror() to + // determine what happened. + + if (ferror (_file)) + Iex::throwErrnoExc(); + else + throw Iex::InputExc ("Unexpected end of file."); + } + + return !feof (_file); +} + diff --git a/docs/src/C_IStream_seekg.cpp b/docs/src/C_IStream_seekg.cpp new file mode 100644 index 0000000000..e5f35c46de --- /dev/null +++ b/docs/src/C_IStream_seekg.cpp @@ -0,0 +1,7 @@ +void +C_IStream::seekg (uint64_t pos) +{ + clearerr (_file); + fseek (_file, pos, SEEK_SET); +} + diff --git a/docs/src/C_IStream_tellg.cpp b/docs/src/C_IStream_tellg.cpp new file mode 100644 index 0000000000..dc42a9763d --- /dev/null +++ b/docs/src/C_IStream_tellg.cpp @@ -0,0 +1,6 @@ +uint64_t +C_IStream::tellg () +{ + return ftell (_file); +} + diff --git a/docs/src/IStream.cpp b/docs/src/IStream.cpp new file mode 100644 index 0000000000..01520ed380 --- /dev/null +++ b/docs/src/IStream.cpp @@ -0,0 +1,20 @@ +class IStream +{ + public: + virtual ~IStream (); + + virtual bool read (char c[], int n) = 0; + virtual uint64_t tellg () = 0; + virtual void seekg (uint64_t pos) = 0; + virtual void clear (); + const char * fileName () const; + virtual bool isMemoryMapped () const; + virtual char * readMemoryMapped (int n); + + protected: + IStream (const char fileName[]); + private: + + // ... +}; + diff --git a/docs/src/MemoryMappedIStream.cpp b/docs/src/MemoryMappedIStream.cpp new file mode 100644 index 0000000000..1872ae14c5 --- /dev/null +++ b/docs/src/MemoryMappedIStream.cpp @@ -0,0 +1,21 @@ +class MemoryMappedIStream: public IStream +{ + public: + MemoryMappedIStream (const char fileName[]); + + virtual ~MemoryMappedIStream (); + + virtual bool isMemoryMapped () const; + virtual char * readMemoryMapped (int n); + virtual bool read (char c[], int n); + virtual uint64_t tellg (); + + virtual void seekg (uint64_t pos); + + private: + + char * _buffer; + uint64_t _fileLength; + uint64_t _readPosition; +}; + diff --git a/docs/src/MemoryMappedIStream_constructor.cpp b/docs/src/MemoryMappedIStream_constructor.cpp new file mode 100644 index 0000000000..8841200819 --- /dev/null +++ b/docs/src/MemoryMappedIStream_constructor.cpp @@ -0,0 +1,23 @@ +MemoryMappedIStream::MemoryMappedIStream (const char fileName[]) + : IStream (fileName), + _buffer (0), + _fileLength (0), + _readPosition (0) +{ + int file = open (fileName, O_RDONLY); + + if (file < 0) + THROW_ERRNO ("Cannot open file \"" << fileName << "\"."); + + struct stat stat; + fstat (file, &stat); + + _fileLength = stat.st_size; + + _buffer = (char *) mmap (0, _fileLength, PROT_READ, MAP_PRIVATE, file, 0); + + close (file); + + if (_buffer == MAP_FAILED) + THROW_ERRNO ("Cannot memory-map file \"" << fileName << "\"."); +} diff --git a/docs/src/MemoryMappedIStream_destructor.cpp b/docs/src/MemoryMappedIStream_destructor.cpp new file mode 100644 index 0000000000..fbef097049 --- /dev/null +++ b/docs/src/MemoryMappedIStream_destructor.cpp @@ -0,0 +1,5 @@ +bool +MemoryMappedIStream::isMemoryMapped () const +{ + return true; +} diff --git a/docs/src/MemoryMappedIStream_isMemoryMapped.cpp b/docs/src/MemoryMappedIStream_isMemoryMapped.cpp new file mode 100644 index 0000000000..064f706a24 --- /dev/null +++ b/docs/src/MemoryMappedIStream_isMemoryMapped.cpp @@ -0,0 +1,4 @@ +MemoryMappedIStream::~MemoryMappedIStream() +{ + munmap (_buffer, _fileLength); +} diff --git a/docs/src/MemoryMappedIStream_read.cpp b/docs/src/MemoryMappedIStream_read.cpp new file mode 100644 index 0000000000..7c2e4e9016 --- /dev/null +++ b/docs/src/MemoryMappedIStream_read.cpp @@ -0,0 +1,29 @@ +bool +MemoryMappedIStream::read (char c[], int n) +{ + if (_readPosition >= _fileLength) + throw Iex::InputExc ("Unexpected end of file."); + + if (_readPosition + n > _fileLength) + throw Iex::InputExc ("Reading past end of file."); + + memcpy (c, _buffer + _readPosition, n); + + _readPosition += n; + + return _readPosition < _fileLength; + +} + +uint64_t +MemoryMappedIStream::tellg () +{ + return _readPosition; +} + +void +MemoryMappedIStream::seekg (uint64_t pos) +{ + _readPosition = pos; +} + diff --git a/docs/src/MemoryMappedIStream_readMemoryMapped.cpp b/docs/src/MemoryMappedIStream_readMemoryMapped.cpp new file mode 100644 index 0000000000..e5fd93595e --- /dev/null +++ b/docs/src/MemoryMappedIStream_readMemoryMapped.cpp @@ -0,0 +1,17 @@ +char * +MemoryMappedIStream::readMemoryMapped (int n) +{ + if (_readPosition >= _fileLength) + throw Iex::InputExc ("Unexpected end of file."); + + if (_readPosition + n > _fileLength) + throw Iex::InputExc ("Reading past end of file."); + + char *data = _buffer + _readPosition; + + _readPosition += n; + + return data; + +} + diff --git a/docs/src/all.cpp b/docs/src/all.cpp new file mode 100644 index 0000000000..1411074e00 --- /dev/null +++ b/docs/src/all.cpp @@ -0,0 +1,101 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +#include +#include +#include +#include +#include +#include + +using namespace Imath; +using namespace Imf; + +struct GZ +{ + half g; + float z; +}; + +int +getPixelSampleCount(int i, int j) +{ + return 0; +} + +void +getPixelSampleData(int i, int j, Array2D& dataZ, Array2D& dataA) +{ +} + +int +getSampleCountForTile(int i, int j, Array2D& sampleCount) +{ + return 0; +} + +void +getSampleDataForTile(int i, int j, int tileSizeX, int tileSizeY, + Array2D& sampleCount, + Array2D& dataZ, Array2D& dataA) +{ +} + + +namespace XXX { +#include "IStream.cpp" +} + +#include "C_IStream.cpp" +#include "C_IStream_clear.cpp" +#include "C_IStream_read.cpp" +#include "C_IStream_seekg.cpp" +#include "C_IStream_tellg.cpp" +#include "makePreviewImage.cpp" +#include "MemoryMappedIStream.cpp" +#include "MemoryMappedIStream_isMemoryMapped.cpp" +#include "MemoryMappedIStream_destructor.cpp" +#include "MemoryMappedIStream_constructor.cpp" +#include "MemoryMappedIStream_read.cpp" +#include "MemoryMappedIStream_readMemoryMapped.cpp" +#include "mergeOverlappingSamples.cpp" +#include "readDeepScanLineFile.cpp" +#include "readDeepTiledFile.cpp" +#include "readGZ1.cpp" +#include "readGZ2.cpp" +#include "readHeader.cpp" +#include "readRgba1.cpp" +#include "readRgba2.cpp" +#include "readRgbaFILE.cpp" +#include "readTiled1.cpp" +#include "readTiledRgba1.cpp" +#include "splitVolumeSample.cpp" +#include "writeDeepScanLineFile.cpp" +#include "writeDeepTiledFile.cpp" +#include "writeGZ1.cpp" +#include "writeGZ2.cpp" +#include "writeRgba1.cpp" +#include "writeRgba2.cpp" + +int +main(int argc, char* argv[]) +{ +} diff --git a/docs/src/file.cpp b/docs/src/file.cpp deleted file mode 100644 index 8158cd3434..0000000000 --- a/docs/src/file.cpp +++ /dev/null @@ -1,55 +0,0 @@ -void -readGZ1 ( - const char fileName[], - Array2D& rPixels, - Array2D& gPixels, - Array2D& zPixels, - int& width, - int& height) - -{ - InputFile file (fileName); - - Box2i dw = file.header ().dataWindow (); - width = dw.max.x - dw.min.x + 1; - height = dw.max.y - dw.min.y + 1; - - rPixels.resizeErase (height, width); - gPixels.resizeErase (height, width); - zPixels.resizeErase (height, width); - - FrameBuffer frameBuffer; - - frameBuffer.insert ("R", // name - Slice (HALF, // type - (char *) (&rPixels[0][0] - // base - dw.min.x - - dw.min.y * width), - sizeof (rPixels[0][0]) * 1, // xStride - sizeof (rPixels[0][0]) * width, // yStride - 1, 1, // x/y sampling - 0.0)); // fillValue - - frameBuffer.insert ("G", // name - Slice (HALF, // type - (char *) (&gPixels[0][0] - // base - dw.min.x - - dw.min.y * width), - sizeof (gPixels[0][0]) * 1, // xStride - sizeof (gPixels[0][0]) * width, // yStride - 1, 1, // x/y sampling - 0.0)); // fillValue - - frameBuffer.insert ("Z", // name - Slice (FLOAT, // type - (char *) (&zPixels[0][0] - // base - dw.min.x - - dw.min.y * width), - sizeof (zPixels[0][0]) * 1, // xStride - sizeof (zPixels[0][0]) * width, // yStride - 1, 1, // x/y sampling - FLT_MAX)); // fillValue - - file.setFrameBuffer (frameBuffer); - file.readPixels (dw.min.y, dw.max.y); -} diff --git a/docs/src/makePreviewImage.cpp b/docs/src/makePreviewImage.cpp index 9195118bcf..5c61f372b2 100644 --- a/docs/src/makePreviewImage.cpp +++ b/docs/src/makePreviewImage.cpp @@ -25,7 +25,7 @@ makePreviewImage ( 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); } } } diff --git a/docs/src/readDeepScanlineFile.cpp b/docs/src/readDeepScanLineFile.cpp similarity index 98% rename from docs/src/readDeepScanlineFile.cpp rename to docs/src/readDeepScanLineFile.cpp index e77c08cbb8..06e9483807 100644 --- a/docs/src/readDeepScanlineFile.cpp +++ b/docs/src/readDeepScanLineFile.cpp @@ -1,5 +1,5 @@ void -readDeepScanlineFile ( +readDeepScanLineFile ( const char filename[], Box2i& displayWindow, Box2i& dataWindow, diff --git a/docs/src/readRgba2.cpp b/docs/src/readRgba2.cpp index 1ff7960183..64ad1d946e 100644 --- a/docs/src/readRgba2.cpp +++ b/docs/src/readRgba2.cpp @@ -5,7 +5,6 @@ readRgba2 (const char fileName[]) Box2i dw = file.dataWindow (); int width = dw.max.x - dw.min.x + 1; - int height = dw.max.y - dw.min.y + 1; Array2D pixels (10, width); while (dw.min.y <= dw.max.y) diff --git a/docs/src/writeDeepScanlineFile.cpp b/docs/src/writeDeepScanLineFile.cpp similarity index 98% rename from docs/src/writeDeepScanlineFile.cpp rename to docs/src/writeDeepScanLineFile.cpp index 201e2ce770..026a16fe48 100644 --- a/docs/src/writeDeepScanlineFile.cpp +++ b/docs/src/writeDeepScanLineFile.cpp @@ -1,5 +1,5 @@ void -writeDeepScanlineFile ( +writeDeepScanLineFile ( const char filename[], Box2i displayWindow, Box2i dataWindow, diff --git a/docs/src/writeTiledRgbaMIP1.cpp b/docs/src/writeTiledRgbaMIP1.cpp index 2b761df72f..f9f5407dbb 100644 --- a/docs/src/writeTiledRgbaMIP1.cpp +++ b/docs/src/writeTiledRgbaMIP1.cpp @@ -22,9 +22,9 @@ writeTiledRgbaMIP1 ( out.writeTiles ( 0, - out.numXTiles (level) – 1, // 6 + out.numXTiles (level) - 1, // 6 0, - out.numYTiles (level) – 1, + out.numYTiles (level) - 1, level); } }