18.7 · Thumbnails and orientation, GIF timing, bitmap layout, and colour spaces
Image bugs are usually metadata and arithmetic bugs: a rotation tag nobody applied, a delay nobody clamped, a row that is padded, a colour converted without room for out-of-range values.
Mental model. An image is pixels plus a description of how to read them: orientation, timing and colour space. Lose the description and the pixels are still there but wrong.
ImageIO
Thumbnail options and the orientation tag, and animated-image timing.
- Which ImageIO thumbnail options matter, and why does a thumbnail come out sideways or at the wrong size?
CGImageSourceCreateThumbnailAtIndex decodes straight to a reduced size without ever building the full bitmap (the point of Q327’s downsampling pipeline). The… - How are animated image frames and delays stored, and what happens to a zero or tiny frame delay?
An animated GIF (or APNG, or HEICS) is one CGImageSource with several indexes: CGImageSourceGetCount gives the frame count, each frame is decoded with…
Core Graphics
Bitmap memory layout, premultiplied alpha and colour-space conversion.
- How much memory does a bitmap use, why is bytesPerRow not width × 4, and what is premultiplied alpha?
A CGContext bitmap costs bytesPerRow × height. Pass bytesPerRow: 0 and Core Graphics chooses it, rounding each row up for alignment: in the check a… - What happens when you convert between sRGB, Display P3 and linear spaces, and why can a component be above 1 or below 0?
A colour is numbers plus a colour space. Display P3 has a wider gamut than sRGB, so pure P3 red is more saturated than anything sRGB can name. Converting it to…
More in Media & graphics
- 18.1 · AVPlayer, time, and editing with compositions
- 18.2 · The audio session, interruptions, routes and AVAudioEngine
- 18.3 · AVCaptureSession, and zero-copy pixel buffers
- 18.4 · HLS, buffering, Now Playing, remote commands, Picture in Picture and AirPlay
- 18.5 · ImageIO formats, Core Image, Metal, and SceneKit versus RealityKit
- 18.6 · VideoToolbox, tvOS focus and media, and building a playback platform
- 18.8 · Extents, working colour space, and a compute pass from start to finish
- 18.9 · Reading an asset, grabbing frames, reading samples, frame-exact time, and pixel buffers