- sync to 2.0.9
parent
d0304c9e1c
commit
0a3a5068ac
20
src/gdtest.c
20
src/gdtest.c
|
@ -173,7 +173,8 @@ main (int argc, char **argv)
|
||||||
|
|
||||||
if (im2 == NULL)
|
if (im2 == NULL)
|
||||||
{
|
{
|
||||||
printf ("GD Source: ERROR Null returned by gdImageCreateFromPngSource\n");
|
printf
|
||||||
|
("GD Source: ERROR Null returned by gdImageCreateFromPngSource\n");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -195,7 +196,8 @@ main (int argc, char **argv)
|
||||||
in = fopen (of, "rb");
|
in = fopen (of, "rb");
|
||||||
if (!in)
|
if (!in)
|
||||||
{
|
{
|
||||||
fprintf (stderr, "GD Sink: ERROR - GD Sink Output file does not exist!\n");
|
fprintf (stderr,
|
||||||
|
"GD Sink: ERROR - GD Sink Output file does not exist!\n");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -230,7 +232,8 @@ main (int argc, char **argv)
|
||||||
im3 = gdImageCreateFromGd2Part (in, 200, 300, 150, 100);
|
im3 = gdImageCreateFromGd2Part (in, 200, 300, 150, 100);
|
||||||
fclose (in);
|
fclose (in);
|
||||||
|
|
||||||
CompareImages ("GD2Part (gdtest_200_300_150_100.png, gdtest.gd2(part))", im2, im3);
|
CompareImages ("GD2Part (gdtest_200_300_150_100.png, gdtest.gd2(part))",
|
||||||
|
im2, im3);
|
||||||
|
|
||||||
gdImageDestroy (im2);
|
gdImageDestroy (im2);
|
||||||
gdImageDestroy (im3);
|
gdImageDestroy (im3);
|
||||||
|
@ -305,7 +308,8 @@ main (int argc, char **argv)
|
||||||
#endif /* HAVE_LIBJPEG */
|
#endif /* HAVE_LIBJPEG */
|
||||||
/* Assume the color closest to black is the foreground
|
/* Assume the color closest to black is the foreground
|
||||||
color for the B&W wbmp image. */
|
color for the B&W wbmp image. */
|
||||||
fprintf (stderr, "NOTE: the WBMP output image will NOT match the original unless the original\n"
|
fprintf (stderr,
|
||||||
|
"NOTE: the WBMP output image will NOT match the original unless the original\n"
|
||||||
"is also black and white. This is OK!\n");
|
"is also black and white. This is OK!\n");
|
||||||
foreground = gdImageColorClosest (im, 0, 0, 0);
|
foreground = gdImageColorClosest (im, 0, 0, 0);
|
||||||
fprintf (stderr, "Foreground index is %d\n", foreground);
|
fprintf (stderr, "Foreground index is %d\n", foreground);
|
||||||
|
@ -336,8 +340,7 @@ main (int argc, char **argv)
|
||||||
{
|
{
|
||||||
fprintf (stderr, "%02X%02X%02X\n",
|
fprintf (stderr, "%02X%02X%02X\n",
|
||||||
gdImageRed (im2, i),
|
gdImageRed (im2, i),
|
||||||
gdImageGreen (im2, i),
|
gdImageGreen (im2, i), gdImageBlue (im2, i));
|
||||||
gdImageBlue (im2, i));
|
|
||||||
}
|
}
|
||||||
fclose (in);
|
fclose (in);
|
||||||
if (!im2)
|
if (!im2)
|
||||||
|
@ -349,7 +352,8 @@ main (int argc, char **argv)
|
||||||
out = fopen ("test/gdtest_wbmp_to_png.png", "wb");
|
out = fopen ("test/gdtest_wbmp_to_png.png", "wb");
|
||||||
if (!out)
|
if (!out)
|
||||||
{
|
{
|
||||||
fprintf (stderr, "Can't create file test/gdtest_wbmp_to_png.png.\n");
|
fprintf (stderr,
|
||||||
|
"Can't create file test/gdtest_wbmp_to_png.png.\n");
|
||||||
exit (1);
|
exit (1);
|
||||||
}
|
}
|
||||||
gdImagePng (im2, out);
|
gdImagePng (im2, out);
|
||||||
|
@ -359,7 +363,7 @@ main (int argc, char **argv)
|
||||||
gdImageDestroy (im);
|
gdImageDestroy (im);
|
||||||
gdImageDestroy (ref);
|
gdImageDestroy (ref);
|
||||||
#else
|
#else
|
||||||
fprintf(stderr, "No PNG library support.\n");
|
fprintf (stderr, "No PNG library support.\n");
|
||||||
#endif /* HAVE_LIBPNG */
|
#endif /* HAVE_LIBPNG */
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
141
src/gdtestft.c
141
src/gdtestft.c
|
@ -55,18 +55,23 @@ main (int argc, char *argv[])
|
||||||
double angle = DEG2RAD (90);
|
double angle = DEG2RAD (90);
|
||||||
#endif
|
#endif
|
||||||
char *f;
|
char *f;
|
||||||
if (argc == 2) {
|
if (argc == 2)
|
||||||
f = argv[1];
|
{
|
||||||
} else {
|
f = argv[1];
|
||||||
/* 2.02: usage message. Defaulting to Times wasn't working well for the
|
}
|
||||||
many people with no /usr/share/fonts/truetype. */
|
else
|
||||||
fprintf(stderr, "Usage: gdtestft fontfilename\n");
|
{
|
||||||
fprintf(stderr, "If fontfilename is not a full or relative path, GDFONTPATH is searched for\n"
|
/* 2.02: usage message. Defaulting to Times wasn't working well for the
|
||||||
"it. If GDFONTPATH is not set, /usr/share/fonts/truetype is searched.\n");
|
many people with no /usr/share/fonts/truetype. */
|
||||||
exit(1);
|
fprintf (stderr, "Usage: gdtestft fontfilename\n");
|
||||||
}
|
fprintf (stderr,
|
||||||
|
"If fontfilename is not a full or relative path, GDFONTPATH is searched for\n"
|
||||||
|
"it. If GDFONTPATH is not set, /usr/share/fonts/truetype is searched.\n");
|
||||||
|
exit (1);
|
||||||
|
}
|
||||||
/* obtain brect so that we can size the image */
|
/* obtain brect so that we can size the image */
|
||||||
err = gdImageStringFT ((gdImagePtr) NULL, &brect[0], 0, f, sz, angle, 0, 0, s);
|
err =
|
||||||
|
gdImageStringFT ((gdImagePtr) NULL, &brect[0], 0, f, sz, angle, 0, 0, s);
|
||||||
if (err)
|
if (err)
|
||||||
{
|
{
|
||||||
fprintf (stderr, err);
|
fprintf (stderr, err);
|
||||||
|
@ -78,13 +83,13 @@ main (int argc, char *argv[])
|
||||||
sy = MAXY (brect) - MINY (brect) + 6;
|
sy = MAXY (brect) - MINY (brect) + 6;
|
||||||
#if 1
|
#if 1
|
||||||
/* Would be palette color 8-bit (which of course is still allowed,
|
/* Would be palette color 8-bit (which of course is still allowed,
|
||||||
but not impressive when used with a JPEG background and antialiasing
|
but not impressive when used with a JPEG background and antialiasing
|
||||||
and alpha channel and so on!) */
|
and alpha channel and so on!) */
|
||||||
im = gdImageCreate (sx * 3, sy);
|
im = gdImageCreate (sx * 3, sy);
|
||||||
#else
|
#else
|
||||||
/* gd 2.0: true color images can use freetype too,
|
/* gd 2.0: true color images can use freetype too,
|
||||||
and they can do antialiasing against arbitrary
|
and they can do antialiasing against arbitrary
|
||||||
complex backgrounds. */
|
complex backgrounds. */
|
||||||
im = gdImageCreateTrueColor (sx * 3, sy);
|
im = gdImageCreateTrueColor (sx * 3, sy);
|
||||||
#endif
|
#endif
|
||||||
/* Background color. gd 2.0: fill the image with it; truecolor
|
/* Background color. gd 2.0: fill the image with it; truecolor
|
||||||
|
@ -92,42 +97,47 @@ main (int argc, char *argv[])
|
||||||
white = gdImageColorResolve (im, 255, 255, 255);
|
white = gdImageColorResolve (im, 255, 255, 255);
|
||||||
/* Load a pretty background and resample it to cover the entire image */
|
/* Load a pretty background and resample it to cover the entire image */
|
||||||
{
|
{
|
||||||
FILE *in = fopen("eleanor.jpg", "rb");
|
FILE *in = fopen ("eleanor.jpg", "rb");
|
||||||
gdImagePtr imb;
|
gdImagePtr imb;
|
||||||
if (in) {
|
if (in)
|
||||||
|
{
|
||||||
#ifdef HAVE_LIBJPEG
|
#ifdef HAVE_LIBJPEG
|
||||||
imb = gdImageCreateFromJpeg(in);
|
imb = gdImageCreateFromJpeg (in);
|
||||||
#else
|
#else
|
||||||
fprintf(stderr, "No JPEG library support.\n");
|
fprintf (stderr, "No JPEG library support.\n");
|
||||||
#endif
|
#endif
|
||||||
if (!imb) {
|
if (!imb)
|
||||||
fprintf(stderr, "gdImageCreateFromJpeg failed\n");
|
{
|
||||||
exit(1);
|
fprintf (stderr, "gdImageCreateFromJpeg failed\n");
|
||||||
}
|
exit (1);
|
||||||
if (!im->trueColor) {
|
}
|
||||||
/* If destination is not truecolor, convert the JPEG to a
|
if (!im->trueColor)
|
||||||
reasonably high-quality palette version. This is not as good
|
{
|
||||||
as creating a truecolor output file, of course. Leave many
|
/* If destination is not truecolor, convert the JPEG to a
|
||||||
colors for text smoothing. */
|
reasonably high-quality palette version. This is not as good
|
||||||
|
as creating a truecolor output file, of course. Leave many
|
||||||
|
colors for text smoothing. */
|
||||||
#if 1
|
#if 1
|
||||||
gdImageTrueColorToPalette(imb, 0, 128);
|
gdImageTrueColorToPalette (imb, 0, 128);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
/* Resample background image to cover new image exactly */
|
/* Resample background image to cover new image exactly */
|
||||||
gdImageCopyResampled(im, imb, 0, 0, 0, 0, sx * 3, sy,
|
gdImageCopyResampled (im, imb, 0, 0, 0, 0, sx * 3, sy,
|
||||||
gdImageSX(imb), gdImageSY(imb));
|
gdImageSX (imb), gdImageSY (imb));
|
||||||
} else {
|
}
|
||||||
/* Can't get background, so paint a simple one */
|
else
|
||||||
/* Truecolor images start out black, so paint it white */
|
{
|
||||||
gdImageFilledRectangle (im, 0, 0, sx * 3, sy, white);
|
/* Can't get background, so paint a simple one */
|
||||||
}
|
/* Truecolor images start out black, so paint it white */
|
||||||
|
gdImageFilledRectangle (im, 0, 0, sx * 3, sy, white);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
/* TBB 2.0.2: only black was working, and I didn't know it because
|
/* TBB 2.0.2: only black was working, and I didn't know it because
|
||||||
the test program used black. Funny, huh? Let's do a more interesting
|
the test program used black. Funny, huh? Let's do a more interesting
|
||||||
color this time. */
|
color this time. */
|
||||||
blue = gdImageColorResolve (im, 128, 192, 255);
|
blue = gdImageColorResolve (im, 128, 192, 255);
|
||||||
/* Almost-transparent blue (alpha blending), with antialiasing */
|
/* Almost-transparent blue (alpha blending), with antialiasing */
|
||||||
blueAlpha = gdImageColorResolveAlpha(im, 128, 192, 255, gdAlphaMax / 2);
|
blueAlpha = gdImageColorResolveAlpha (im, 128, 192, 255, gdAlphaMax / 2);
|
||||||
/* render the string, offset origin to center string */
|
/* render the string, offset origin to center string */
|
||||||
x = 0 - MINX (brect) + 3;
|
x = 0 - MINX (brect) + 3;
|
||||||
y = 0 - MINY (brect) + 3;
|
y = 0 - MINY (brect) + 3;
|
||||||
|
@ -154,36 +164,39 @@ main (int argc, char *argv[])
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
/* TBB: Write img to test/fttest.jpg or test/fttest.png */
|
/* TBB: Write img to test/fttest.jpg or test/fttest.png */
|
||||||
if (im->trueColor) {
|
if (im->trueColor)
|
||||||
out = fopen ("test/fttest.jpg", "wb");
|
|
||||||
if (!out)
|
|
||||||
{
|
{
|
||||||
fprintf (stderr, "Can't create test/fttest.jpg\n");
|
out = fopen ("test/fttest.jpg", "wb");
|
||||||
exit (1);
|
if (!out)
|
||||||
}
|
{
|
||||||
/* Fairly high JPEG quality setting */
|
fprintf (stderr, "Can't create test/fttest.jpg\n");
|
||||||
|
exit (1);
|
||||||
|
}
|
||||||
|
/* Fairly high JPEG quality setting */
|
||||||
#ifdef HAVE_LIBJPEG
|
#ifdef HAVE_LIBJPEG
|
||||||
gdImageJpeg (im, out, 90);
|
gdImageJpeg (im, out, 90);
|
||||||
#else
|
#else
|
||||||
fprintf(stderr, "No JPEG library support.\n");
|
fprintf (stderr, "No JPEG library support.\n");
|
||||||
#endif
|
#endif
|
||||||
fclose (out);
|
fclose (out);
|
||||||
fprintf (stderr, "Test image written to test/fttest.jpg\n");
|
fprintf (stderr, "Test image written to test/fttest.jpg\n");
|
||||||
} else {
|
}
|
||||||
out = fopen ("test/fttest.png", "wb");
|
else
|
||||||
if (!out)
|
|
||||||
{
|
{
|
||||||
fprintf (stderr, "Can't create test/fttest.png\n");
|
out = fopen ("test/fttest.png", "wb");
|
||||||
exit (1);
|
if (!out)
|
||||||
}
|
{
|
||||||
|
fprintf (stderr, "Can't create test/fttest.png\n");
|
||||||
|
exit (1);
|
||||||
|
}
|
||||||
#ifdef HAVE_LIBJPEG
|
#ifdef HAVE_LIBJPEG
|
||||||
gdImagePng (im, out);
|
gdImagePng (im, out);
|
||||||
#else
|
#else
|
||||||
fprintf(stderr, "No PNG library support.\n");
|
fprintf (stderr, "No PNG library support.\n");
|
||||||
#endif
|
#endif
|
||||||
fclose (out);
|
fclose (out);
|
||||||
fprintf (stderr, "Test image written to test/fttest.png\n");
|
fprintf (stderr, "Test image written to test/fttest.png\n");
|
||||||
}
|
}
|
||||||
/* Destroy it */
|
/* Destroy it */
|
||||||
gdImageDestroy (im);
|
gdImageDestroy (im);
|
||||||
|
|
||||||
|
|
|
@ -44,7 +44,7 @@ main (int argc, char **argv)
|
||||||
#ifdef HAVE_LIBPNG
|
#ifdef HAVE_LIBPNG
|
||||||
gdImagePng (im, out);
|
gdImagePng (im, out);
|
||||||
#else
|
#else
|
||||||
fprintf(stderr, "No PNG library support.\n");
|
fprintf (stderr, "No PNG library support.\n");
|
||||||
#endif
|
#endif
|
||||||
fclose (out);
|
fclose (out);
|
||||||
gdImageDestroy (im);
|
gdImageDestroy (im);
|
||||||
|
|
2393
src/jisx0208.h
2393
src/jisx0208.h
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue