src/video/SDL_surface.c
changeset 5296 48067bfc300c
parent 5288 d4381f3b0d1e
child 5375 16877f74123c
equal deleted inserted replaced
5295:b88d05603e4b 5296:48067bfc300c
   638     dstrect->w = dstrect->h = 0;
   638     dstrect->w = dstrect->h = 0;
   639     return 0;
   639     return 0;
   640 }
   640 }
   641 
   641 
   642 /*
   642 /*
       
   643  * Scale and blit a surface 
       
   644 */
       
   645 int
       
   646 SDL_BlitScaled(SDL_Surface * src, const SDL_Rect * srcrect,
       
   647                SDL_Surface * dst, const SDL_Rect * dstrect)
       
   648 {
       
   649     /* Save off the original dst width, height */
       
   650     int dstW = dstrect->w;
       
   651     int dstH = dstrect->h;
       
   652     SDL_Rect final_dst = *dstrect;
       
   653     SDL_Rect final_src = *srcrect;
       
   654 
       
   655     /* Clip the dst surface to the dstrect */
       
   656     SDL_SetClipRect( dst, &final_dst );
       
   657 
       
   658     /* If the dest was clipped to a zero sized rect then exit */
       
   659     if ( dst->clip_rect.w <= 0 || dst->clip_rect.h <= 0 ) {
       
   660         return -1;
       
   661     }
       
   662 
       
   663     /* Did the dst width change? */
       
   664     if ( dstW != dst->clip_rect.w ) {
       
   665         /* scale the src width appropriately */
       
   666         final_src.w = final_src.w * dst->clip_rect.w / dstW;
       
   667     }
       
   668 
       
   669     /* Did the dst height change? */
       
   670     if ( dstH != dst->clip_rect.h ) {
       
   671         /* scale the src width appropriately */
       
   672         final_src.h = final_src.h * dst->clip_rect.h / dstH;
       
   673     }
       
   674 
       
   675     /* Clip the src surface to the srcrect */
       
   676     SDL_SetClipRect( src, &final_src );
       
   677 
       
   678     src->map->info.flags |= SDL_COPY_NEAREST;
       
   679 
       
   680     if ( src->format->format == dst->format->format && !SDL_ISPIXELFORMAT_INDEXED(src->format->format) ) {
       
   681         return SDL_SoftStretch( src, &final_src, dst, &final_dst );
       
   682     } else {
       
   683         return SDL_LowerBlit( src, &final_src, dst, &final_dst );
       
   684     }
       
   685 }
       
   686 
       
   687 /*
   643  * Lock a surface to directly access the pixels
   688  * Lock a surface to directly access the pixels
   644  */
   689  */
   645 int
   690 int
   646 SDL_LockSurface(SDL_Surface * surface)
   691 SDL_LockSurface(SDL_Surface * surface)
   647 {
   692 {