Hello,
I already successful to copy a surface. But, i want to ask about this logic:
// ===========================================
// function
void put_pixel32( SDL_Surface *surface, int x, int y, Uint32 pixel )
{
//Convert the pixels to 32 bit
Uint32 *pixels = (Uint32 *)surface->pixels;
//Set the pixel
pixels[ ( y * surface->w ) + x ] = pixel;
}
Uint32 get_pixel32( SDL_Surface *surface, int x, int y )
{
//Convert the pixels to 32 bit
Uint32 *pixels = (Uint32 *)surface->pixels;
//Get the requested pixel
return pixels[ ( y * surface->w ) + x ];
}
// ====================================
// i get this function’s code from LazyFoo.net
…
// in main function
SDL_Surface *newSurface = NULL;
baru = SDL_CreateRGBSurface(SDL_SRCALPHA|SDL_SRCCOLORKEY|SDL_HWSURFACE,
oldSurface->w , ButtonSurface->h
,screen->format->BitsPerPixel,temp_->Rmask,temp_->Gmask,temp_->Bmask,temp_->Amask);
if ( SDL_MUSTLOCK(newSurface))
{
SDL_LockSurface( newSurface);
}
for(int x=0; x< newSurface->w ; x++)
{
for(int y=0; y< (newSurface->h/2); y++)
{
//for(int y=0; y< newSurface->h; y++){ //<---- will
error
put_pixel32(newSurface,x,y,get_pixel32(oldSurface,x,y));
}
}
if ( SDL_MUSTLOCK(newSurface))
{
SDL_UnlockSurface( newSurface);
}
…
// ========================================
I still don’t understand , why condition for h must divide by 2 in 'y’
looping.–
View this message in context: http://sdl.5483.n7.nabble.com/Get-and-Put-Pixel-32-tp36541.html
Sent from the SDL mailing list archive at Nabble.com.