| Summary: | A note of variable "pitch" of SDL_Surface estructure | ||
|---|---|---|---|
| Product: | SDL | Reporter: | Jordi Espada Brau <jordi.espada> |
| Component: | video | Assignee: | Ryan C. Gordon <icculus> |
| Status: | RESOLVED WONTFIX | QA Contact: | Sam Lantinga <slouken> |
| Severity: | trivial | ||
| Priority: | P2 | ||
| Version: | 1.2.9 | ||
| Hardware: | x86 | ||
| OS: | Windows (XP) | ||
|
Description
Jordi Espada Brau
2007-02-08 10:28:11 UTC
If you have a look at SDL_CalculatePitch() in SDL_pixels.c, you'll find that comment: /* Surface should be 4-byte aligned for speed */ 'pitch' is the number of bytes per line allocated for the surface. It is not the width*bytesPerPixel. Also if you check most video surfaces returned by SDL_SetVideoMode, you'll see that pitch value is even higher than width (sometimes 512 for a 400 pixel width, or 1024 for 800 pixel width). This is because video hardware don't always have finer granularity. For software surfaces, it's easier for the cpu to deal with at least 4 bytes (32 bits) minimum granularity. There is a good reason that 'pitch' value is present in SDL_Surface structure, in that it's most likely will be different than 'width'*'bytesPerPixel', or it would be useless to have it in the first place. |