Create "canvas" as 24-bit all the time

Previously was having it match the display's ("screen"'s) depth
and masks, but this apparently causes artifacts under SDL2.
Closes https://sourceforge.net/p/tuxpaint/bugs/259/
This commit is contained in:
Bill Kendrick 2022-09-04 01:33:36 -07:00
parent 39264d3545
commit 53c1c5e995
2 changed files with 15 additions and 7 deletions

View file

@ -7,7 +7,7 @@ Various contributors (see below, and AUTHORS.txt)
http://www.tuxpaint.org/
2022.September.2 (0.9.29)
2022.September.4 (0.9.29)
* Improvements to "Stamp" tool:
-----------------------------
* WIP - Stamps may now be rotated.
@ -17,6 +17,12 @@ http://www.tuxpaint.org/
* Bug Fixes:
----------
* Always creating 24-bit canvases, in an attempt to avoid blending
artifacts, e.g., when applying brush strokes using the Paint tool.
(Previously, we were using the display's color depth and masks,
which seemed to work fine under SDL1.2, but does not under SDL2.)
Closes https://sourceforge.net/p/tuxpaint/bugs/259/
* Opening and immediately dismissing Color Mixer could cause
an unexpected color to be chosen.
h/t @kentonyanamin on Twitter for reporting.

View file

@ -28079,13 +28079,15 @@ static void setup(void)
printf("Canvas size is %d x %d\n", canvas_width, canvas_height);
#endif
canvas = SDL_CreateRGBSurface(screen->flags, canvas_width, canvas_height,
screen->format->BitsPerPixel,
screen->format->Rmask, screen->format->Gmask, screen->format->Bmask, 0);
/* Per https://wiki.libsdl.org/SDL_CreateRGBSurface,
* the flags are unused and should be set to 0
* Using zeros for the RGB masks sets a default value, based on the depth.
*/
canvas = SDL_CreateRGBSurface(0, canvas_width, canvas_height,
24, 0, 0, 0, 0);
save_canvas = SDL_CreateRGBSurface(screen->flags, canvas_width, canvas_height,
screen->format->BitsPerPixel,
screen->format->Rmask, screen->format->Gmask, screen->format->Bmask, 0);
save_canvas = SDL_CreateRGBSurface(0, canvas_width, canvas_height,
24, 0, 0, 0, 0);
img_starter = NULL;