View | Details | Raw Unified | Return to bug 239614
Collapse All | Expand All

(-)Makefile (-4 / +4 lines)
Lines 1-48 Link Here
1
# Created by: Tom McLaughlin <tmclaugh@sdf.lonestar.org>
1
# Created by: Tom McLaughlin <tmclaugh@sdf.lonestar.org>
2
# $FreeBSD$
2
# $FreeBSD$
3
3
4
PORTNAME=	libgdiplus
4
PORTNAME=	libgdiplus
5
PORTVERSION=	5.6
5
PORTVERSION=	6.0.4
6
PORTREVISION=	2
7
CATEGORIES=	x11-toolkits
6
CATEGORIES=	x11-toolkits
8
MASTER_SITES=	http://download.mono-project.com/sources/${PORTNAME}/
7
MASTER_SITES=	http://download.mono-project.com/sources/${PORTNAME}/
9
8
10
MAINTAINER=	mono@FreeBSD.org
9
MAINTAINER=	prj@rootwyrm.com
11
COMMENT=	GDI+ API for System.Windows.Forms in Mono
10
COMMENT=	GDI+ API for System.Windows.Forms in Mono
12
11
13
LICENSE=	GPLv3
12
LICENSE=	GPLv3
14
LICENSE_FILE=	${WRKSRC}/COPYING
13
LICENSE_FILE=	${WRKSRC}/COPYING
15
14
16
LIB_DEPENDS=	libtiff.so:graphics/tiff \
15
LIB_DEPENDS=	libtiff.so:graphics/tiff \
17
		libgif.so:graphics/giflib \
16
		libgif.so:graphics/giflib \
18
		libpng.so:graphics/png \
17
		libpng.so:graphics/png \
19
		libcairo.so:graphics/cairo \
18
		libcairo.so:graphics/cairo \
19
		libpango-1.0.so:x11-toolkits/pango \
20
		libfreetype.so:print/freetype2 \
20
		libfreetype.so:print/freetype2 \
21
		libexif.so:graphics/libexif \
21
		libexif.so:graphics/libexif \
22
		libfontconfig.so:x11-fonts/fontconfig
22
		libfontconfig.so:x11-fonts/fontconfig
23
23
24
GNU_CONFIGURE=	yes
24
GNU_CONFIGURE=	yes
25
USES=		cpe gettext-runtime gmake gnome jpeg libtool:keepla pathfix \
25
USES=		cpe gettext-runtime gmake gnome jpeg libtool:keepla pathfix \
26
		pkgconfig
26
		pkgconfig
27
USE_GNOME=	glib20
27
USE_GNOME=	cairo glib20 pango
28
USE_LDCONFIG=	yes
28
USE_LDCONFIG=	yes
29
CPPFLAGS+=	-I${LOCALBASE}/include
29
CPPFLAGS+=	-I${LOCALBASE}/include
30
LDFLAGS+=	-L${LOCALBASE}/lib
30
LDFLAGS+=	-L${LOCALBASE}/lib
31
INSTALL_TARGET=	install-strip
31
INSTALL_TARGET=	install-strip
32
CPE_VENDOR=	mono-project
32
CPE_VENDOR=	mono-project
33
33
34
OPTIONS_DEFINE=	X11
34
OPTIONS_DEFINE=	X11
35
OPTIONS_DEFAULT=X11
35
OPTIONS_DEFAULT=X11
36
36
37
X11_USES=	xorg
37
X11_USES=	xorg
38
X11_USE=	XORG=x11,xrender
38
X11_USE=	XORG=x11,xrender
39
X11_CONFIGURE_OFF=	--without-x11
39
X11_CONFIGURE_OFF=	--without-x11
40
40
41
PLIST_FILES=	lib/libgdiplus.a \
41
PLIST_FILES=	lib/libgdiplus.a \
42
		lib/libgdiplus.la \
42
		lib/libgdiplus.la \
43
		lib/libgdiplus.so \
43
		lib/libgdiplus.so \
44
		lib/libgdiplus.so.0 \
44
		lib/libgdiplus.so.0 \
45
		lib/libgdiplus.so.0.0.0 \
45
		lib/libgdiplus.so.0.0.0 \
46
		libdata/pkgconfig/libgdiplus.pc
46
		libdata/pkgconfig/libgdiplus.pc
