We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 4359

Summary: SDL_CalculatePitch() returns zero for 1 and 4 bits per pixel formats
Product: SDL Reporter: DafabHoid <sdlbugs>
Component: videoAssignee: Sam Lantinga <slouken>
Status: RESOLVED DUPLICATE QA Contact: Sam Lantinga <slouken>
Severity: minor    
Priority: P2 CC: sylvain.becker
Version: 2.0.9   
Hardware: x86_64   
OS: Linux   

Description DafabHoid 2018-11-05 18:14:15 UTC
Calling SDL_CalculatePitch() with one of the pixel formats INDEX1MSB, INDEX1LSB, INDEX4MSB, INDEX4LSB returns zero.
This makes it impossible to create a surface with one of those formats, because SDL_CreateRGBSurfaceWithFormat returns a surface with a pitch of 0 and a pixels array malloc'ed with size 0. For obvious reasons such a surface can't be blitted nor converted and is therefore not usable.

The reason is that SDL_BYTESPERPIXEL() returns 0 for those formats, which is probably a problem in some other areas as well. I do not know if SDL plans to still support those formats, as they do not seem to be very popular, but in its current state they are just unusable.
Comment 1 Sylvain 2019-09-11 14:13:22 UTC
This is duplicate of bug 4785

*** This bug has been marked as a duplicate of bug 4785 ***