コード例 #1
0
ファイル: gdgen.c プロジェクト: aosm/graphviz
static gdImagePtr loadshapeimage(char *name)
{
	gdImagePtr	rv = 0;
	char	*shapeimagefile,*suffix;
	FILE	*in = NULL;

	if ((shapeimagefile=safefile(name))) {
#ifndef MSWIN32
		in = fopen (shapeimagefile, "r");
#else
		in = fopen (shapeimagefile, "rb");
#endif
	}
	if (!in) 
		agerr(AGERR, "couldn't open image file %s\n",shapeimagefile);
	else {
		suffix = strrchr(shapeimagefile,'.');
		if (!suffix) suffix = shapeimagefile; else suffix++;
		if (!strcasecmp(suffix,"wbmp")) rv = gdImageCreateFromWBMP(in);
#ifdef WITH_GIF
		else if (!strcasecmp(suffix,"gif")) rv = gdImageCreateFromGif(in);
#endif
#ifdef HAVE_LIBPNG
		else if (!strcasecmp(suffix,"png")) rv = gdImageCreateFromPng(in);
#endif
#ifdef HAVE_LIBJPEG
		else if (!strcasecmp(suffix,"jpeg")||!strcasecmp(suffix,"jpg")) rv = gdImageCreateFromJpeg(in);
#endif
		else if (!strcasecmp(suffix,"xbm")) rv = gdImageCreateFromXbm(in);
		else agerr(AGERR, "image file %s suffix not recognized\n",name);
		fclose(in);
		if (!rv) agerr(AGERR, "image file %s contents were not recognized\n",name);
	}
	return rv;
}
コード例 #2
0
ファイル: fread.c プロジェクト: peter-mount/piweather.center
gdImagePtr imagefilter_readFile( char *n ) {
    if(!n)
        return NULL;
    
    FILE *f = fopen(n,"r");
    if(!f)
        return NULL;
    
    gdImagePtr img = NULL;
    
    if( strendswith(n,".gd"))
        img = gdImageCreateFromGd(f);
    
    if( strendswith(n,".gd2"))
        img = gdImageCreateFromGd2(f);
    
    if( strendswith(n,".gif"))
        img = gdImageCreateFromGif(f);
    
    if( strendswith(n,".jpg"))
        img = gdImageCreateFromJpeg(f);
    
    if( strendswith(n,".png"))
        img = gdImageCreateFromPng(f);
    
    if( strendswith(n,".bmp"))
        img = gdImageCreateFromWBMP(f);
    
    if( strendswith(n,".xbm"))
        img = gdImageCreateFromXbm(f);
    
    fclose(f);
    return img;
}
コード例 #3
0
ファイル: gd.c プロジェクト: suprit/stuff
LISP lgdImageCreateFromXbm(LISP f)
{   LISP result;
    long iflag;
    result = cons(NIL,NIL);
    result->type = tc_gdimage;
    iflag = no_interrupt(1);
    result->storage_as.string.data =
        (char *) gdImageCreateFromXbm(get_c_file(f,NULL));
    no_interrupt(iflag);
    return(result);
}
コード例 #4
0
ファイル: x10_basic_read.c プロジェクト: cmb69/libgd
int main()
{
	gdImagePtr im;
	FILE *fp;
	char *path;

	fp = gdTestFileOpen2("xbm", "x10_basic_read.xbm");
	im = gdImageCreateFromXbm(fp);
	fclose(fp);
	gdTestAssert(im != NULL);

	path = gdTestFilePath2("xbm", "x10_basic_read_exp.png");
	gdAssertImageEqualsToFile(path, im);
	gdFree(path);

	gdImageDestroy(im);

	return gdNumFailures();
}