47
47
48
.include <bsd.port.mk>
48
.include <bsd.port.mk>
(-)distinfo (-3 / +3 lines)
Lines 1-3 Link Here
1
TIMESTAMP = 1534789592
1
TIMESTAMP = 1584469047
2
SHA256 (libgdiplus-5.6.tar.gz) = e1f2c0443af8d37b1a2971feb8826c82e932cff36dab814b94fce22f4d3dc53a
2
SHA256 (libgdiplus-6.0.4.tar.gz) = b75c38c9765d5b3e2fb3da4435f169c732983878c0f94b8bf9012137022abf29
3
SIZE (libgdiplus-5.6.tar.gz) = 731564
3
SIZE (libgdiplus-6.0.4.tar.gz) = 1390998
(-)files/patch-configure (-11 lines)
Lines 1-11 Link Here
1
--- configure.orig	2018-03-28 19:28:08 UTC
2
+++ configure
3
@@ -14133,7 +14133,7 @@ fi
4
 
5
 
6
 # Add xrender here so that we don't fail to find glib if we won't have xrender.pc
7
-if test "x$no_x" != "xyes" && "x$x11_available" = "xyes"; then
8
+if test "x$no_x" != "xyes" && test "x$x11_available" = "xyes"; then
9
    GDIPLUS_LIBS="$GDIPLUS_LIBS `$PKG_CONFIG --libs xrender `"
10
    GDIPLUS_CFLAGS="$GDIPLUS_CFLAGS `$PKG_CONFIG --cflags xrender `"
11
 fi
