MRaster examples 21.0.0.0
Image Processing Library
Loading...
Searching...
No Matches
convertRawToTIFF.cpp
Go to the documentation of this file.
1// -*- Mode:C++; Coding:us-ascii-unix; fill-column:158 -*-
2/*******************************************************************************************************************************************************.H.S.**/
3/**
4 @file convertRawToTIFF.cpp
5 @author Mitch Richling http://www.mitchr.me/
6 @brief Demonstrate how load a floating point RAW file and save it as an integer TIFF.@EOL
7 @keywords MRaster
8 @std C++20
9 @copyright
10 @parblock
11 Copyright (c) 2022, Mitchell Jay Richling <http://www.mitchr.me/> All rights reserved.
12
13 Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
14
15 1. Redistributions of source code must retain the above copyright notice, this list of conditions, and the following disclaimer.
16
17 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software
21 without specific prior written permission.
22
23 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
25 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26 OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27 LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
28 DAMAGE.
29 @endparblock
30*/
31/*******************************************************************************************************************************************************.H.E.**/
32
33//--------------------------------------------------------------------------------------------------------------------------------------------------------------
34#include "ramCanvas.hpp"
35
36//--------------------------------------------------------------------------------------------------------------------------------------------------------------
37int main(int argc, char *argv[]) {
38 mjr::ramCanvas3c32F theRamCanvas;
39 std::string fileName;
40
41 if (argc < 2)
42 fileName = "../data/utest/ut-draw_primatives_flt.mrw"; // This file is used for unit tests -- a handy 32-bit raw image. ;)
43 else
44 fileName = argv[1];
45
46 int ret;
47
48 ret = theRamCanvas.readRAWfile(fileName);
49 if (ret != 0) {
50 std::cout << "ERROR(readRAWfile): " << ret << std::endl;
51 return ret;
52 }
53
54 // We create a converter object for the *two* file write methods below. This converter will transform the 32-bit floating point channels into 8-bit
55 // unsigned integer channels.
56 mjr::ramCanvas3c32F::rcConverterRGBbyte<mjr::ramCanvas3c32F> rcConv(theRamCanvas);
57
58 ret = theRamCanvas.writeRAWfile("foo.mrw", rcConv);
59 if (ret != 0) {
60 std::cout << "ERROR(writeRAWfile): " << ret << std::endl;
61 return ret;
62 }
63
64 // Note: For the more complex writeTIFFfile() method, the markAlpha argument is not optional.
65 ret = theRamCanvas.writeTIFFfile("foo.tiff", rcConv, false);
66 if (ret != 0) {
67 std::cout << "ERROR(writeTIFFfile): " << ret << std::endl;
68 return ret;
69 }
70
71 return 0;
72}
int main(int argc, char *argv[])