Merge branch 'master' into gtk3

This commit is contained in:
Morgan Hardwood 2016-12-05 12:01:45 +01:00
commit 5ecd50b1cd
3 changed files with 19 additions and 12 deletions

View File

@ -556,11 +556,13 @@ int ImageIO::loadJPEG (Glib::ustring fname)
jpeg_read_header(&cinfo, TRUE); jpeg_read_header(&cinfo, TRUE);
//if JPEG is CMYK, then abort reading //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); jpeg_destroy_decompress(&cinfo);
return IMIO_READERROR; return IMIO_READERROR;
} }
cinfo.out_color_space = JCS_RGB;
deleteLoadedProfileData(); deleteLoadedProfileData();
loadedProfileDataJpg = true; loadedProfileDataJpg = true;
bool hasprofile = read_icc_profile (&cinfo, (JOCTET**)&loadedProfileData, (unsigned int*)&loadedProfileLength); 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); TIFFClose(in);
if (photometric == PHOTOMETRIC_RGB) { if (photometric == PHOTOMETRIC_RGB || photometric == PHOTOMETRIC_MINISBLACK) {
if ((samplesperpixel == 3 || samplesperpixel == 4) && sampleformat == SAMPLEFORMAT_UINT) { if ((samplesperpixel == 1 || samplesperpixel == 3 || samplesperpixel == 4) && sampleformat == SAMPLEFORMAT_UINT) {
if (bitspersample == 8) { if (bitspersample == 8) {
sFormat = IIOSF_UNSIGNED_CHAR; sFormat = IIOSF_UNSIGNED_CHAR;
return IMIO_SUCCESS; return IMIO_SUCCESS;
@ -820,7 +822,7 @@ int ImageIO::loadTIFF (Glib::ustring fname)
allocate (width, height); allocate (width, height);
float minValue[3] = {0.f, 0.f, 0.f}, maxValue[3] = {0.f, 0.f, 0.f}; 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++) { for (int row = 0; row < height; row++) {
if (TIFFReadScanline(in, linebuffer, row, 0) < 0) { if (TIFFReadScanline(in, linebuffer, row, 0) < 0) {
@ -829,10 +831,21 @@ int ImageIO::loadTIFF (Glib::ustring fname)
return IMIO_READERROR; return IMIO_READERROR;
} }
if (samplesperpixel > 3) if (samplesperpixel > 3) {
for (int i = 0; i < width; i++) { for (int i = 0; i < width; i++) {
memcpy (linebuffer + i * 3 * bitspersample / 8, linebuffer + i * samplesperpixel * bitspersample / 8, 3 * bitspersample / 8); 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)) { if (sampleFormat & (IIOSF_LOGLUV24 | IIOSF_LOGLUV32 | IIOSF_FLOAT)) {
setScanline (row, linebuffer, bitspersample, minValue, maxValue); setScanline (row, linebuffer, bitspersample, minValue, maxValue);

View File

@ -169,9 +169,7 @@ Image8* ImProcFunctions::lab2rgb (LabImage* lab, int cx, int cy, int cw, int ch,
cmsUInt32Number flags = cmsFLAGS_NOOPTIMIZE | cmsFLAGS_NOCACHE; cmsUInt32Number flags = cmsFLAGS_NOOPTIMIZE | cmsFLAGS_NOCACHE;
if (icm.outputBPC) { if (icm.outputBPC) {
flags |= cmsFLAGS_BLACKPOINTCOMPENSATION; flags |= cmsFLAGS_BLACKPOINTCOMPENSATION;
printf("lab2rgb / bpc=true\n");
} }
else printf("lab2rgb / bpc=false\n");
lcmsMutex->lock (); lcmsMutex->lock ();
cmsHPROFILE LabIProf = cmsCreateLab4Profile(nullptr); cmsHPROFILE LabIProf = cmsCreateLab4Profile(nullptr);
cmsHTRANSFORM hTransform = cmsCreateTransform (LabIProf, TYPE_Lab_DBL, oprofG, TYPE_RGB_8, icm.outputIntent, flags); // NOCACHE is important for thread safety 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); iccStore->getGammaArray(icm, *ga);
oprof = iccStore->createGammaProfile(icm, *ga); oprof = iccStore->createGammaProfile(icm, *ga);
lcmsMutex->unlock (); lcmsMutex->unlock ();
printf("iccStore->createGammaProfile(icm, *ga);\n");
} else { } else {
oprof = iccStore->getProfile (icm.output); oprof = iccStore->getProfile (icm.output);
// printf("iccStore->getProfile (%s);\n", icm.output.c_str());
} }
if (oprof) { if (oprof) {
cmsUInt32Number flags = cmsFLAGS_NOOPTIMIZE | cmsFLAGS_NOCACHE; cmsUInt32Number flags = cmsFLAGS_NOOPTIMIZE | cmsFLAGS_NOCACHE;
if (icm.outputBPC) { if (icm.outputBPC) {
flags |= cmsFLAGS_BLACKPOINTCOMPENSATION; 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 (); lcmsMutex->lock ();
cmsHPROFILE iprof = cmsCreateLab4Profile(nullptr); cmsHPROFILE iprof = cmsCreateLab4Profile(nullptr);
cmsHTRANSFORM hTransform = cmsCreateTransform (iprof, TYPE_Lab_FLT, oprof, TYPE_RGB_16, icm.outputIntent, flags); cmsHTRANSFORM hTransform = cmsCreateTransform (iprof, TYPE_Lab_FLT, oprof, TYPE_RGB_16, icm.outputIntent, flags);

View File

@ -526,7 +526,7 @@ public:
// you have to check if the surface is created thanks to surfaceCreated before starting to draw on it // you have to check if the surface is created thanks to surfaceCreated before starting to draw on it
bool surfaceCreated() bool surfaceCreated()
{ {
return surface; return static_cast<bool>(surface);
} }
Cairo::RefPtr<Cairo::ImageSurface> getSurface() Cairo::RefPtr<Cairo::ImageSurface> getSurface()
{ {