(-)files/patch-src_gifcodec.c (-307 lines)
Lines 1-307 Link Here
1
--- src/gifcodec.c.orig	2018-03-28 19:27:53 UTC
2
+++ src/gifcodec.c
3
@@ -39,6 +39,292 @@ GUID gdip_gif_image_format_guid = {0xb96
4
 
5
 #include "gifcodec.h"
6
 
7
+#define COLOR_ARRAY_SIZE 32768
8
+#define BITS_PER_PRIM_COLOR 5
9
+#define MAX_PRIM_COLOR      0x1f
10
+
11
+static int SortRGBAxis;
12
+
13
+typedef struct QuantizedColorType {
14
+    GifByteType RGB[3];
15
+    GifByteType NewColorIndex;
16
+    long Count;
17
+    struct QuantizedColorType *Pnext;
18
+} QuantizedColorType;
19
+
20
+typedef struct NewColorMapType {
21
+    GifByteType RGBMin[3], RGBWidth[3];
22
+    unsigned int NumEntries; /* # of QuantizedColorType in linked list below */
23
+    unsigned long Count; /* Total number of pixels in all the entries */
24
+    QuantizedColorType *QuantizedColors;
25
+} NewColorMapType;
26
+
27
+
28
+/****************************************************************************
29
+ * Routine called by qsort to compare two entries.
30
+ ****************************************************************************/
31
+static int
32
+SortCmpRtn(const void *Entry1,
33
+           const void *Entry2) {
34
+
35
+    return (*((QuantizedColorType **) Entry1))->RGB[SortRGBAxis] -
36
+       (*((QuantizedColorType **) Entry2))->RGB[SortRGBAxis];
37
+}
38
+
39
+/******************************************************************************
40
+ * Routine to subdivide the RGB space recursively using median cut in each
41
+ * axes alternatingly until ColorMapSize different cubes exists.
42
+ * The biggest cube in one dimension is subdivide unless it has only one entry.
43
+ * Returns GIF_ERROR if failed, otherwise GIF_OK.
44
+ ******************************************************************************/
45
+static int
46
+SubdivColorMap(NewColorMapType * NewColorSubdiv,
47
+               unsigned int ColorMapSize,
48
+               unsigned int *NewColorMapSize) {
49
+
50
+    int MaxSize;
51
+    unsigned int i, j, Index = 0, NumEntries, MinColor, MaxColor;
52
+    long Sum, Count;
53
+    QuantizedColorType *QuantizedColor, **SortArray;
54
+
55
+    while (ColorMapSize > *NewColorMapSize) {
56
+        /* Find candidate for subdivision: */
57
+        MaxSize = -1;
58
+        for (i = 0; i < *NewColorMapSize; i++) {
59
+            for (j = 0; j < 3; j++) {
60
+                if ((((int)NewColorSubdiv[i].RGBWidth[j]) > MaxSize) &&
61
+                      (NewColorSubdiv[i].NumEntries > 1)) {
62
+                    MaxSize = NewColorSubdiv[i].RGBWidth[j];
63
+                    Index = i;
64
+                    SortRGBAxis = j;
65
+                }
66
+            }
67
+        }
68
+
69
+        if (MaxSize == -1)
70
+            return GIF_OK;
71
+
72
+        /* Split the entry Index into two along the axis SortRGBAxis: */
73
+
74
+        /* Sort all elements in that entry along the given axis and split at
75
+         * the median.  */
76
+        SortArray = (QuantizedColorType **)malloc(
77
+                      sizeof(QuantizedColorType *) *
78
+                      NewColorSubdiv[Index].NumEntries);
79
+        if (SortArray == NULL)
80
+            return GIF_ERROR;
81
+        for (j = 0, QuantizedColor = NewColorSubdiv[Index].QuantizedColors;
82
+             j < NewColorSubdiv[Index].NumEntries && QuantizedColor != NULL;
83
+             j++, QuantizedColor = QuantizedColor->Pnext)
84
+            SortArray[j] = QuantizedColor;
85
+
86
+        qsort(SortArray, NewColorSubdiv[Index].NumEntries,
87
+              sizeof(QuantizedColorType *), SortCmpRtn);
88
+
89
+        /* Relink the sorted list into one: */
90
+        for (j = 0; j < NewColorSubdiv[Index].NumEntries - 1; j++)
91
+            SortArray[j]->Pnext = SortArray[j + 1];
92
+        SortArray[NewColorSubdiv[Index].NumEntries - 1]->Pnext = NULL;
93
+        NewColorSubdiv[Index].QuantizedColors = QuantizedColor = SortArray[0];
94
+        free((char *)SortArray);
95
+
96
+        /* Now simply add the Counts until we have half of the Count: */
97
+        Sum = NewColorSubdiv[Index].Count / 2 - QuantizedColor->Count;
98
+        NumEntries = 1;
99
+        Count = QuantizedColor->Count;
100
+        while (QuantizedColor->Pnext != NULL &&
101
+              (Sum -= QuantizedColor->Pnext->Count) >= 0 &&
102
+               QuantizedColor->Pnext->Pnext != NULL) {
103
+            QuantizedColor = QuantizedColor->Pnext;
104
+            NumEntries++;
105
+            Count += QuantizedColor->Count;
106
+        }
107
+        /* Save the values of the last color of the first half, and first
108
+         * of the second half so we can update the Bounding Boxes later.
109
+         * Also as the colors are quantized and the BBoxes are full 0..255,
110
+         * they need to be rescaled.
111
+         */
112
+        MaxColor = QuantizedColor->RGB[SortRGBAxis]; /* Max. of first half */
113
+       /* coverity[var_deref_op] */
114
+        MinColor = QuantizedColor->Pnext->RGB[SortRGBAxis]; /* of second */
115
+        MaxColor <<= (8 - BITS_PER_PRIM_COLOR);
116
+        MinColor <<= (8 - BITS_PER_PRIM_COLOR);
117
+
118
+        /* Partition right here: */
119
+        NewColorSubdiv[*NewColorMapSize].QuantizedColors =
120
+           QuantizedColor->Pnext;
121
+        QuantizedColor->Pnext = NULL;
122
+        NewColorSubdiv[*NewColorMapSize].Count = Count;
123
+        NewColorSubdiv[Index].Count -= Count;
124
+        NewColorSubdiv[*NewColorMapSize].NumEntries =
125
+           NewColorSubdiv[Index].NumEntries - NumEntries;
126
+        NewColorSubdiv[Index].NumEntries = NumEntries;
127
+        for (j = 0; j < 3; j++) {
128
+            NewColorSubdiv[*NewColorMapSize].RGBMin[j] =
129
+               NewColorSubdiv[Index].RGBMin[j];
130
+            NewColorSubdiv[*NewColorMapSize].RGBWidth[j] =
131
+               NewColorSubdiv[Index].RGBWidth[j];
132
+        }
133
+        NewColorSubdiv[*NewColorMapSize].RGBWidth[SortRGBAxis] =
134
+           NewColorSubdiv[*NewColorMapSize].RGBMin[SortRGBAxis] +
135
+           NewColorSubdiv[*NewColorMapSize].RGBWidth[SortRGBAxis] - MinColor;
136
+        NewColorSubdiv[*NewColorMapSize].RGBMin[SortRGBAxis] = MinColor;
137
+
138
+        NewColorSubdiv[Index].RGBWidth[SortRGBAxis] =
139
+           MaxColor - NewColorSubdiv[Index].RGBMin[SortRGBAxis];
140
+
141
+        (*NewColorMapSize)++;
142
+    }
143
+
144
+    return GIF_OK;
145
+}
146
+
147
+/******************************************************************************
148
+ * Quantize high resolution image into lower one. Input image consists of a
149
+ * 2D array for each of the RGB colors with size Width by Height. There is no
150
+ * Color map for the input. Output is a quantized image with 2D array of
151
+ * indexes into the output color map.
152
+ *   Note input image can be 24 bits at the most (8 for red/green/blue) and
153
+ * the output has 256 colors at the most (256 entries in the color map.).
154
+ * ColorMapSize specifies size of color map up to 256 and will be updated to
155
+ * real size before returning.
156
+ *   Also non of the parameter are allocated by this routine.
157
+ *   This function returns GIF_OK if succesfull, GIF_ERROR otherwise.
158
+ ******************************************************************************/
159
+static int
160
+QuantizeBuffer(unsigned int Width,
161
+               unsigned int Height,
162
+               int *ColorMapSize,
163
+               GifByteType * RedInput,
164
+               GifByteType * GreenInput,
165
+               GifByteType * BlueInput,
166
+               GifByteType * OutputBuffer,
167
+               GifColorType * OutputColorMap) {
168
+
169
+    unsigned int Index, NumOfEntries;
170
+    int i, j, MaxRGBError[3];
171
+    unsigned int NewColorMapSize;
172
+    long Red, Green, Blue;
173
+    NewColorMapType NewColorSubdiv[256];
174
+    QuantizedColorType *ColorArrayEntries, *QuantizedColor;
175
+
176
+    ColorArrayEntries = (QuantizedColorType *)malloc(
177
+                           sizeof(QuantizedColorType) * COLOR_ARRAY_SIZE);
178
+    if (ColorArrayEntries == NULL) {
179
+        return GIF_ERROR;
180
+    }
181
+
182
+    for (i = 0; i < COLOR_ARRAY_SIZE; i++) {
183
+        ColorArrayEntries[i].RGB[0] = i >> (2 * BITS_PER_PRIM_COLOR);
184
+        ColorArrayEntries[i].RGB[1] = (i >> BITS_PER_PRIM_COLOR) &
185
+           MAX_PRIM_COLOR;
186
+        ColorArrayEntries[i].RGB[2] = i & MAX_PRIM_COLOR;
187
+        ColorArrayEntries[i].Count = 0;
188
+    }
189
+
190
+    /* Sample the colors and their distribution: */
191
+    for (i = 0; i < (int)(Width * Height); i++) {
192
+        Index = ((RedInput[i] >> (8 - BITS_PER_PRIM_COLOR)) <<
193
+                  (2 * BITS_PER_PRIM_COLOR)) +
194
+                ((GreenInput[i] >> (8 - BITS_PER_PRIM_COLOR)) <<
195
+                  BITS_PER_PRIM_COLOR) +
196
+                (BlueInput[i] >> (8 - BITS_PER_PRIM_COLOR));
197
+        ColorArrayEntries[Index].Count++;
198
+    }
199
+
200
+    /* Put all the colors in the first entry of the color map, and call the
201
+     * recursive subdivision process.  */
202
+    for (i = 0; i < 256; i++) {
203
+        NewColorSubdiv[i].QuantizedColors = NULL;
204
+        NewColorSubdiv[i].Count = NewColorSubdiv[i].NumEntries = 0;
205
+        for (j = 0; j < 3; j++) {
206
+            NewColorSubdiv[i].RGBMin[j] = 0;
207
+            NewColorSubdiv[i].RGBWidth[j] = 255;
208
+        }
209
+    }
210
+
211
+    /* Find the non empty entries in the color table and chain them: */
212
+    for (i = 0; i < COLOR_ARRAY_SIZE; i++)
213
+        if (ColorArrayEntries[i].Count > 0)
214
+            break;
215
+    QuantizedColor = NewColorSubdiv[0].QuantizedColors = &ColorArrayEntries[i];
216
+    NumOfEntries = 1;
217
+    while (++i < COLOR_ARRAY_SIZE)
218
+        if (ColorArrayEntries[i].Count > 0) {
219
+            QuantizedColor->Pnext = &ColorArrayEntries[i];
220
+            QuantizedColor = &ColorArrayEntries[i];
221
+            NumOfEntries++;
222
+        }
223
+    QuantizedColor->Pnext = NULL;
224
+
225
+    NewColorSubdiv[0].NumEntries = NumOfEntries; /* Different sampled colors */
226
+    NewColorSubdiv[0].Count = ((long)Width) * Height; /* Pixels */
227
+    NewColorMapSize = 1;
228
+    if (SubdivColorMap(NewColorSubdiv, *ColorMapSize, &NewColorMapSize) !=
229
+       GIF_OK) {
230
+        free((char *)ColorArrayEntries);
231
+        return GIF_ERROR;
232
+    }
233
+    if (NewColorMapSize < *ColorMapSize) {
234
+        /* And clear rest of color map: */
235
+        for (i = NewColorMapSize; i < *ColorMapSize; i++)
236
+            OutputColorMap[i].Red = OutputColorMap[i].Green =
237
+                OutputColorMap[i].Blue = 0;
238
+    }
239
+
240
+    /* Average the colors in each entry to be the color to be used in the
241
+     * output color map, and plug it into the output color map itself. */
242
+    for (i = 0; i < NewColorMapSize; i++) {
243
+        if ((j = NewColorSubdiv[i].NumEntries) > 0) {
244
+            QuantizedColor = NewColorSubdiv[i].QuantizedColors;
245
+            Red = Green = Blue = 0;
246
+            while (QuantizedColor) {
247
+                QuantizedColor->NewColorIndex = i;
248
+                Red += QuantizedColor->RGB[0];
249
+                Green += QuantizedColor->RGB[1];
250
+                Blue += QuantizedColor->RGB[2];
251
+                QuantizedColor = QuantizedColor->Pnext;
252
+            }
253
+            OutputColorMap[i].Red = (Red << (8 - BITS_PER_PRIM_COLOR)) / j;
254
+            OutputColorMap[i].Green = (Green << (8 - BITS_PER_PRIM_COLOR)) / j;
255
+            OutputColorMap[i].Blue = (Blue << (8 - BITS_PER_PRIM_COLOR)) / j;
256
+        } else
257
+            fprintf(stderr,
258
+                    "\n%s: Null entry in quantized color map - that's weird.\n",
259
+                    "libgdiplus");
260
+    }
261
+
262
+    /* Finally scan the input buffer again and put the mapped index in the
263
+     * output buffer.  */
264
+    MaxRGBError[0] = MaxRGBError[1] = MaxRGBError[2] = 0;
265
+    for (i = 0; i < (int)(Width * Height); i++) {
266
+        Index = ((RedInput[i] >> (8 - BITS_PER_PRIM_COLOR)) <<
267
+                 (2 * BITS_PER_PRIM_COLOR)) +
268
+                ((GreenInput[i] >> (8 - BITS_PER_PRIM_COLOR)) <<
269
+                 BITS_PER_PRIM_COLOR) +
270
+                (BlueInput[i] >> (8 - BITS_PER_PRIM_COLOR));
271
+        Index = ColorArrayEntries[Index].NewColorIndex;
272
+        OutputBuffer[i] = Index;
273
+        if (MaxRGBError[0] < ABS(OutputColorMap[Index].Red - RedInput[i]))
274
+            MaxRGBError[0] = ABS(OutputColorMap[Index].Red - RedInput[i]);
275
+        if (MaxRGBError[1] < ABS(OutputColorMap[Index].Green - GreenInput[i]))
276
+            MaxRGBError[1] = ABS(OutputColorMap[Index].Green - GreenInput[i]);
277
+        if (MaxRGBError[2] < ABS(OutputColorMap[Index].Blue - BlueInput[i]))
278
+            MaxRGBError[2] = ABS(OutputColorMap[Index].Blue - BlueInput[i]);
279
+    }
280
+
281
+#ifdef DEBUG
282
+    fprintf(stderr,
283
+            "Quantization L(0) errors: Red = %d, Green = %d, Blue = %d.\n",
284
+            MaxRGBError[0], MaxRGBError[1], MaxRGBError[2]);
285
+#endif /* DEBUG */
286
+
287
+    free((char *)ColorArrayEntries);
288
+
289
+    *ColorMapSize = NewColorMapSize;
290
+
291
+    return GIF_OK;
292
+}
293
 
294
 /* Data structure used for callback */
295
 typedef struct
296
@@ -852,11 +1138,7 @@ gdip_save_gif_image (void *stream, GpIma
297
 					}
298
 				}
299
 				if (
300
-#if GIFLIB_MAJOR >= 5
301
-				GifQuantizeBuffer(
302
-#else
303
 				QuantizeBuffer(
304
-#endif
305
 						bitmap_data->width, bitmap_data->height, &cmap_size, 
306
 						red,  green, blue, pixbuf, cmap->Colors) == GIF_ERROR) {
307
 					goto error;

Return to bug 239614