Skip to content
This repository has been archived by the owner on Apr 8, 2024. It is now read-only.

Commit

Permalink
Throws exception for colored images that don't have 8 bits per color
Browse files Browse the repository at this point in the history
Summary:
@public

Throws an exception for RGB/CMYK images whose colors are represented with something else that 8 bits. This is the case for kCGImagePixelFormatRGB555.

Reviewed By: cuva

Differential Revision: D15625249

fbshipit-source-id: a0ee5199e4d55220d1631e994a52c51cfe3c0a76
  • Loading branch information
diegosanchezr authored and facebook-github-bot committed Jun 5, 2019
1 parent 3eef478 commit 15fb5fd
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions ios/SpectrumKit/SpectrumKit/Image/FSPImagePixelSpecification.mm
Original file line number Diff line number Diff line change
Expand Up @@ -235,10 +235,16 @@ + (instancetype)imagePixelSpecificationColorModelFromImage:(UIImage *)image
return FSPImagePixelSpecificationColorModel.unknown;
case kCGColorSpaceModelMonochrome:
return FSPImagePixelSpecificationColorModel.gray;
case kCGColorSpaceModelRGB:
case kCGColorSpaceModelRGB: {
const auto bitsPerComponent = CGImageGetBitsPerComponent(image.CGImage);
SPECTRUM_ERROR_FORMAT_IF(bitsPerComponent != 8, "unsupported_image_pixel_spec_rgb_bits_per_component", "%d", bitsPerComponent);
return FSPImagePixelSpecificationColorModel.rgb;
case kCGColorSpaceModelCMYK:
}
case kCGColorSpaceModelCMYK: {
const auto bitsPerComponent = CGImageGetBitsPerComponent(image.CGImage);
SPECTRUM_ERROR_FORMAT_IF(bitsPerComponent != 8, "unsupported_image_pixel_spec_cmyk_bits_per_component", "%d", bitsPerComponent);
return FSPImagePixelSpecificationColorModel.yCbCr;
}
case kCGColorSpaceModelLab:
case kCGColorSpaceModelDeviceN:
case kCGColorSpaceModelIndexed:
Expand Down

0 comments on commit 15fb5fd

Please sign in to comment.