src/video/SDL_surface.c
branchSDL-1.3
changeset 1678 90bf530ced8e
parent 1672 8e754b82cecc
child 1682 7ae8018b2e5d
     1.1 --- a/src/video/SDL_surface.c	Tue Jun 13 04:37:45 2006 +0000
     1.2 +++ b/src/video/SDL_surface.c	Wed Jun 14 06:14:26 2006 +0000
     1.3 @@ -134,6 +134,8 @@
     1.4      int w, h;
     1.5      int bpp;
     1.6      Uint32 Rmask, Gmask, Bmask, Amask;
     1.7 +    void *pixels;
     1.8 +    int pitch;
     1.9  
    1.10      if (SDL_QueryTexture(textureID, &format, NULL, &w, &h) < 0) {
    1.11          return NULL;
    1.12 @@ -145,14 +147,22 @@
    1.13          return NULL;
    1.14      }
    1.15  
    1.16 -    surface = SDL_CreateRGBSurface(0, 0, 0, bpp, Rmask, Gmask, Bmask, Amask);
    1.17 -    if (surface != NULL) {
    1.18 -        surface->flags |= (SDL_HWSURFACE | SDL_PREALLOC);
    1.19 -        surface->w = w;
    1.20 -        surface->h = h;
    1.21 -        surface->lock_data = (void *) textureID;
    1.22 -        SDL_SetClipRect(surface, NULL);
    1.23 +    if (SDL_QueryTexturePixels(textureID, &pixels, &pitch) == 0) {
    1.24 +        surface =
    1.25 +            SDL_CreateRGBSurfaceFrom(pixels, w, h, bpp, pitch, Rmask, Gmask,
    1.26 +                                     Bmask, Amask);
    1.27 +    } else {
    1.28 +        surface =
    1.29 +            SDL_CreateRGBSurface(0, 0, 0, bpp, Rmask, Gmask, Bmask, Amask);
    1.30 +        if (surface) {
    1.31 +            surface->flags |= SDL_HWSURFACE;
    1.32 +            surface->w = w;
    1.33 +            surface->h = h;
    1.34 +            surface->lock_data = (void *) textureID;
    1.35 +            SDL_SetClipRect(surface, NULL);
    1.36 +        }
    1.37      }
    1.38 +
    1.39      return surface;
    1.40  }
    1.41