Beispiel #1
0
int main()
{
	gdImagePtr im;

	im = gdImageCreateFromBmp(NULL);
	if (im != NULL) {
		gdImageDestroy(im);
		return 1;
	}
	gdImageBmp(im, NULL, 0); /* noop safely */
	return 0;
}
bool WriteGDImage(const char * filepath, gdImagePtr gdImg, u8 format, u8 compression)
{
	if(gdImg == 0)
		return false;

	FILE * file = fopen(filepath, "wb");
	if(!file)
		return false;

	switch(format)
	{
		default:
		case IMAGE_PNG:
			gdImagePng(gdImg, file);
			break;
		case IMAGE_JPEG:
			gdImageJpeg(gdImg, file, LIMIT(100-compression, 0, 100));
			break;
		case IMAGE_GIF:
			gdImageGif(gdImg, file);
			break;
		case IMAGE_TIFF:
			gdImageTiff(gdImg, file);
			break;
		case IMAGE_BMP:
			gdImageBmp(gdImg, file, compression > 9 ? 9 : compression);
			break;
		case IMAGE_GD:
			gdImageGd(gdImg, file);
			break;
		case IMAGE_GD2:
			gdImageGd2(gdImg, file, 0, LIMIT(compression+1, 1, 2));
			break;
	}

	fclose(file);

	return true;
}