IMG_tif.c
changeset 493 b6f8fbe5a386
parent 492 915de300a9a9
child 496 6332f9425dcc
     1.1 --- a/IMG_tif.c	Tue Nov 01 10:36:59 2016 -0700
     1.2 +++ b/IMG_tif.c	Tue Nov 01 10:40:08 2016 -0700
     1.3 @@ -37,7 +37,7 @@
     1.4      TIFF* (*TIFFClientOpen)(const char*, const char*, thandle_t, TIFFReadWriteProc, TIFFReadWriteProc, TIFFSeekProc, TIFFCloseProc, TIFFSizeProc, TIFFMapFileProc, TIFFUnmapFileProc);
     1.5      void (*TIFFClose)(TIFF*);
     1.6      int (*TIFFGetField)(TIFF*, ttag_t, ...);
     1.7 -    int (*TIFFReadRGBAImage)(TIFF*, uint32, uint32, uint32*, int);
     1.8 +    int (*TIFFReadRGBAImageOriented)(TIFF*, uint32, uint32, uint32*, int, int);
     1.9      TIFFErrorHandler (*TIFFSetErrorHandler)(TIFFErrorHandler);
    1.10  } lib;
    1.11  
    1.12 @@ -70,10 +70,10 @@
    1.13              SDL_UnloadObject(lib.handle);
    1.14              return -1;
    1.15          }
    1.16 -        lib.TIFFReadRGBAImage =
    1.17 -            (int (*)(TIFF*, uint32, uint32, uint32*, int))
    1.18 -            SDL_LoadFunction(lib.handle, "TIFFReadRGBAImage");
    1.19 -        if ( lib.TIFFReadRGBAImage == NULL ) {
    1.20 +        lib.TIFFReadRGBAImageOriented =
    1.21 +            (int (*)(TIFF*, uint32, uint32, uint32*, int, int))
    1.22 +            SDL_LoadFunction(lib.handle, "TIFFReadRGBAImageOriented");
    1.23 +        if ( lib.TIFFReadRGBAImageOriented == NULL ) {
    1.24              SDL_UnloadObject(lib.handle);
    1.25              return -1;
    1.26          }
    1.27 @@ -106,7 +106,7 @@
    1.28          lib.TIFFClientOpen = TIFFClientOpen;
    1.29          lib.TIFFClose = TIFFClose;
    1.30          lib.TIFFGetField = TIFFGetField;
    1.31 -        lib.TIFFReadRGBAImage = TIFFReadRGBAImage;
    1.32 +        lib.TIFFReadRGBAImageOriented = TIFFReadRGBAImageOriented;
    1.33          lib.TIFFSetErrorHandler = TIFFSetErrorHandler;
    1.34      }
    1.35      ++lib.loaded;
    1.36 @@ -240,23 +240,9 @@
    1.37      if(!surface)
    1.38          goto error;
    1.39  
    1.40 -    if(!lib.TIFFReadRGBAImage(tiff, img_width, img_height, (uint32 *)surface->pixels, 0))
    1.41 +    if(!lib.TIFFReadRGBAImageOriented(tiff, img_width, img_height, (uint32 *)surface->pixels, ORIENTATION_TOPLEFT, 0))
    1.42          goto error;
    1.43  
    1.44 -    /* libtiff loads the image upside-down, flip it back */
    1.45 -    half = img_height / 2;
    1.46 -    for(y = 0; y < half; y++)
    1.47 -    {
    1.48 -            Uint32 *top = (Uint32 *)surface->pixels + y * surface->pitch/4;
    1.49 -            Uint32 *bot = (Uint32 *)surface->pixels
    1.50 -                      + (img_height - y - 1) * surface->pitch/4;
    1.51 -        for(x = 0; x < img_width; x++)
    1.52 -        {
    1.53 -                Uint32 tmp = top[x];
    1.54 -            top[x] = bot[x];
    1.55 -            bot[x] = tmp;
    1.56 -        }
    1.57 -    }
    1.58      lib.TIFFClose(tiff);
    1.59  
    1.60      return surface;