1 /*
2 * This file is part of RawTherapee.
3 *
4 * Copyright (c) 2004-2010 Gabor Horvath <hgabor@rawtherapee.com>
5 *
6 * RawTherapee is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * RawTherapee is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with RawTherapee. If not, see <https://www.gnu.org/licenses/>.
18 */
19 #pragma once
20
21 #include <type_traits>
22 #include <glibmm/ustring.h>
23
24 namespace rtengine
25 {
26
27 // Update a point of a Cairo::Surface by accessing the raw data
28 void poke255_uc(unsigned char*& dest, unsigned char r, unsigned char g, unsigned char b);
29 // Update a point of a Cairo::Surface by accessing the raw data
30 void poke01_d(unsigned char*& dest, double r, double g, double b);
31 // Update a point of a Cairo::Surface by accessing the raw data
32 void poke01_f(unsigned char*& dest, float r, float g, float b);
33
34 void bilinearInterp(const unsigned char* src, int sw, int sh, unsigned char* dst, int dw, int dh);
35 void nearestInterp(const unsigned char* src, int sw, int sh, unsigned char* dst, int dw, int dh);
36 void rotate(unsigned char* img, int& w, int& h, int deg);
37 void hflip(unsigned char* img, int w, int h);
38 void vflip(unsigned char* img, int w, int h);
39
40 template<typename ENUM>
toUnderlying(ENUM value)41 constexpr typename std::underlying_type<ENUM>::type toUnderlying(ENUM value)
42 {
43 return static_cast<typename std::underlying_type<ENUM>::type>(value);
44 }
45
46 // Return lower case extension without the "." or "" if the given name contains no "."
47 Glib::ustring getFileExtension(const Glib::ustring& filename);
48 // Return true if file has .jpeg or .jpg extension (ignoring case)
49 bool hasJpegExtension(const Glib::ustring& filename);
50 // Return true if file has .tiff or .tif extension (ignoring case)
51 bool hasTiffExtension(const Glib::ustring& filename);
52 // Return true if file has .png extension (ignoring case)
53 bool hasPngExtension(const Glib::ustring& filename);
54
55 void swab(const void* from, void* to, ssize_t n);
56
57 }
58
59 #if __SIZEOF_WCHAR_T__ == 4
60 Glib::ustring utf32_to_utf8(wchar_t* UTF32Buffer, size_t sizeOfUTF32Buffer);
61 #endif
62
63