<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/a-programmer-s-view-on-digital-images-the-essentials-50qz5ulcd" -->

---
title: A programmer's view on digital images: the essentials
description: A foundational guide to how uncompressed raster images are stored in memory. Covers pixel representation (R, G, B, A channels), bits per pixel vs. bits per...
canonical: https://daily.dev/posts/a-programmer-s-view-on-digital-images-the-essentials-50qz5ulcd
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: A programmer's view on digital images: the essentials | daily.dev
og:description: A foundational guide to how uncompressed raster images are stored in memory. Covers pixel representation (R, G, B, A channels), bits per pixel vs. bits per...
og:url: https://daily.dev/posts/a-programmer-s-view-on-digital-images-the-essentials-50qz5ulcd
og:image: https://api.daily.dev/og/posts/50Qz5uLCD.png
og:image:alt: A programmer's view on digital images: the essentials
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# A programmer's view on digital images: the essentials

**[Collabora Blog](https://daily.dev/sources/collabora)** · 8 min read · 0 upvotes · 0 comments

## Summary

A foundational guide to how uncompressed raster images are stored in memory. Covers pixel representation (R, G, B, A channels), bits per pixel vs. bits per channel, pixel formats and endianness, image stride vs. pitch, and the canonical formula for computing a pixel's memory address. Also touches on row padding, multi-planar formats (YUV), and GPU tiled formats as supplementary topics.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://www.collabora.com/news-and-blog/blog/2016/02/16/a-programmers-view-on-digital-images-the-essentials>

## Questions this post answers

### What is the formula to compute the memory address of a pixel at coordinates x,y in an image buffer?

The canonical formula is: pixel_address = data_begin + y * stride_bytes + x * bytes_per_pixel. In C with 32-bit pixels, cast data_begin to uint32_t*, then add y * stride_bytes / sizeof(uint32_t) to reach the correct row, then add x to reach the correct column. The stride_bytes value accounts for any row padding beyond the image width.

_Graphics developers computing pixel addresses track low-level image layout details like these on daily.dev._

### What is the difference between stride and pitch in image buffers?

Stride and pitch refer to the same concept: the number of bytes (or sometimes pixels) from the start of one image row to the start of the next, including any padding. The two terms are used interchangeably across codebases, and the units (bytes vs. pixels) vary by convention. Always verify the units used in the specific API or codebase rather than assuming.

_Developers working across graphics APIs where stride conventions differ find it useful to follow discussions on daily.dev._

### Why do 24-bit RGB images typically use 32 bits per pixel in memory?

True 24-bit-per-pixel formats are rarely used in memory because aligning rows to 32-bit boundaries makes image processing simpler and more efficient — hardware and vectorized instructions often require or benefit from this alignment. The extra 8 bits per pixel are left unused and are typically marked with 'X' in pixel format names. The memory trade-off is almost always worth the performance gain.

_Developers optimizing image pipelines or working with pixel format constraints find relevant discussions on daily.dev._

## Similar posts on daily.dev

- [How JPEG works: Interactively explore JPEG's lossy compression methods](https://daily.dev/posts/how-jpeg-works-interactively-explore-jpeg-s-lossy-compression-methods-thgyhxnvu) · Hacker News · 0 upvotes · 0 comments

---

Tags: [#image-processing](https://daily.dev/tags/image-processing)

[View this post on daily.dev](https://daily.dev/posts/a-programmer-s-view-on-digital-images-the-essentials-50qz5ulcd)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"A programmer's view on digital images: the essentials","url":"https://daily.dev/posts/a-programmer-s-view-on-digital-images-the-essentials-50qz5ulcd","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/a-programmer-s-view-on-digital-images-the-essentials-50qz5ulcd"},"datePublished":"2026-08-11T08:54:05.831Z","dateModified":"2026-08-11T09:26:07.573Z","description":"A foundational guide to how uncompressed raster images are stored in memory. Covers pixel representation (R, G, B, A channels), bits per pixel vs. bits per...","image":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/d0a1cc69af62bdc84a5bfb48d9823edc?_a=AQAEuop","thumbnailUrl":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/d0a1cc69af62bdc84a5bfb48d9823edc?_a=AQAEuop","isAccessibleForFree":true,"articleSection":"Collabora Blog","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"Collabora Blog","logo":"https://media.daily.dev/image/upload/s--ZGZ0FjqS--/f_auto,q_auto/v1786438306/logos/collabora?_a=BAMAMicg0","url":"https://daily.dev/sources/collabora"},"commentCount":0,"discussionUrl":"https://daily.dev/posts/a-programmer-s-view-on-digital-images-the-essentials-50qz5ulcd","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":0},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"keywords":"image-processing","timeRequired":"PT8M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"Collabora Blog","item":"https://daily.dev/sources/collabora"},{"@type":"ListItem","position":3,"name":"A programmer's view on digital images: the essentials"}]}
{"@context":"https://schema.org","@type":"FAQPage","@id":"https://daily.dev/posts/a-programmer-s-view-on-digital-images-the-essentials-50qz5ulcd#faq","mainEntity":[{"@type":"Question","name":"What is the formula to compute the memory address of a pixel at coordinates x,y in an image buffer?","acceptedAnswer":{"@type":"Answer","text":"The canonical formula is: pixel_address = data_begin + y * stride_bytes + x * bytes_per_pixel. In C with 32-bit pixels, cast data_begin to uint32_t*, then add y * stride_bytes / sizeof(uint32_t) to reach the correct row, then add x to reach the correct column. The stride_bytes value accounts for any row padding beyond the image width. Graphics developers computing pixel addresses track low-level image layout details like these on daily.dev."}},{"@type":"Question","name":"What is the difference between stride and pitch in image buffers?","acceptedAnswer":{"@type":"Answer","text":"Stride and pitch refer to the same concept: the number of bytes (or sometimes pixels) from the start of one image row to the start of the next, including any padding. The two terms are used interchangeably across codebases, and the units (bytes vs. pixels) vary by convention. Always verify the units used in the specific API or codebase rather than assuming. Developers working across graphics APIs where stride conventions differ find it useful to follow discussions on daily.dev."}},{"@type":"Question","name":"Why do 24-bit RGB images typically use 32 bits per pixel in memory?","acceptedAnswer":{"@type":"Answer","text":"True 24-bit-per-pixel formats are rarely used in memory because aligning rows to 32-bit boundaries makes image processing simpler and more efficient — hardware and vectorized instructions often require or benefit from this alignment. The extra 8 bits per pixel are left unused and are typically marked with 'X' in pixel format names. The memory trade-off is almost always worth the performance gain. Developers optimizing image pipelines or working with pixel format constraints find relevant discussions on daily.dev."}}]}
```

