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 4785

Summary: SDL_CreateRGBSurface creates 1-bit surfaces with zero pitch
Product: SDL Reporter: Shibe <shibe>
Component: videoAssignee: Sam Lantinga <slouken>
Status: RESOLVED FIXED QA Contact: Sam Lantinga <slouken>
Severity: normal    
Priority: P2 CC: sdlbugs, sezeroz, sylvain.becker
Version: 2.0.10   
Hardware: x86_64   
OS: Linux   
Attachments: reproduction

Description Shibe 2019-09-03 17:28:53 UTC
Created attachment 3947 [details]
reproduction

When called like this

    SDL_CreateRGBSurface(0, width, height, 1, 0, 0, 0, 0);

it returns a surface with pitch=0. SDL_BYTESPERPIXEL is zero as well.
Comment 1 Sylvain 2019-09-04 12:52:53 UTC
Maybe the definition of pixel format in SDL_pixels.h is incorrect:
1LSB, 1MSB, 4LSB, 4MSB should have 1 BytePerPixel

diff -r 6203d73874ab include/SDL_pixels.h
--- a/include/SDL_pixels.h	Tue Sep 03 11:55:20 2019 -0700
+++ b/include/SDL_pixels.h	Wed Sep 04 14:50:49 2019 +0200
@@ -173,16 +173,16 @@
     SDL_PIXELFORMAT_UNKNOWN,
     SDL_PIXELFORMAT_INDEX1LSB =
         SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_INDEX1, SDL_BITMAPORDER_4321, 0,
-                               1, 0),
+                               1, 1),
     SDL_PIXELFORMAT_INDEX1MSB =
         SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_INDEX1, SDL_BITMAPORDER_1234, 0,
-                               1, 0),
+                               1, 1),
     SDL_PIXELFORMAT_INDEX4LSB =
         SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_INDEX4, SDL_BITMAPORDER_4321, 0,
-                               4, 0),
+                               4, 1),
     SDL_PIXELFORMAT_INDEX4MSB =
         SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_INDEX4, SDL_BITMAPORDER_1234, 0,
-                               4, 0),
+                               4, 1),
Comment 2 Sylvain 2019-09-11 14:13:22 UTC
*** Bug 4359 has been marked as a duplicate of this bug. ***
Comment 3 Sam Lantinga 2019-10-16 15:47:30 UTC
Fixed, thanks!
https://hg.libsdl.org/SDL/rev/5f88f7095b8a