コード例 #1
0
void GuiImageData::LoadTGA(const u8 *img, int imgSize)
{
    gdImagePtr gdImg = gdImageCreateFromTgaPtr(imgSize, (u8*) img);
    if(gdImg == 0)
        return;

    data = GDImageToRGBA8(&gdImg, &width, &height);
    gdImageDestroy(gdImg);
}
コード例 #2
0
ファイル: fuzz2.c プロジェクト: the-st0rm/libgd
int main(int argc, char **argv)
{
	gdImagePtr ptr;
	char* buffer;
	int size;
	int res;

	if (argc<2)
	{
		printf("Usage: %s <input_file>\n", argv[0]);
		return 0;
	}

	size = read_file(argv[1], &buffer);
	if (size <= 0)
	{
		return 0;
	}

	char ext[6];
	res = read_extenstion(buffer, size, ext);
	if (res < 0)
	{
		//printf("ext: %s\n", ext);
		//printf("extention not correct\n");
		exit(0);
	}

	
	switch (res)
	{
		case 1:
		//open png
			printf("openning png\n");
			ptr = gdImageCreateFromPngPtr(size-5, (void *)buffer);
			break;
		case 2:
		//open gif
			printf("openning gif\n");
			ptr = gdImageCreateFromGifPtr(size-5, (void *)buffer);
			break;
		case 3:
		//open jpg
			printf("openning jpg\n");
			ptr = gdImageCreateFromJpegPtr(size-5, (void *)buffer);
			break;
		case 4:
		//open tga
			printf("openning tga\n");
			ptr = gdImageCreateFromTgaPtr(size-5, (void *)buffer);
			break;
		case 5:
		//open tiff
			printf("openning tiff\n");
			ptr = gdImageCreateFromTiffPtr(size-5, (void *)buffer);
			break;
		// case 6:
		// //open webp
		// 	printf("openning webp\n");
		// 	exit(0);
		// 	//gdImageWebpPtr()
		// 	break;
		default:
			printf("error!\n");
			exit(0);
	}
	printf("ptr: %p\n", ptr);
	//gdImagePtr ptr2;
	int new_size;
	FILE *output;
	output = fopen("/dev/null", "wb");
	gdImageWebp(ptr, output); 
	
	return 0;

	// char * filename = argv[1];
	// printf("opening: %s\n", filename);
	// FILE *in;
	// in = fopen(filename, "r");
	// if (in!=NULL)
	// {
	// 	im = gdImageCreateFromPng(in);
	// 	printf("imageptr: %p\n", im);
	// }
	//printf("Main\n");




	return 0;
}
コード例 #3
0
ファイル: imagelibrary.c プロジェクト: nupfel/friendup
gdImagePtr ImageRead( struct ImageLibrary *im, File *rootDev, const char *path )
{
	gdImagePtr img = NULL;
	FHandler *fh = rootDev->f_FSys;
	File *rfp = (File *)fh->FileOpen( rootDev, path, "rb" );
	if( rfp != NULL )
	{
		BufString *bs = BufStringNew( );
		char buffer[ 20048 ];
		int len = 0;

		while( ( len = fh->FileRead( rfp, buffer, 20048 ) ) > 0 )
		{
			BufStringAddSize( bs, buffer, len );
		}
		
		img = gdImageCreateFromJpegPtr( bs->bs_Size, (void *)bs->bs_Buffer ) ;
		if( img == NULL )
		{
			if( img == NULL )
			{
				img = gdImageCreateFromBmpPtr( bs->bs_Size, (void *)bs->bs_Buffer ) ;
				if( img == NULL )
				{
					img = gdImageCreateFromGifPtr( bs->bs_Size, (void *)bs->bs_Buffer ) ;
					if( img == NULL )
					{
						img = gdImageCreateFromPngPtr( bs->bs_Size, (void *)bs->bs_Buffer ) ;
						if( img == NULL )
						{
							img = gdImageCreateFromTgaPtr( bs->bs_Size, (void *)bs->bs_Buffer ) ;
							if( img == NULL )
							{
								img = gdImageCreateFromTiffPtr( bs->bs_Size, (void *)bs->bs_Buffer ) ;
								if( img == NULL )
								{
									img = gdImageCreateFromWBMPPtr( bs->bs_Size, (void *)bs->bs_Buffer ) ;
									if( img == NULL )
									{
										img = gdImageCreateFromWebpPtr( bs->bs_Size, (void *)bs->bs_Buffer ) ;
									}
								}
							}
						}
					}
				}
			}
		}
		
		if( img == NULL )
		{
			ERROR("Graphics format not recognized\n");
		}
		
		BufStringDelete( bs );
		
		fh->FileClose( rootDev, rfp );
	}
	else
	{
		ERROR("Cannot open file: %s to read\n", path );
	}
	return img;
}