image::pixel::Specification _pixelSpecificationFromColorType()

in cpp/spectrum/plugins/png/LibPngDecompressor.cpp [43:67]


image::pixel::Specification _pixelSpecificationFromColorType(
    const png_byte colorType,
    const png_byte bitDepth,
    const int channels) {
  if (bitDepth == 8 && colorType == PNG_COLOR_TYPE_GRAY && channels == 1) {
    return image::pixel::specifications::Gray;
  } else if (
      bitDepth == 8 && colorType == PNG_COLOR_TYPE_GRAY_ALPHA &&
      channels == 2) {
    return image::pixel::specifications::GrayA;
  } else if (
      bitDepth == 8 && colorType == PNG_COLOR_TYPE_RGB && channels == 3) {
    return image::pixel::specifications::RGB;
  } else if (
      bitDepth == 8 && colorType == PNG_COLOR_TYPE_RGBA && channels == 4) {
    return image::pixel::specifications::ARGB;
  } else {
    SPECTRUM_ERROR_FORMAT(
        codecs::error::DecompressorUnexpectedPixelSpecification,
        "colorType: %u, bitDepth: %u, channels: %u",
        colorType,
        bitDepth,
        channels);
  }
}