- 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)
|
||||
{
|
||||
printf ("GD Source: ERROR Null returned by gdImageCreateFromPngSource\n");
|
||||
printf
|
||||
("GD Source: ERROR Null returned by gdImageCreateFromPngSource\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -195,7 +196,8 @@ main (int argc, char **argv)
|
|||
in = fopen (of, "rb");
|
||||
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
|
||||
{
|
||||
|
@ -230,7 +232,8 @@ main (int argc, char **argv)
|
|||
im3 = gdImageCreateFromGd2Part (in, 200, 300, 150, 100);
|
||||
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 (im3);
|
||||
|
@ -305,7 +308,8 @@ main (int argc, char **argv)
|
|||
#endif /* HAVE_LIBJPEG */
|
||||
/* Assume the color closest to black is the foreground
|
||||
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");
|
||||
foreground = gdImageColorClosest (im, 0, 0, 0);
|
||||
fprintf (stderr, "Foreground index is %d\n", foreground);
|
||||
|
@ -336,8 +340,7 @@ main (int argc, char **argv)
|
|||
{
|
||||
fprintf (stderr, "%02X%02X%02X\n",
|
||||
gdImageRed (im2, i),
|
||||
gdImageGreen (im2, i),
|
||||
gdImageBlue (im2, i));
|
||||
gdImageGreen (im2, i), gdImageBlue (im2, i));
|
||||
}
|
||||
fclose (in);
|
||||
if (!im2)
|
||||
|
@ -349,7 +352,8 @@ main (int argc, char **argv)
|
|||
out = fopen ("test/gdtest_wbmp_to_png.png", "wb");
|
||||
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);
|
||||
}
|
||||
gdImagePng (im2, out);
|
||||
|
@ -359,7 +363,7 @@ main (int argc, char **argv)
|
|||
gdImageDestroy (im);
|
||||
gdImageDestroy (ref);
|
||||
#else
|
||||
fprintf(stderr, "No PNG library support.\n");
|
||||
fprintf (stderr, "No PNG library support.\n");
|
||||
#endif /* HAVE_LIBPNG */
|
||||
|
||||
return 0;
|
||||
|
|
141
src/gdtestft.c
141
src/gdtestft.c
|
@ -55,18 +55,23 @@ main (int argc, char *argv[])
|
|||
double angle = DEG2RAD (90);
|
||||
#endif
|
||||
char *f;
|
||||
if (argc == 2) {
|
||||
f = argv[1];
|
||||
} else {
|
||||
/* 2.02: usage message. Defaulting to Times wasn't working well for the
|
||||
many people with no /usr/share/fonts/truetype. */
|
||||
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);
|
||||
}
|
||||
if (argc == 2)
|
||||
{
|
||||
f = argv[1];
|
||||
}
|
||||
else
|
||||
{
|
||||
/* 2.02: usage message. Defaulting to Times wasn't working well for the
|
||||
many people with no /usr/share/fonts/truetype. */
|
||||
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 */
|
||||
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)
|
||||
{
|
||||
fprintf (stderr, err);
|
||||
|
@ -78,13 +83,13 @@ main (int argc, char *argv[])
|
|||
sy = MAXY (brect) - MINY (brect) + 6;
|
||||
#if 1
|
||||
/* Would be palette color 8-bit (which of course is still allowed,
|
||||
but not impressive when used with a JPEG background and antialiasing
|
||||
and alpha channel and so on!) */
|
||||
but not impressive when used with a JPEG background and antialiasing
|
||||
and alpha channel and so on!) */
|
||||
im = gdImageCreate (sx * 3, sy);
|
||||
#else
|
||||
/* gd 2.0: true color images can use freetype too,
|
||||
and they can do antialiasing against arbitrary
|
||||
complex backgrounds. */
|
||||
and they can do antialiasing against arbitrary
|
||||
complex backgrounds. */
|
||||
im = gdImageCreateTrueColor (sx * 3, sy);
|
||||
#endif
|
||||
/* 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);
|
||||
/* Load a pretty background and resample it to cover the entire image */
|
||||
{
|
||||
FILE *in = fopen("eleanor.jpg", "rb");
|
||||
gdImagePtr imb;
|
||||
if (in) {
|
||||
FILE *in = fopen ("eleanor.jpg", "rb");
|
||||
gdImagePtr imb;
|
||||
if (in)
|
||||
{
|
||||
#ifdef HAVE_LIBJPEG
|
||||
imb = gdImageCreateFromJpeg(in);
|
||||
imb = gdImageCreateFromJpeg (in);
|
||||
#else
|
||||
fprintf(stderr, "No JPEG library support.\n");
|
||||
fprintf (stderr, "No JPEG library support.\n");
|
||||
#endif
|
||||
if (!imb) {
|
||||
fprintf(stderr, "gdImageCreateFromJpeg failed\n");
|
||||
exit(1);
|
||||
}
|
||||
if (!im->trueColor) {
|
||||
/* If destination is not truecolor, convert the JPEG to a
|
||||
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 (!imb)
|
||||
{
|
||||
fprintf (stderr, "gdImageCreateFromJpeg failed\n");
|
||||
exit (1);
|
||||
}
|
||||
if (!im->trueColor)
|
||||
{
|
||||
/* If destination is not truecolor, convert the JPEG to a
|
||||
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
|
||||
gdImageTrueColorToPalette(imb, 0, 128);
|
||||
gdImageTrueColorToPalette (imb, 0, 128);
|
||||
#endif
|
||||
}
|
||||
/* Resample background image to cover new image exactly */
|
||||
gdImageCopyResampled(im, imb, 0, 0, 0, 0, sx * 3, sy,
|
||||
gdImageSX(imb), gdImageSY(imb));
|
||||
} else {
|
||||
/* 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);
|
||||
}
|
||||
}
|
||||
/* Resample background image to cover new image exactly */
|
||||
gdImageCopyResampled (im, imb, 0, 0, 0, 0, sx * 3, sy,
|
||||
gdImageSX (imb), gdImageSY (imb));
|
||||
}
|
||||
else
|
||||
{
|
||||
/* 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
|
||||
the test program used black. Funny, huh? Let's do a more interesting
|
||||
color this time. */
|
||||
the test program used black. Funny, huh? Let's do a more interesting
|
||||
color this time. */
|
||||
blue = gdImageColorResolve (im, 128, 192, 255);
|
||||
/* 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 */
|
||||
x = 0 - MINX (brect) + 3;
|
||||
y = 0 - MINY (brect) + 3;
|
||||
|
@ -154,36 +164,39 @@ main (int argc, char *argv[])
|
|||
return 1;
|
||||
}
|
||||
/* TBB: Write img to test/fttest.jpg or test/fttest.png */
|
||||
if (im->trueColor) {
|
||||
out = fopen ("test/fttest.jpg", "wb");
|
||||
if (!out)
|
||||
if (im->trueColor)
|
||||
{
|
||||
fprintf (stderr, "Can't create test/fttest.jpg\n");
|
||||
exit (1);
|
||||
}
|
||||
/* Fairly high JPEG quality setting */
|
||||
out = fopen ("test/fttest.jpg", "wb");
|
||||
if (!out)
|
||||
{
|
||||
fprintf (stderr, "Can't create test/fttest.jpg\n");
|
||||
exit (1);
|
||||
}
|
||||
/* Fairly high JPEG quality setting */
|
||||
#ifdef HAVE_LIBJPEG
|
||||
gdImageJpeg (im, out, 90);
|
||||
gdImageJpeg (im, out, 90);
|
||||
#else
|
||||
fprintf(stderr, "No JPEG library support.\n");
|
||||
fprintf (stderr, "No JPEG library support.\n");
|
||||
#endif
|
||||
fclose (out);
|
||||
fprintf (stderr, "Test image written to test/fttest.jpg\n");
|
||||
} else {
|
||||
out = fopen ("test/fttest.png", "wb");
|
||||
if (!out)
|
||||
fclose (out);
|
||||
fprintf (stderr, "Test image written to test/fttest.jpg\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf (stderr, "Can't create test/fttest.png\n");
|
||||
exit (1);
|
||||
}
|
||||
out = fopen ("test/fttest.png", "wb");
|
||||
if (!out)
|
||||
{
|
||||
fprintf (stderr, "Can't create test/fttest.png\n");
|
||||
exit (1);
|
||||
}
|
||||
#ifdef HAVE_LIBJPEG
|
||||
gdImagePng (im, out);
|
||||
gdImagePng (im, out);
|
||||
#else
|
||||
fprintf(stderr, "No PNG library support.\n");
|
||||
fprintf (stderr, "No PNG library support.\n");
|
||||
#endif
|
||||
fclose (out);
|
||||
fprintf (stderr, "Test image written to test/fttest.png\n");
|
||||
}
|
||||
fclose (out);
|
||||
fprintf (stderr, "Test image written to test/fttest.png\n");
|
||||
}
|
||||
/* Destroy it */
|
||||
gdImageDestroy (im);
|
||||
|
||||
|
|
|
@ -44,7 +44,7 @@ main (int argc, char **argv)
|
|||
#ifdef HAVE_LIBPNG
|
||||
gdImagePng (im, out);
|
||||
#else
|
||||
fprintf(stderr, "No PNG library support.\n");
|
||||
fprintf (stderr, "No PNG library support.\n");
|
||||
#endif
|
||||
fclose (out);
|
||||
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