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 - SDL_CreateRGBSurface creates 1-bit surfaces with zero pitch
Summary: SDL_CreateRGBSurface creates 1-bit surfaces with zero pitch
Status: RESOLVED FIXED
Alias: None
Product: SDL
Classification: Unclassified
Component: video (show other bugs)
Version: 2.0.10
Hardware: x86_64 Linux
: P2 normal
Assignee: Sam Lantinga
QA Contact: Sam Lantinga
URL:
Keywords:
: 4359 (view as bug list)
Depends on:
Blocks:
 
Reported: 2019-09-03 17:28 UTC by Shibe
Modified: 2019-10-16 15:47 UTC (History)
3 users (show)

See Also:


Attachments
reproduction (704 bytes, text/plain)
2019-09-03 17:28 UTC, Shibe
Details

Note You need to log in before you can comment on or make changes to this bug.
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