fix Surface_to_bytefield()
Each line of the SDL surface use "pitch" bytes. see https://pulkomandy.tk/projects/GrafX2/ticket/171
This commit is contained in:
		
							parent
							
								
									bb5a9e1fea
								
							
						
					
					
						commit
						7e5daa65a8
					
				@ -373,17 +373,11 @@ byte * Surface_to_bytefield(SDL_Surface *source, byte * dest)
 | 
				
			|||||||
  byte *src;
 | 
					  byte *src;
 | 
				
			||||||
  byte *dest_ptr;
 | 
					  byte *dest_ptr;
 | 
				
			||||||
  int y;
 | 
					  int y;
 | 
				
			||||||
  int remainder;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
  // Support seulement des images 256 couleurs
 | 
					  // Support seulement des images 256 couleurs
 | 
				
			||||||
  if (source->format->BytesPerPixel != 1)
 | 
					  if (source->format->BytesPerPixel != 1)
 | 
				
			||||||
    return NULL;
 | 
					    return NULL;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  if (source->w & 3)
 | 
					 | 
				
			||||||
    remainder=4-(source->w&3);
 | 
					 | 
				
			||||||
  else
 | 
					 | 
				
			||||||
    remainder=0;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  if (dest==NULL)
 | 
					  if (dest==NULL)
 | 
				
			||||||
    dest=(byte *)malloc(source->w*source->h);
 | 
					    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);
 | 
					    memcpy(dest_ptr, src,source->w);
 | 
				
			||||||
    dest_ptr += source->w;
 | 
					    dest_ptr += source->w;
 | 
				
			||||||
    src += source->w + remainder;
 | 
					    src += source->pitch;
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
  return dest;
 | 
					  return dest;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user