Skip to content

Commit

Permalink
fix issue #7, unable to open gray scale image with color profile
Browse files Browse the repository at this point in the history
  • Loading branch information
robaho committed Dec 19, 2018
1 parent 66d9dd8 commit 2a29add
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion Seashore/source/extra/Bitmap.m
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,13 @@ void convertBitmapColorSync(unsigned char *dbitmap, int dspp, int dspace, unsign

// Execute the conversion
CMNewProfile(&srcProf, iprofile);
CMAppleProfileHeader header;
CMGetProfileHeader(srcProf,&header);
if(header.cm2.dataColorSpace==0){
// did not read profile correctly, use monitor profile
// the error from CMNewProfile is still 0 for some reason...
CMGetDefaultProfileBySpace(cmGrayData, &srcProf);
}
CMGetDefaultProfileBySpace(cmGrayData, &destProf);
NCWNewColorWorld(&cw, srcProf, destProf);
CWMatchBitmap(cw, &srcBitmap, NULL, 0, &destBitmap);
Expand Down Expand Up @@ -442,7 +449,7 @@ void convertBitmapNoColorSync(unsigned char *dbitmap, int dspp, int dspace, unsi

// Remove redundant bits and bytes
if (ibps == 8) {
if (ibipp != ispp * 8 || ibypr != width * ispp) {
if ((ibipp != ispp * 8) || (ibypr != width * ispp)) {
pbitmap = getPtr(ptrs);
bitmap = mallocPtr(&ptrs, width * height * ispp);
for (j = 0; j < height; j++) {
Expand Down

0 comments on commit 2a29add

Please sign in to comment.