- add the c++ binding to the build

- don't try to compile jpeg/png if the format is not enabled
master
pajoye 2008-01-15 21:47:49 +00:00
parent f9c40d7ab2
commit 0f62911ab0
3 changed files with 51 additions and 3 deletions

View File

@ -2,12 +2,18 @@
SET (LIBGD_SRC_FILES
gd.c
gdfx.c
gdfx.h
gd_crop.c
gd_transform.c
gd_security.c
gdpp.cxx
gdpp.h
gd_gd.c
gd_gd2.c
gd_io.c
gd_io.h
gd_io_stream.cxx
gd_io_stream.h
gd_io_dp.c
gd_gif_in.c
gd_gif_out.c
@ -15,18 +21,26 @@ SET (LIBGD_SRC_FILES
gd_io_ss.c
gd_jpeg.c
gd_nnquant.c
gd_nnquant.h
gd_png.c
gd_tiff.c
gd_tga.c
gd_tga.h
gd_ss.c
gd_topal.c
gd_wbmp.c
gdcache.c
gdcache.h
gdfontg.c
gdfontg.h
gdfontl.c
gdfontl.h
gdfontmb.c
gdfontmb.h
gdfonts.c
gdfonts.h
gdfontt.c
gdfontt.h
gdft.c
gdhelpers.c
gdhelpers.h
@ -35,6 +49,7 @@ SET (LIBGD_SRC_FILES
gdxpm.c
jisx0208.h
wbmp.c
gd.h
wbmp.h
)

View File

@ -40,15 +40,18 @@ namespace GD
0x89 0x50 0x4E 0x47 0x0D 0x0A 0x1A 0x0A
== .PNG\r\n.\n
*/
#if HAVE_PNG
case 0x89: // PNG
rtn = CreateFromPng(in);
break;
#endif
/* GIF
0x47 0x49 0x46
*/
case 0x47: // GIF
rtn = CreateFromGif(in);
break;
#if HAVE_JPEG
/* JPEG
A JFIF-standard file will start with the four bytes (hex) FF D8 FF E0,
followed by two variable bytes (often hex 00 10), followed by 'JFIF'.
@ -56,6 +59,7 @@ namespace GD
case 0xFF: // JPEG
rtn = CreateFromJpeg(in);
break;
#endif
/* WBMP
WBMP Type 0: B/W, Uncompressed bitmap is the only gd supported type
*/
@ -118,6 +122,7 @@ namespace GD
bool rtn;
switch (in.peek())
{
#if HAVE_PNG
/* PNG
The first eight bytes of a PNG file always contain the following (decimal) values:
0x89 0x50 0x4E 0x47 0x0D 0x0A 0x1A 0x0A
@ -126,12 +131,16 @@ namespace GD
case 0x89: // PNG
rtn = CreateFromPng(in);
break;
#endif
/* GIF
0x47 0x49 0x46
*/
case 0x47: // GIF
rtn = CreateFromGif(in);
break;
#if HAVE_JPEG
/* JPEG
A JFIF-standard file will start with the four bytes (hex) FF D8 FF E0,
followed by two variable bytes (often hex 00 10), followed by 'JFIF'.
@ -139,6 +148,8 @@ namespace GD
case 0xFF: // JPEG
rtn = CreateFromJpeg(in);
break;
#endif
/* WBMP
WBMP Type 0: B/W, Uncompressed bitmap is the only gd supported type
*/
@ -181,6 +192,8 @@ namespace GD
bool rtn;
switch (((unsigned char * )data)[0])
{
#if HAVE_PNG
/* PNG
The first eight bytes of a PNG file always contain the following (decimal) values:
0x89 0x50 0x4E 0x47 0x0D 0x0A 0x1A 0x0A
@ -189,12 +202,15 @@ namespace GD
case 0x89: // PNG
rtn = CreateFromPng(size, data);
break;
#endif
/* GIF
0x47 0x49 0x46
*/
case 0x47: // GIF
rtn = CreateFromGif(size, data);
break;
#if HAVE_JPEG
/* JPEG
A JFIF-standard file will start with the four bytes (hex) FF D8 FF E0,
followed by two variable bytes (often hex 00 10), followed by 'JFIF'.
@ -202,6 +218,8 @@ namespace GD
case 0xFF: // JPEG
rtn = CreateFromJpeg(size, data);
break;
#endif
/* WBMP
WBMP Type 0: B/W, Uncompressed bitmap is the only gd supported type
*/

View File

@ -262,7 +262,7 @@ namespace GD
*/
Image(int size, void * data)
:im(0) { CreateFrom(size, data); }
#if HAVE_PNG
/** Construct an image by reading from \p in.
The tag is an empty struct which simply tells the compiler which image read function to use.
e.g. GD::Image img(input, GD::Png_tag()); // read a png file from input
@ -292,6 +292,7 @@ namespace GD
*/
Image(int size, void * data, Png_tag)
:im(0) { CreateFromPng(size, data); }
#endif
/** Construct an image by reading from \p in.
The tag is an empty struct which simply tells the compiler which image read function to use.
@ -353,6 +354,7 @@ namespace GD
Image(int size, void * data, WBMP_tag)
:im(0) { CreateFromWBMP(size, data); }
#if HAVE_JPEG
/** Construct an image by reading from \p in.
The tag is an empty struct which simply tells the compiler which image read function to use.
e.g. GD::Image img(input, GD::Jpeg_tag()); // read a jpeg file from input
@ -382,6 +384,7 @@ namespace GD
*/
Image(int size, void * data, Jpeg_tag)
:im(0) { CreateFromJpeg(size, data); }
#endif
/** Construct an image by reading from \p in.
The tag is an empty struct which simply tells the compiler which image read function to use.
@ -525,6 +528,8 @@ namespace GD
bool CreateFrom(std::istream & in);
/// Read an image from a memory block, after determining the image format
bool CreateFrom(int size, void * data);
#if HAVE_PNG
// Png
bool CreateFromPng(FILE * in)
{
@ -547,6 +552,8 @@ namespace GD
istreamIOCtx _in_ctx(in);
return ((im = gdImageCreateFromPngCtx( & _in_ctx)) != 0);
}
#endif
// Gif
bool CreateFromGif(FILE * in)
{
@ -591,6 +598,8 @@ namespace GD
istreamIOCtx _in_ctx(in);
return ((im = gdImageCreateFromWBMPCtx( & _in_ctx)) != 0);
}
#if HAVE_JPEG
// Jpeg
/**
Load a truecolor image from a JPEG format file.
@ -648,6 +657,8 @@ namespace GD
istreamIOCtx _in_ctx(in);
return ((im = gdImageCreateFromJpegCtx( & _in_ctx)) != 0);
}
#endif
// Gd
bool CreateFromGd(FILE * in)
{
@ -948,7 +959,8 @@ namespace GD
ostreamIOCtx _out_ctx(out);
gdImageGifCtx(im, & _out_ctx);
}
#if HAVE_PNG
/**
Write out this image in PNG file format to \p out.
\param out A FILE * handle
@ -1009,6 +1021,7 @@ namespace GD
ostreamIOCtx _out_ctx(out);
gdImagePngCtxEx(im, & _out_ctx, level);
}
#endif
/**
Write out this image in WBMP file format ( black and white only ) to \p out.
@ -1042,7 +1055,8 @@ namespace GD
ostreamIOCtx _out_ctx(out);
gdImageWBMPCtx(im, fg, & _out_ctx);
}
#if HAVE_JPEG
/**
Write out this image in JPEG file format to \p out.
\param out A FILE * handle
@ -1075,6 +1089,7 @@ namespace GD
ostreamIOCtx _out_ctx(out);
gdImageJpegCtx(im, & _out_ctx, quality);
}
#endif
void GifAnimBegin(FILE * out, int GlobalCM, int Loops) const
{ gdImageGifAnimBegin(im, out, GlobalCM, Loops); }