Merge branch 'master' into pixelshift
This commit is contained in:
@@ -46,8 +46,6 @@ ImageMetaData* ImageMetaData::fromFile (const Glib::ustring& fname, RawMetaDataL
|
|||||||
|
|
||||||
ImageData::ImageData (Glib::ustring fname, RawMetaDataLocation* ri) : iso_speed(0), aperture(0.), shutter(0.)
|
ImageData::ImageData (Glib::ustring fname, RawMetaDataLocation* ri) : iso_speed(0), aperture(0.), shutter(0.)
|
||||||
{
|
{
|
||||||
|
|
||||||
size_t dotpos = fname.find_last_of ('.');
|
|
||||||
root = nullptr;
|
root = nullptr;
|
||||||
iptc = nullptr;
|
iptc = nullptr;
|
||||||
|
|
||||||
@@ -72,7 +70,7 @@ ImageData::ImageData (Glib::ustring fname, RawMetaDataLocation* ri) : iso_speed(
|
|||||||
fclose (f);
|
fclose (f);
|
||||||
extractInfo ();
|
extractInfo ();
|
||||||
}
|
}
|
||||||
} else if ((dotpos < fname.size() - 3 && !fname.casefold().compare (dotpos, 4, ".jpg")) || (dotpos < fname.size() - 4 && !fname.casefold().compare (dotpos, 5, ".jpeg"))) {
|
} else if (hasJpegExtension(fname)) {
|
||||||
FILE* f = g_fopen (fname.c_str (), "rb");
|
FILE* f = g_fopen (fname.c_str (), "rb");
|
||||||
|
|
||||||
if (f) {
|
if (f) {
|
||||||
@@ -83,7 +81,7 @@ ImageData::ImageData (Glib::ustring fname, RawMetaDataLocation* ri) : iso_speed(
|
|||||||
iptc = iptc_data_new_from_jpeg_file (ff);
|
iptc = iptc_data_new_from_jpeg_file (ff);
|
||||||
fclose (ff);
|
fclose (ff);
|
||||||
}
|
}
|
||||||
} else if ((dotpos < fname.size() - 3 && !fname.casefold().compare (dotpos, 4, ".tif")) || (dotpos < fname.size() - 4 && !fname.casefold().compare (dotpos, 5, ".tiff"))) {
|
} else if (hasTiffExtension(fname)) {
|
||||||
FILE* f = g_fopen (fname.c_str (), "rb");
|
FILE* f = g_fopen (fname.c_str (), "rb");
|
||||||
|
|
||||||
if (f) {
|
if (f) {
|
||||||
|
@@ -1441,19 +1441,11 @@ void png_flush(png_structp png_ptr)
|
|||||||
int ImageIO::load (Glib::ustring fname)
|
int ImageIO::load (Glib::ustring fname)
|
||||||
{
|
{
|
||||||
|
|
||||||
size_t lastdot = fname.find_last_of ('.');
|
if (hasPngExtension(fname)) {
|
||||||
|
|
||||||
if( Glib::ustring::npos == lastdot ) {
|
|
||||||
return IMIO_FILETYPENOTSUPPORTED;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!fname.casefold().compare (lastdot, 4, ".png")) {
|
|
||||||
return loadPNG (fname);
|
return loadPNG (fname);
|
||||||
} else if (!fname.casefold().compare (lastdot, 4, ".jpg") ||
|
} else if (hasJpegExtension(fname)) {
|
||||||
!fname.casefold().compare (lastdot, 5, ".jpeg")) {
|
|
||||||
return loadJPEG (fname);
|
return loadJPEG (fname);
|
||||||
} else if (!fname.casefold().compare (lastdot, 4, ".tif") ||
|
} else if (hasTiffExtension(fname)) {
|
||||||
!fname.casefold().compare (lastdot, 5, ".tiff")) {
|
|
||||||
return loadTIFF (fname);
|
return loadTIFF (fname);
|
||||||
} else {
|
} else {
|
||||||
return IMIO_FILETYPENOTSUPPORTED;
|
return IMIO_FILETYPENOTSUPPORTED;
|
||||||
@@ -1462,20 +1454,11 @@ int ImageIO::load (Glib::ustring fname)
|
|||||||
|
|
||||||
int ImageIO::save (Glib::ustring fname)
|
int ImageIO::save (Glib::ustring fname)
|
||||||
{
|
{
|
||||||
|
if (hasPngExtension(fname)) {
|
||||||
size_t lastdot = fname.find_last_of ('.');
|
|
||||||
|
|
||||||
if( Glib::ustring::npos == lastdot ) {
|
|
||||||
return IMIO_FILETYPENOTSUPPORTED;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!fname.casefold().compare (lastdot, 4, ".png")) {
|
|
||||||
return savePNG (fname);
|
return savePNG (fname);
|
||||||
} else if (!fname.casefold().compare (lastdot, 4, ".jpg") ||
|
} else if (hasJpegExtension(fname)) {
|
||||||
!fname.casefold().compare (lastdot, 5, ".jpeg")) {
|
|
||||||
return saveJPEG (fname);
|
return saveJPEG (fname);
|
||||||
} else if (!fname.casefold().compare (lastdot, 4, ".tif") ||
|
} else if (hasTiffExtension(fname)) {
|
||||||
!fname.casefold().compare (lastdot, 5, ".tiff")) {
|
|
||||||
return saveTIFF (fname);
|
return saveTIFF (fname);
|
||||||
} else {
|
} else {
|
||||||
return IMIO_FILETYPENOTSUPPORTED;
|
return IMIO_FILETYPENOTSUPPORTED;
|
||||||
|
@@ -74,27 +74,19 @@ void StdImageSource::getSampleFormat (const Glib::ustring &fname, IIOSampleForma
|
|||||||
sFormat = IIOSF_UNKNOWN;
|
sFormat = IIOSF_UNKNOWN;
|
||||||
sArrangement = IIOSA_UNKNOWN;
|
sArrangement = IIOSA_UNKNOWN;
|
||||||
|
|
||||||
size_t lastdot = fname.find_last_of ('.');
|
if (hasJpegExtension(fname)) {
|
||||||
|
|
||||||
if( Glib::ustring::npos == lastdot ) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!fname.casefold().compare (lastdot, 4, ".jpg") ||
|
|
||||||
!fname.casefold().compare (lastdot, 5, ".jpeg")) {
|
|
||||||
// For now, png and jpeg files are converted to unsigned short by the loader itself,
|
// For now, png and jpeg files are converted to unsigned short by the loader itself,
|
||||||
// but there should be functions that read the sample format first, like the TIFF case below
|
// but there should be functions that read the sample format first, like the TIFF case below
|
||||||
sFormat = IIOSF_UNSIGNED_CHAR;
|
sFormat = IIOSF_UNSIGNED_CHAR;
|
||||||
sArrangement = IIOSA_CHUNKY;
|
sArrangement = IIOSA_CHUNKY;
|
||||||
return;
|
return;
|
||||||
} else if (!fname.casefold().compare (lastdot, 4, ".png")) {
|
} else if (hasPngExtension(fname)) {
|
||||||
int result = ImageIO::getPNGSampleFormat (fname, sFormat, sArrangement);
|
int result = ImageIO::getPNGSampleFormat (fname, sFormat, sArrangement);
|
||||||
|
|
||||||
if (result == IMIO_SUCCESS) {
|
if (result == IMIO_SUCCESS) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} else if (!fname.casefold().compare (lastdot, 4, ".tif") ||
|
} else if (hasTiffExtension(fname)) {
|
||||||
!fname.casefold().compare (lastdot, 5, ".tiff")) {
|
|
||||||
int result = ImageIO::getTIFFSampleFormat (fname, sFormat, sArrangement);
|
int result = ImageIO::getTIFFSampleFormat (fname, sFormat, sArrangement);
|
||||||
|
|
||||||
if (result == IMIO_SUCCESS) {
|
if (result == IMIO_SUCCESS) {
|
||||||
|
@@ -76,7 +76,6 @@ void poke01_f(unsigned char* &dest, float r, float g, float b)
|
|||||||
|
|
||||||
void bilinearInterp(const unsigned char* src, int sw, int sh, unsigned char* dst, int dw, int dh)
|
void bilinearInterp(const unsigned char* src, int sw, int sh, unsigned char* dst, int dw, int dh)
|
||||||
{
|
{
|
||||||
|
|
||||||
int ix = 0;
|
int ix = 0;
|
||||||
|
|
||||||
for (int i = 0; i < dh; i++) {
|
for (int i = 0; i < dh; i++) {
|
||||||
@@ -134,7 +133,6 @@ void bilinearInterp (const unsigned char* src, int sw, int sh, unsigned char* ds
|
|||||||
|
|
||||||
void nearestInterp(const unsigned char* src, int sw, int sh, unsigned char* dst, int dw, int dh)
|
void nearestInterp(const unsigned char* src, int sw, int sh, unsigned char* dst, int dw, int dh)
|
||||||
{
|
{
|
||||||
|
|
||||||
int ix = 0;
|
int ix = 0;
|
||||||
|
|
||||||
for (int i = 0; i < dh; i++) {
|
for (int i = 0; i < dh; i++) {
|
||||||
@@ -152,7 +150,6 @@ void nearestInterp (const unsigned char* src, int sw, int sh, unsigned char* dst
|
|||||||
|
|
||||||
void rotate(unsigned char* img, int& w, int& h, int deg)
|
void rotate(unsigned char* img, int& w, int& h, int deg)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (deg == 0) {
|
if (deg == 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -192,7 +189,6 @@ void rotate (unsigned char* img, int& w, int& h, int deg)
|
|||||||
|
|
||||||
void hflip(unsigned char* img, int w, int h)
|
void hflip(unsigned char* img, int w, int h)
|
||||||
{
|
{
|
||||||
|
|
||||||
unsigned char* flipped = new unsigned char[3 * w * h];
|
unsigned char* flipped = new unsigned char[3 * w * h];
|
||||||
int ix = 0;
|
int ix = 0;
|
||||||
|
|
||||||
@@ -209,7 +205,6 @@ void hflip (unsigned char* img, int w, int h)
|
|||||||
|
|
||||||
void vflip(unsigned char* img, int w, int h)
|
void vflip(unsigned char* img, int w, int h)
|
||||||
{
|
{
|
||||||
|
|
||||||
unsigned char* flipped = new unsigned char[3 * w * h];
|
unsigned char* flipped = new unsigned char[3 * w * h];
|
||||||
int ix = 0;
|
int ix = 0;
|
||||||
|
|
||||||
@@ -224,6 +219,30 @@ void vflip (unsigned char* img, int w, int h)
|
|||||||
delete[] flipped;
|
delete[] flipped;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Glib::ustring getFileExtension(const Glib::ustring& filename)
|
||||||
|
{
|
||||||
|
const Glib::ustring::size_type lastdot_pos = filename.find_last_of('.');
|
||||||
|
return
|
||||||
|
lastdot_pos != Glib::ustring::npos
|
||||||
|
? filename.substr(lastdot_pos + 1).lowercase()
|
||||||
|
: Glib::ustring();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool hasJpegExtension(const Glib::ustring& filename)
|
||||||
|
{
|
||||||
|
const Glib::ustring extension = getFileExtension(filename);
|
||||||
|
return extension == "jpg" || extension == "jpeg";
|
||||||
|
}
|
||||||
|
|
||||||
|
bool hasTiffExtension(const Glib::ustring& filename)
|
||||||
|
{
|
||||||
|
const Glib::ustring extension = getFileExtension(filename);
|
||||||
|
return extension == "tif" || extension == "tiff";
|
||||||
|
}
|
||||||
|
|
||||||
|
bool hasPngExtension(const Glib::ustring& filename)
|
||||||
|
{
|
||||||
|
return getFileExtension(filename) == "png";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
@@ -19,15 +19,16 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
|
#include <glibmm/ustring.h>
|
||||||
|
|
||||||
namespace rtengine
|
namespace rtengine
|
||||||
{
|
{
|
||||||
|
|
||||||
// update a point of a Cairo::Surface by accessing the raw data
|
// Update a point of a Cairo::Surface by accessing the raw data
|
||||||
void poke255_uc(unsigned char*& dest, unsigned char r, unsigned char g, unsigned char b);
|
void poke255_uc(unsigned char*& dest, unsigned char r, unsigned char g, unsigned char b);
|
||||||
// update a point of a Cairo::Surface by accessing the raw data
|
// Update a point of a Cairo::Surface by accessing the raw data
|
||||||
void poke01_d(unsigned char*& dest, double r, double g, double b);
|
void poke01_d(unsigned char*& dest, double r, double g, double b);
|
||||||
// update a point of a Cairo::Surface by accessing the raw data
|
// Update a point of a Cairo::Surface by accessing the raw data
|
||||||
void poke01_f(unsigned char*& dest, float r, float g, float b);
|
void poke01_f(unsigned char*& dest, float r, float g, float b);
|
||||||
|
|
||||||
void bilinearInterp(const unsigned char* src, int sw, int sh, unsigned char* dst, int dw, int dh);
|
void bilinearInterp(const unsigned char* src, int sw, int sh, unsigned char* dst, int dw, int dh);
|
||||||
@@ -42,4 +43,13 @@ typename std::underlying_type<ENUM>::type toUnderlying(ENUM value)
|
|||||||
return static_cast<typename std::underlying_type<ENUM>::type>(value);
|
return static_cast<typename std::underlying_type<ENUM>::type>(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Return lower case extension without the "." or "" if the given name contains no "."
|
||||||
|
Glib::ustring getFileExtension(const Glib::ustring& filename);
|
||||||
|
// Return true if file has .jpeg or .jpg extension (ignoring case)
|
||||||
|
bool hasJpegExtension(const Glib::ustring& filename);
|
||||||
|
// Return true if file has .tiff or .tif extension (ignoring case)
|
||||||
|
bool hasTiffExtension(const Glib::ustring& filename);
|
||||||
|
// Return true if file has .png extension (ignoring case)
|
||||||
|
bool hasPngExtension(const Glib::ustring& filename);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -269,7 +269,6 @@ int ProfileStore::findFolderId(const Glib::ustring &path)
|
|||||||
*/
|
*/
|
||||||
const ProfileStoreEntry* ProfileStore::findEntryFromFullPathU(Glib::ustring path)
|
const ProfileStoreEntry* ProfileStore::findEntryFromFullPathU(Glib::ustring path)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (path.empty()) {
|
if (path.empty()) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
@@ -278,12 +277,18 @@ const ProfileStoreEntry* ProfileStore::findEntryFromFullPathU(Glib::ustring path
|
|||||||
return internalDefaultEntry;
|
return internalDefaultEntry;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t lastdot = path.find_last_of ('.');
|
// consistently apply casefold() to make sure dot position is correct
|
||||||
|
const Glib::ustring casefolded_path = path.casefold();
|
||||||
|
const Glib::ustring::size_type lastdot_pos = casefolded_path.find_last_of('.');
|
||||||
|
|
||||||
if (lastdot != Glib::ustring::npos && lastdot <= path.size() - 4 && !path.casefold().compare (lastdot, 4, paramFileExtension))
|
if (
|
||||||
// removing the extension
|
lastdot_pos != Glib::ustring::npos
|
||||||
|
&& lastdot_pos <= casefolded_path.size() - 4
|
||||||
|
&& !casefolded_path.compare(lastdot_pos, 4, paramFileExtension))
|
||||||
{
|
{
|
||||||
path = path.substr(0, lastdot);
|
// removing the extension
|
||||||
|
// now use dot position without casefold()
|
||||||
|
path = path.substr(0, path.find_last_of('.'));
|
||||||
}
|
}
|
||||||
|
|
||||||
// dir separator may come from options file and may be \ or /, we convert them to G_DIR_SEPARATOR_S
|
// dir separator may come from options file and may be \ or /, we convert them to G_DIR_SEPARATOR_S
|
||||||
|
Reference in New Issue
Block a user