cvs: gd /libgd/examples CMakeLists.txt tiffread.c

[email protected] ("Pierre-Alain Joye") Thu, 04 Oct 2007 19:47:41 -0000
Newsgroups php.gd.cvs
Message-ID <cvspajoye1191527261@cvsserver>
pajoye		Thu Oct  4 19:47:41 2007 UTC

  Added files:                 
    /gd/libgd/examples	CMakeLists.txt tiffread.c 
  Log:
  - add examples directory
  - add tiff usage example
  
  

http://cvs.php.net/viewvc.cgi/gd/libgd/examples/CMakeLists.txt?view=markup&rev=1.1
Index: gd/libgd/examples/CMakeLists.txt
+++ gd/libgd/examples/CMakeLists.txt

message("inc: ${GD_INCLUDE_DIR}")
include_directories (BEFORE ${GD_SOURCE_DIR}/src "${CMAKE_BINARY_DIR}")


SET(TESTS_FILES
  tiffread	
)

FOREACH(test_name ${TESTS_FILES})
	add_executable(${test_name} "${test_name}.c")
	target_link_libraries (${test_name} ${GD_LIB})
	ADD_TEST(${test_name} ${EXECUTABLE_OUTPUT_PATH}/${test_name})
ENDFOREACH(test_name)

http://cvs.php.net/viewvc.cgi/gd/libgd/examples/tiffread.c?view=markup&rev=1.1
Index: gd/libgd/examples/tiffread.c
+++ gd/libgd/examples/tiffread.c
/* $Id: tiffread.c,v 1.1 2007/10/04 19:47:41 pajoye Exp $ */
#include <gd.h>
#include <stdio.h>
#include <stdlib.h>
int main()
{
 	gdImagePtr im;
	FILE *fp;
	char path[2048];

//	sprintf(path, "/home/pierre/projects/gd/patches/tiff/images/cramps-tile.tif");
	sprintf(path, "/home/pierre/projects/gd/patches/tiff/images/ycbcr-cat.tif");

	printf("opening %s\n", path);
	fp = fopen(path, "rb");
	if (!fp) {
		printf("failed, cannot open file\n");
		return 1;
	}

	im = gdImageCreateFromTiff(fp);
	fclose(fp);
	if (!im) {
		fprintf(stderr, "Can't load TIFF image %s\n", path);
		return 1;
	}

	fp = fopen("fromtiff.png", "wb");
	if (!fp) {
		fprintf(stderr, "Can't save png image fromtiff.png\n");
		gdImageDestroy(im);
		return 1;
	}

	gdImagePng(im, fp);
	fclose(fp);
	gdImageDestroy(im);
}