Advertisement
Guest User

Untitled

a guest
Jan 14th, 2016
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 5.55 KB | None | 0 0
  1. diff -urpN libgdiplus-3.12.orig/src/gifcodec.c libgdiplus-3.12/src/gifcodec.c
  2. --- libgdiplus-3.12.orig/src/gifcodec.c 2016-01-14 00:55:23.067332449 -0800
  3. +++ libgdiplus-3.12/src/gifcodec.c  2016-01-14 01:03:38.271799157 -0800
  4. @@ -326,11 +326,6 @@ QuantizeBuffer(unsigned int Width,
  5.      return GIF_OK;
  6.  }
  7.  
  8. -#ifdef EgifOpen
  9. -/* giflib declares this incorrectly as EgifOpen */
  10. -extern GifFileType *EGifOpen(void *userData, OutputFunc writeFunc);
  11. -#endif
  12. -
  13.  /* Data structure used for callback */
  14.  typedef struct
  15.  {
  16. @@ -394,7 +389,7 @@ gdip_gif_inputfunc (GifFileType *gif, Gi
  17.  */
  18.  
  19.  static int
  20. -AddExtensionBlockMono(SavedImage *New, int Len, BYTE ExtData[])
  21. +AddExtensionBlockMono(SavedImage *New, int Function, int Len, BYTE ExtData[])
  22.  {
  23.     ExtensionBlock  *ep;
  24.  
  25. @@ -410,15 +405,15 @@ AddExtensionBlockMono(SavedImage *New, i
  26.  
  27.     ep = &New->ExtensionBlocks[New->ExtensionBlockCount++];
  28.  
  29. +   ep->Function = Function;
  30.     ep->ByteCount=Len;
  31. -   ep->Bytes = (char *)GdipAlloc(ep->ByteCount);
  32. +   ep->Bytes = (GifByteType *)GdipAlloc(ep->ByteCount);
  33.     if (ep->Bytes == NULL) {
  34.         return (GIF_ERROR);
  35.     }
  36.  
  37.     if (ExtData) {
  38.         memcpy(ep->Bytes, ExtData, Len);
  39. -       ep->Function = New->Function;
  40.     }
  41.  
  42.     return (GIF_OK);
  43. @@ -455,6 +450,7 @@ static int
  44.  DGifSlurpMono(GifFileType * GifFile, SavedImage *TrailingExtensions)
  45.  {
  46.     int     ImageSize;
  47. +   int     Function;
  48.     GifRecordType   RecordType;
  49.     SavedImage  *sp;
  50.     GifByteType *ExtData;
  51. @@ -521,20 +517,19 @@ DGifSlurpMono(GifFileType * GifFile, Sav
  52.             }
  53.  
  54.             case EXTENSION_RECORD_TYPE: {
  55. -               if (DGifGetExtension(GifFile, &temp_save.Function, &ExtData) == GIF_ERROR) {
  56. +               if (DGifGetExtension(GifFile, &Function, &ExtData) == GIF_ERROR) {
  57.                     return (GIF_ERROR);
  58.                 }
  59.  
  60.                 while (ExtData != NULL) {
  61.                     /* Create an extension block with our data */
  62. -                   if (AddExtensionBlockMono(&temp_save, ExtData[0], &ExtData[1]) == GIF_ERROR) {
  63. +                   if (AddExtensionBlockMono(&temp_save, Function, ExtData[0], &ExtData[1]) == GIF_ERROR) {
  64.                         return (GIF_ERROR);
  65.                     }
  66.  
  67.                     if (DGifGetExtensionNext(GifFile, &ExtData) == GIF_ERROR) {
  68.                         return (GIF_ERROR);
  69.                     }
  70. -                   temp_save.Function = 0;
  71.                 }
  72.                 break;
  73.             }
  74. @@ -593,9 +588,9 @@ gdip_load_gif_image (void *stream, GpIma
  75.     loop_counter = FALSE;
  76.  
  77.     if (from_file) {
  78. -       gif = DGifOpen(stream, &gdip_gif_fileinputfunc);
  79. +       gif = DGifOpen(stream, &gdip_gif_fileinputfunc, NULL);
  80.     } else {
  81. -       gif = DGifOpen (stream, &gdip_gif_inputfunc);
  82. +       gif = DGifOpen (stream, &gdip_gif_inputfunc, NULL);
  83.     }
  84.    
  85.     if (gif == NULL) {
  86. @@ -870,7 +865,11 @@ gdip_load_gif_image (void *stream, GpIma
  87.     }
  88.  
  89.     FreeExtensionMono(&global_extensions);
  90. +#if (GIFLIB_MAJOR > 5) || ((GIFLIB_MAJOR == 5) && (GIFLIB_MINOR >= 1))
  91. +   DGifCloseFile (gif, NULL);
  92. +#else
  93.     DGifCloseFile (gif);
  94. +#endif
  95.  
  96.     *image = result;
  97.     return Ok;
  98. @@ -886,7 +885,11 @@ error:
  99.  
  100.     if (gif != NULL) {
  101.         FreeExtensionMono (&global_extensions);
  102. +#if (GIFLIB_MAJOR > 5) || ((GIFLIB_MAJOR == 5) && (GIFLIB_MINOR >= 1))
  103. +       DGifCloseFile (gif, NULL);
  104. +#else
  105.         DGifCloseFile (gif);
  106. +#endif
  107.     }
  108.  
  109.     *image = NULL;
  110. @@ -950,9 +953,9 @@ gdip_save_gif_image (void *stream, GpIma
  111.     }
  112.  
  113.     if (from_file) {
  114. -       fp = EGifOpenFileName (stream, 0);
  115. +       fp = EGifOpenFileName (stream, 0, NULL);
  116.     } else {
  117. -       fp = EGifOpen (stream, gdip_gif_outputfunc);
  118. +       fp = EGifOpen (stream, gdip_gif_outputfunc, NULL);
  119.     }
  120.        
  121.     if (!fp) {
  122. @@ -991,7 +994,7 @@ gdip_save_gif_image (void *stream, GpIma
  123.                     goto error;
  124.                 }
  125.  
  126. -               cmap = MakeMapObject(cmap_size, 0);
  127. +               cmap = GifMakeMapObject(cmap_size, 0);
  128.  
  129.                 pixbuf = GdipAlloc(pixbuf_size);
  130.                 if (pixbuf == NULL) {
  131. @@ -1082,7 +1085,7 @@ gdip_save_gif_image (void *stream, GpIma
  132.                 pixbuf = pixbuf_org;
  133.             } else {
  134.                 cmap_size = 256;
  135. -               cmap  = MakeMapObject (cmap_size, 0);
  136. +               cmap  = GifMakeMapObject (cmap_size, 0);
  137.  
  138.                 red = GdipAlloc(pixbuf_size);
  139.                 green = GdipAlloc(pixbuf_size);
  140. @@ -1113,13 +1116,13 @@ gdip_save_gif_image (void *stream, GpIma
  141.                         v += 4;
  142.                     }
  143.                 }
  144. -               if (QuantizeBuffer(bitmap_data->width, bitmap_data->height, &cmap_size,
  145. +               if (GifQuantizeBuffer(bitmap_data->width, bitmap_data->height, &cmap_size,
  146.                         red,  green, blue, pixbuf, cmap->Colors) == GIF_ERROR) {
  147.                     goto error;
  148.                 }
  149.             }
  150.  
  151. -           cmap->BitsPerPixel = BitSize (cmap_size);
  152. +           cmap->BitsPerPixel = GifBitSize (cmap_size);
  153.             cmap->ColorCount = 1 << cmap->BitsPerPixel;
  154.  
  155.             if ((frame == 0) && (k == 0)) {
  156. @@ -1137,8 +1140,10 @@ gdip_save_gif_image (void *stream, GpIma
  157.                         Buffer[0] = 1;
  158.                         Buffer[1] = ptr[0];
  159.                         Buffer[2] = ptr[1];
  160. -                       EGifPutExtensionFirst(fp, APPLICATION_EXT_FUNC_CODE, 11, "NETSCAPE2.0");
  161. -                       EGifPutExtensionLast(fp, APPLICATION_EXT_FUNC_CODE, 3, Buffer);
  162. +                       EGifPutExtensionLeader(fp, APPLICATION_EXT_FUNC_CODE);
  163. +                       EGifPutExtensionBlock(fp, 11, "NETSCAPE2.0");
  164. +                       EGifPutExtensionBlock(fp, 3, Buffer);
  165. +                       EGifPutExtensionTrailer(fp);
  166.                     }
  167.                 }
  168.  
  169. @@ -1190,7 +1195,7 @@ gdip_save_gif_image (void *stream, GpIma
  170.                 pixbuf += bitmap_data->width;
  171.             }
  172.  
  173. -           FreeMapObject (cmap);
  174. +           GifFreeMapObject (cmap);
  175.             if (red != NULL) {
  176.                 GdipFree (red);
  177.             }
  178. @@ -1212,13 +1217,17 @@ gdip_save_gif_image (void *stream, GpIma
  179.         }
  180.     }
  181.  
  182. +#if (GIFLIB_MAJOR > 5) || ((GIFLIB_MAJOR == 5) && (GIFLIB_MINOR >= 1))
  183. +   EGifCloseFile (fp, NULL);
  184. +#else
  185.     EGifCloseFile (fp);
  186. -  
  187. +#endif
  188. +
  189.     return Ok;
  190.  
  191.  error:
  192.     if (cmap != NULL) {
  193. -       FreeMapObject (cmap);
  194. +       GifFreeMapObject (cmap);
  195.     }
  196.  
  197.     if (red != NULL) {
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement