Various compilation scripts & patches for Linux programs.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

157 lines
4.4 KiB

7 years ago
  1. Port qgifer to giflib 5 API.
  2. See also: https://bugs.gentoo.org/show_bug.cgi?id=536634
  3. --- a/src/gifcreator.cpp
  4. +++ b/src/gifcreator.cpp
  5. @@ -38,7 +38,7 @@
  6. j--;
  7. }
  8. for(int i=0;i<cmaps.size();i++)
  9. - FreeMapObject(cmaps[i]);
  10. + GifFreeMapObject(cmaps[i]);
  11. }
  12. @@ -52,7 +52,7 @@
  13. }
  14. - GifFileType *GifFile = EGifOpenFileName(filename, FALSE);
  15. + GifFileType *GifFile = EGifOpenFileName(filename, 0, NULL);
  16. if (!GifFile){
  17. PrintGifError();
  18. @@ -74,7 +74,7 @@
  19. {
  20. char nsle[12] = "NETSCAPE2.0";
  21. char subblock[3];
  22. - if (EGifPutExtensionFirst(GifFile, APPLICATION_EXT_FUNC_CODE, 11, nsle) == GIF_ERROR) {
  23. + if (EGifPutExtension(GifFile, APPLICATION_EXT_FUNC_CODE, 11, nsle) == GIF_ERROR) {
  24. PrintGifError();
  25. return false;
  26. }
  27. @@ -82,7 +82,7 @@
  28. subblock[2] = loop_count % 256;
  29. subblock[1] = loop_count / 256;
  30. - if (EGifPutExtensionLast(GifFile, APPLICATION_EXT_FUNC_CODE, 3, subblock) == GIF_ERROR) {
  31. + if (EGifPutExtension(GifFile, APPLICATION_EXT_FUNC_CODE, 3, subblock) == GIF_ERROR) {
  32. PrintGifError();
  33. return false;
  34. }
  35. @@ -111,7 +111,7 @@
  36. if (EGifPutImageDesc(
  37. GifFile,
  38. - 0, 0, w, h, FALSE, cmaps.size() > ni ? cmaps.at(ni) : cmaps.at(cmaps.size()-1)
  39. + 0, 0, w, h, 0, cmaps.size() > ni ? cmaps.at(ni) : cmaps.at(cmaps.size()-1)
  40. ) == GIF_ERROR) {
  41. PrintGifError();
  42. endProgress();
  43. @@ -135,7 +135,7 @@
  44. return false;
  45. }
  46. - if (EGifCloseFile(GifFile) == GIF_ERROR) {
  47. + if (EGifCloseFile(GifFile, NULL) == GIF_ERROR) {
  48. PrintGifError();
  49. endProgress();
  50. return false;
  51. --- a/src/gifcreator.h
  52. +++ b/src/gifcreator.h
  53. @@ -31,6 +31,12 @@
  54. typedef vector<GifByteType> Frame;
  55. typedef unsigned char Byte;
  56. +static inline void
  57. +PrintGifError()
  58. +{
  59. + fprintf(stderr, "\nGIF-LIB error: %s.\n", GifErrorString(GIF_ERROR));
  60. +}
  61. +
  62. class GifCreator
  63. {
  64. --- a/src/palettewidget.cpp
  65. +++ b/src/palettewidget.cpp
  66. @@ -34,7 +34,7 @@
  67. PaletteWidget::~PaletteWidget()
  68. {
  69. - FreeMapObject(palette);
  70. + GifFreeMapObject(palette);
  71. }
  72. void PaletteWidget::paintEvent(QPaintEvent*)
  73. @@ -117,7 +117,7 @@
  74. if(palette && mindiff > 1)
  75. {
  76. qDebug() << "deleting old palette, size: " << size << ", colors: " << palette->ColorCount;
  77. - FreeMapObject(palette);
  78. + GifFreeMapObject(palette);
  79. qDebug() << "done";
  80. palette = NULL;
  81. }
  82. @@ -157,7 +157,7 @@
  83. }
  84. ColorMapObject* previous = palette;
  85. - palette = MakeMapObject(size, NULL);
  86. + palette = GifMakeMapObject(size, NULL);
  87. if (!palette)
  88. {
  89. qDebug() << "NULL palette!";
  90. @@ -165,7 +165,7 @@
  91. }
  92. - if (QuantizeBuffer(fimg.width(), fimg.height(), &size,
  93. + if (GifQuantizeBuffer(fimg.width(), fimg.height(), &size,
  94. &(r[0]),&(g[0]),&(b[0]), &(output[0]),
  95. palette->Colors) == GIF_ERROR)
  96. {
  97. @@ -178,11 +178,11 @@
  98. //qDebug() << "difference: " << df;
  99. if(previous && df < mindiff)
  100. {
  101. - FreeMapObject(palette);
  102. + GifFreeMapObject(palette);
  103. palette = previous;
  104. }
  105. else if(df >= mindiff)
  106. - FreeMapObject(previous);
  107. + GifFreeMapObject(previous);
  108. // qDebug() << "palette (" << palette->ColorCount << ") :";
  109. // for(int i=0;i<size;i++)
  110. @@ -230,8 +230,8 @@
  111. {
  112. QStringList rgb = QString(str).split(";", QString::SkipEmptyParts);
  113. if(palette)
  114. - FreeMapObject(palette);
  115. - palette = MakeMapObject(rgb.size(), NULL);
  116. + GifFreeMapObject(palette);
  117. + palette = GifMakeMapObject(rgb.size(), NULL);
  118. if(!palette)
  119. return false;
  120. size = rgb.size();
  121. --- a/src/palettewidget.h
  122. +++ b/src/palettewidget.h
  123. @@ -30,7 +30,7 @@
  124. PaletteWidget(QWidget* parent=0, Qt::WindowFlags f=0);
  125. virtual ~PaletteWidget();
  126. ColorMapObject* map() {return palette;}
  127. - ColorMapObject* mapCopy() {return MakeMapObject(palette->ColorCount, palette->Colors);}
  128. + ColorMapObject* mapCopy() {return GifMakeMapObject(palette->ColorCount, palette->Colors);}
  129. bool fromImage(const QImage& img, int palette_size, float mindiff = 2);
  130. void setColumnCount(int cc){cols = cc;}
  131. bool toFile(const QString& path);
  132. @@ -38,7 +38,7 @@
  133. QString toString();
  134. bool fromString(const QString& str);
  135. int getSize() const {return size;}
  136. - void clear() {if(palette) FreeMapObject(palette); palette = NULL; update();}
  137. + void clear() {if(palette) GifFreeMapObject(palette); palette = NULL; update();}
  138. private:
  139. int size;
  140. int cols;