diff --git a/rtengine/imageio.cc b/rtengine/imageio.cc index f869a0f3e..e886dabce 100644 --- a/rtengine/imageio.cc +++ b/rtengine/imageio.cc @@ -556,11 +556,13 @@ int ImageIO::loadJPEG (Glib::ustring fname) jpeg_read_header(&cinfo, TRUE); //if JPEG is CMYK, then abort reading - if (cinfo.jpeg_color_space == JCS_CMYK || cinfo.jpeg_color_space == JCS_YCCK || cinfo.jpeg_color_space == JCS_GRAYSCALE) { + if (cinfo.jpeg_color_space == JCS_CMYK || cinfo.jpeg_color_space == JCS_YCCK) { jpeg_destroy_decompress(&cinfo); return IMIO_READERROR; } + cinfo.out_color_space = JCS_RGB; + deleteLoadedProfileData(); loadedProfileDataJpg = true; bool hasprofile = read_icc_profile (&cinfo, (JOCTET**)&loadedProfileData, (unsigned int*)&loadedProfileLength); @@ -677,8 +679,8 @@ int ImageIO::getTIFFSampleFormat (Glib::ustring fname, IIOSampleFormat &sFormat, TIFFClose(in); - if (photometric == PHOTOMETRIC_RGB) { - if ((samplesperpixel == 3 || samplesperpixel == 4) && sampleformat == SAMPLEFORMAT_UINT) { + if (photometric == PHOTOMETRIC_RGB || photometric == PHOTOMETRIC_MINISBLACK) { + if ((samplesperpixel == 1 || samplesperpixel == 3 || samplesperpixel == 4) && sampleformat == SAMPLEFORMAT_UINT) { if (bitspersample == 8) { sFormat = IIOSF_UNSIGNED_CHAR; return IMIO_SUCCESS; @@ -820,7 +822,7 @@ int ImageIO::loadTIFF (Glib::ustring fname) allocate (width, height); float minValue[3] = {0.f, 0.f, 0.f}, maxValue[3] = {0.f, 0.f, 0.f}; - unsigned char* linebuffer = new unsigned char[TIFFScanlineSize(in)]; + unsigned char* linebuffer = new unsigned char[TIFFScanlineSize(in) * (samplesperpixel == 1 ? 3 : 1)]; for (int row = 0; row < height; row++) { if (TIFFReadScanline(in, linebuffer, row, 0) < 0) { @@ -829,10 +831,21 @@ int ImageIO::loadTIFF (Glib::ustring fname) return IMIO_READERROR; } - if (samplesperpixel > 3) + if (samplesperpixel > 3) { for (int i = 0; i < width; i++) { memcpy (linebuffer + i * 3 * bitspersample / 8, linebuffer + i * samplesperpixel * bitspersample / 8, 3 * bitspersample / 8); } + } + else if (samplesperpixel == 1) { + const size_t bytes = bitspersample / 8; + for (int i = width - 1; i >= 0; --i) { + const unsigned char* const src = linebuffer + i * bytes; + unsigned char* const dest = linebuffer + i * 3 * bytes; + memcpy(dest + 2 * bytes, src, bytes); + memcpy(dest + 1 * bytes, src, bytes); + memcpy(dest + 0 * bytes, src, bytes); + } + } if (sampleFormat & (IIOSF_LOGLUV24 | IIOSF_LOGLUV32 | IIOSF_FLOAT)) { setScanline (row, linebuffer, bitspersample, minValue, maxValue); diff --git a/rtengine/iplab2rgb.cc b/rtengine/iplab2rgb.cc index 6b04bb8f2..218dbf6fe 100644 --- a/rtengine/iplab2rgb.cc +++ b/rtengine/iplab2rgb.cc @@ -169,9 +169,7 @@ Image8* ImProcFunctions::lab2rgb (LabImage* lab, int cx, int cy, int cw, int ch, cmsUInt32Number flags = cmsFLAGS_NOOPTIMIZE | cmsFLAGS_NOCACHE; if (icm.outputBPC) { flags |= cmsFLAGS_BLACKPOINTCOMPENSATION; - printf("lab2rgb / bpc=true\n"); } - else printf("lab2rgb / bpc=false\n"); lcmsMutex->lock (); cmsHPROFILE LabIProf = cmsCreateLab4Profile(nullptr); cmsHTRANSFORM hTransform = cmsCreateTransform (LabIProf, TYPE_Lab_DBL, oprofG, TYPE_RGB_8, icm.outputIntent, flags); // NOCACHE is important for thread safety @@ -290,19 +288,15 @@ Image16* ImProcFunctions::lab2rgb16 (LabImage* lab, int cx, int cy, int cw, int iccStore->getGammaArray(icm, *ga); oprof = iccStore->createGammaProfile(icm, *ga); lcmsMutex->unlock (); - printf("iccStore->createGammaProfile(icm, *ga);\n"); } else { oprof = iccStore->getProfile (icm.output); -// printf("iccStore->getProfile (%s);\n", icm.output.c_str()); } if (oprof) { cmsUInt32Number flags = cmsFLAGS_NOOPTIMIZE | cmsFLAGS_NOCACHE; if (icm.outputBPC) { flags |= cmsFLAGS_BLACKPOINTCOMPENSATION; -// printf("lab2rgb16 / icm.outputBPC=true / outputIntent=%d\n", icm.outputIntent); } -// else printf("lab2rgb16 / icm.outputBPC=false / outputIntent=%d\n", icm.outputIntent); lcmsMutex->lock (); cmsHPROFILE iprof = cmsCreateLab4Profile(nullptr); cmsHTRANSFORM hTransform = cmsCreateTransform (iprof, TYPE_Lab_FLT, oprof, TYPE_RGB_16, icm.outputIntent, flags); diff --git a/rtgui/guiutils.h b/rtgui/guiutils.h index 87213dc04..722b706eb 100644 --- a/rtgui/guiutils.h +++ b/rtgui/guiutils.h @@ -526,7 +526,7 @@ public: // you have to check if the surface is created thanks to surfaceCreated before starting to draw on it bool surfaceCreated() { - return surface; + return static_cast(surface); } Cairo::RefPtr getSurface() {