bitDepth property

int bitDepth
final

Bits per channel, which is what PNG's IHDR and JPEG's frame header both carry — 8 in the 24-bit RGB PNG Play asks for by name, and 16 in the 48-bit one a macOS capture can produce.

Per channel rather than per pixel deliberately, because the stores state it the other way round — "24-bit PNG", "32-bit PNG" — and converting at the call site would mean knowing the channel count, which the header of a palettised PNG does not give directly. The messages do the arithmetic in prose instead.

Read for a JPEG too, and not checked for one — see imageEncodingProblem. Reported rather than suppressed because the field is what the file says, and a parser that returned 8 for a 12-bit JPEG would be lying to whatever asks next.

Implementation

final int bitDepth;