isValid method

bool isValid()

Implementation

bool isValid() {
  if (pixelDepth != 8 &&
      pixelDepth != 16 &&
      pixelDepth != 24 &&
      pixelDepth != 32) {
    return false;
  }

  if (hasColorMap) {
    if (colorMapLength > 256 || colorMapType != 1) {
      return false;
    }
    if (colorMapDepth != 16 && colorMapDepth != 24 && colorMapDepth != 32) {
      return false;
    }
  } else if (colorMapType == 1) {
    return false;
  }

  return true;
}