Support for saving TIFFs as BigTIFF (#6690)
This commit is contained in:
@@ -17,21 +17,17 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with RawTherapee. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#include <png.h>
|
||||
#include <glib/gstdio.h>
|
||||
#include <tiff.h>
|
||||
#include <tiffio.h>
|
||||
#include <cstdio>
|
||||
#include <cstring>
|
||||
#include <fcntl.h>
|
||||
#include <libiptcdata/iptc-jpeg.h>
|
||||
#include <memory>
|
||||
#include "rt_math.h"
|
||||
#include "procparams.h"
|
||||
#include "utils.h"
|
||||
#include "../rtgui/options.h"
|
||||
#include "../rtgui/version.h"
|
||||
#include "../rtexif/rtexif.h"
|
||||
#include <string>
|
||||
|
||||
#include <fcntl.h>
|
||||
#include <glib/gstdio.h>
|
||||
#include <libiptcdata/iptc-jpeg.h>
|
||||
#include <png.h>
|
||||
#include <tiff.h>
|
||||
#include <tiffio.h>
|
||||
|
||||
#ifdef WIN32
|
||||
#include <winsock2.h>
|
||||
@@ -39,12 +35,20 @@
|
||||
#include <netinet/in.h>
|
||||
#endif
|
||||
|
||||
#include "color.h"
|
||||
#include "iccjpeg.h"
|
||||
#include "imageio.h"
|
||||
#include "iptcpairs.h"
|
||||
#include "iccjpeg.h"
|
||||
#include "color.h"
|
||||
|
||||
#include "jpeg.h"
|
||||
#include "procparams.h"
|
||||
#include "rt_math.h"
|
||||
#include "utils.h"
|
||||
|
||||
#include "../rtgui/options.h"
|
||||
#include "../rtgui/version.h"
|
||||
|
||||
#include "../rtexif/rtexif.h"
|
||||
|
||||
|
||||
using namespace std;
|
||||
using namespace rtengine;
|
||||
@@ -1328,7 +1332,13 @@ int ImageIO::saveJPEG (const Glib::ustring &fname, int quality, int subSamp) con
|
||||
return IMIO_SUCCESS;
|
||||
}
|
||||
|
||||
int ImageIO::saveTIFF (const Glib::ustring &fname, int bps, bool isFloat, bool uncompressed) const
|
||||
int ImageIO::saveTIFF (
|
||||
const Glib::ustring &fname,
|
||||
int bps,
|
||||
bool isFloat,
|
||||
bool uncompressed,
|
||||
bool big
|
||||
) const
|
||||
{
|
||||
if (getWidth() < 1 || getHeight() < 1) {
|
||||
return IMIO_HEADERERROR;
|
||||
@@ -1345,15 +1355,28 @@ int ImageIO::saveTIFF (const Glib::ustring &fname, int bps, bool isFloat, bool u
|
||||
int lineWidth = width * 3 * bps / 8;
|
||||
unsigned char* linebuffer = new unsigned char[lineWidth];
|
||||
|
||||
std::string mode = "w";
|
||||
|
||||
// little hack to get libTiff to use proper byte order (see TIFFClienOpen()):
|
||||
const char *mode = !exifRoot ? "w" : (exifRoot->getOrder() == rtexif::INTEL ? "wl" : "wb");
|
||||
if (exifRoot) {
|
||||
if (exifRoot->getOrder() == rtexif::INTEL) {
|
||||
mode += 'l';
|
||||
} else {
|
||||
mode += 'b';
|
||||
}
|
||||
}
|
||||
|
||||
if (big) {
|
||||
mode += '8';
|
||||
}
|
||||
|
||||
#ifdef WIN32
|
||||
FILE *file = g_fopen_withBinaryAndLock (fname);
|
||||
int fileno = _fileno(file);
|
||||
int osfileno = _get_osfhandle(fileno);
|
||||
TIFF* out = TIFFFdOpen (osfileno, fname.c_str(), mode);
|
||||
TIFF* out = TIFFFdOpen (osfileno, fname.c_str(), mode.c_str());
|
||||
#else
|
||||
TIFF* out = TIFFOpen(fname.c_str(), mode);
|
||||
TIFF* out = TIFFOpen(fname.c_str(), mode.c_str());
|
||||
int fileno = TIFFFileno (out);
|
||||
#endif
|
||||
|
||||
|
Reference in New Issue
Block a user