Commit 7e5daa65 authored by Thomas Bernard's avatar Thomas Bernard 💬 Committed by Adrien Destugues
Browse files

fix Surface_to_bytefield()

Each line of the SDL surface use "pitch" bytes.
see https://pulkomandy.tk/projects/GrafX2/ticket/171
parent bb5a9e1f
Pipeline #660754349 passed with stages
in 18 minutes and 9 seconds
......@@ -373,17 +373,11 @@ byte * Surface_to_bytefield(SDL_Surface *source, byte * dest)
byte *src;
byte *dest_ptr;
int y;
int remainder;
// Support seulement des images 256 couleurs
if (source->format->BytesPerPixel != 1)
return NULL;
if (source->w & 3)
remainder=4-(source->w&3);
else
remainder=0;
if (dest==NULL)
dest=(byte *)malloc(source->w*source->h);
......@@ -393,7 +387,7 @@ byte * Surface_to_bytefield(SDL_Surface *source, byte * dest)
{
memcpy(dest_ptr, src,source->w);
dest_ptr += source->w;
src += source->w + remainder;
src += source->pitch;
}
return dest;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment