Revision 31722
tags/gvsig_redes-1_0_0-1235/libraries/libjni-potrace/.classpath | ||
---|---|---|
1 |
<?xml version="1.0" encoding="UTF-8"?> |
|
2 |
<classpath> |
|
3 |
<classpathentry kind="src" path="src/main/java"/> |
|
4 |
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> |
|
5 |
<classpathentry kind="output" path="bin"/> |
|
6 |
</classpath> |
tags/gvsig_redes-1_0_0-1235/libraries/libjni-potrace/.project | ||
---|---|---|
1 |
<?xml version="1.0" encoding="UTF-8"?> |
|
2 |
<projectDescription> |
|
3 |
<name>libjni-potrace</name> |
|
4 |
<comment></comment> |
|
5 |
<projects> |
|
6 |
</projects> |
|
7 |
<buildSpec> |
|
8 |
<buildCommand> |
|
9 |
<name>org.eclipse.jdt.core.javabuilder</name> |
|
10 |
<arguments> |
|
11 |
</arguments> |
|
12 |
</buildCommand> |
|
13 |
</buildSpec> |
|
14 |
<natures> |
|
15 |
<nature>org.eclipse.jdt.core.javanature</nature> |
|
16 |
</natures> |
|
17 |
</projectDescription> |
tags/gvsig_redes-1_0_0-1235/libraries/libjni-potrace/src/main/native/jpotrace/CMakeLists.txt | ||
---|---|---|
1 |
set(LIB_NAME jpotrace) |
|
2 |
|
|
3 |
FILE(GLOB LIB_PUBLIC_HEADERS "${HEADER_PATH}/*.h") |
|
4 |
FILE(GLOB LIB_COMMON_FILES "*.c*") |
|
5 |
|
|
6 |
include_directories( |
|
7 |
${CMAKE_SOURCE_DIR}/include |
|
8 |
${JAVA_INCLUDE_PATH} |
|
9 |
${JAVA_INCLUDE_PATH2} |
|
10 |
${POTRACE_INCLUDE_DIR} |
|
11 |
) |
|
12 |
|
|
13 |
add_library(${LIB_NAME} SHARED |
|
14 |
${LIB_PUBLIC_HEADERS} |
|
15 |
${LIB_COMMON_FILES} |
|
16 |
) |
|
17 |
|
|
18 |
target_link_libraries(${LIB_NAME} |
|
19 |
${POTRACE_LIBRARY} |
|
20 |
) |
|
21 |
|
|
22 |
if(APPLE) |
|
23 |
SET_TARGET_PROPERTIES(${LIB_NAME} |
|
24 |
PROPERTIES |
|
25 |
SUFFIX .jnilib) |
|
26 |
endif(APPLE) |
|
27 |
|
|
28 |
INCLUDE(ModuleInstall OPTIONAL) |
|
29 |
|
|
30 |
SET_TARGET_PROPERTIES(jpotrace PROPERTIES VERSION "${JPOTRACE_VERSION}") |
|
31 |
IF(WIN32) |
|
32 |
SET_TARGET_PROPERTIES(jpotrace PROPERTIES OUTPUT_NAME "jpotrace${JPOTRACE_VERSION}") |
|
33 |
ENDIF(WIN32) |
|
34 |
IF(UNIX) |
|
35 |
SET_TARGET_PROPERTIES(jpotrace PROPERTIES OUTPUT_NAME "jpotrace${VERSION}") |
|
36 |
ENDIF(UNIX) |
|
37 |
|
|
38 |
IF(UNIX AND NOT APPLE) |
|
39 |
SET_TARGET_PROPERTIES ( ${LIB_NAME} PROPERTIES LINK_FLAGS "-Wl,-E") |
|
40 |
ENDIF(UNIX AND NOT APPLE) |
|
41 |
|
tags/gvsig_redes-1_0_0-1235/libraries/libjni-potrace/src/main/native/jpotrace/potrace.c | ||
---|---|---|
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
2 |
* |
|
3 |
* Copyright (C) 2005 IVER T.I. and Generalitat Valenciana. |
|
4 |
* |
|
5 |
* This program is free software; you can redistribute it and/or |
|
6 |
* modify it under the terms of the GNU General Public License |
|
7 |
* as published by the Free Software Foundation; either version 2 |
|
8 |
* of the License, or (at your option) any later version. |
|
9 |
* |
|
10 |
* This program is distributed in the hope that it will be useful, |
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 |
* GNU General Public License for more details. |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License |
|
16 |
* along with this program; if not, write to the Free Software |
|
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
18 |
*/ |
|
19 |
#include <jni.h> |
|
20 |
#include <stdio.h> |
|
21 |
#include <stdlib.h> |
|
22 |
#include <string.h> |
|
23 |
#include "potrace_raster.h" |
|
24 |
|
|
25 |
/** |
|
26 |
* Parte de jni para vectorizar un buffer |
|
27 |
*/ |
|
28 |
JNIEXPORT jdoubleArray JNICALL Java_org_gvsig_jpotrace_Potrace_vectorizeBufferRasterNat(JNIEnv *env, jclass clase, jintArray bufferIn, jint width, jint height, jobjectArray array) { |
|
29 |
int i; |
|
30 |
jint *cbufferIn; |
|
31 |
double *values; |
|
32 |
jsize size; |
|
33 |
jdoubleArray jvalues; |
|
34 |
jint length; |
|
35 |
char **list; |
|
36 |
|
|
37 |
cbufferIn = (*env)->GetIntArrayElements(env, bufferIn, NULL); |
|
38 |
|
|
39 |
length = (*env)->GetArrayLength(env, array); |
|
40 |
list = malloc(length * sizeof(char *)); |
|
41 |
for (i = 0; i < length; i++) { |
|
42 |
jobject string = (*env)->GetObjectArrayElement(env, array, i); |
|
43 |
list[i] = (char *) (*env)->GetStringUTFChars(env, string, NULL); |
|
44 |
} |
|
45 |
|
|
46 |
values = vectorizarBuffer((long *) cbufferIn, width, height, length, list); |
|
47 |
size = (jsize) values[0]; |
|
48 |
jvalues = (*env)->NewDoubleArray(env, size); |
|
49 |
(*env)->SetDoubleArrayRegion(env, jvalues, 0, size, values); |
|
50 |
|
|
51 |
free(values); |
|
52 |
|
|
53 |
for (i = 0; i < length; i++) { |
|
54 |
jobject string = (*env)->GetObjectArrayElement(env, array, i); |
|
55 |
(*env)->ReleaseStringUTFChars(env, string, list[i]); |
|
56 |
} |
|
57 |
free (list); |
|
58 |
|
|
59 |
return jvalues; |
|
60 |
} |
tags/gvsig_redes-1_0_0-1235/libraries/libjni-potrace/src/main/java/org/gvsig/jpotrace/JNIBase.java | ||
---|---|---|
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
2 |
* |
|
3 |
* Copyright (C) 2005 IVER T.I. and Generalitat Valenciana. |
|
4 |
* |
|
5 |
* This program is free software; you can redistribute it and/or |
|
6 |
* modify it under the terms of the GNU General Public License |
|
7 |
* as published by the Free Software Foundation; either version 2 |
|
8 |
* of the License, or (at your option) any later version. |
|
9 |
* |
|
10 |
* This program is distributed in the hope that it will be useful, |
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 |
* GNU General Public License for more details. |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License |
|
16 |
* along with this program; if not, write to the Free Software |
|
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
18 |
*/ |
|
19 |
package org.gvsig.jpotrace; |
|
20 |
/** |
|
21 |
* La clase <code>JNIBase</code> sirve para cargar la libreria de jpotrace |
|
22 |
* |
|
23 |
* @version 31/07/2008 |
|
24 |
* @author BorSanZa - Borja S?nchez Zamorano (borja.sanchez@iver.es) |
|
25 |
*/ |
|
26 |
public class JNIBase { |
|
27 |
static { |
|
28 |
String os = System.getProperty("os.name"); |
|
29 |
if (os.toLowerCase().startsWith("windows")) |
|
30 |
System.loadLibrary("jpotrace001"); |
|
31 |
else |
|
32 |
System.loadLibrary("jpotrace"); |
|
33 |
} |
|
34 |
} |
tags/gvsig_redes-1_0_0-1235/libraries/libjni-potrace/src/main/java/org/gvsig/jpotrace/PotraceException.java | ||
---|---|---|
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
2 |
* |
|
3 |
* Copyright (C) 2005 IVER T.I. and Generalitat Valenciana. |
|
4 |
* |
|
5 |
* This program is free software; you can redistribute it and/or |
|
6 |
* modify it under the terms of the GNU General Public License |
|
7 |
* as published by the Free Software Foundation; either version 2 |
|
8 |
* of the License, or (at your option) any later version. |
|
9 |
* |
|
10 |
* This program is distributed in the hope that it will be useful, |
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 |
* GNU General Public License for more details. |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License |
|
16 |
* along with this program; if not, write to the Free Software |
|
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
18 |
*/ |
|
19 |
package org.gvsig.jpotrace; |
|
20 |
/** |
|
21 |
* La clase <code>PotraceException</code> es una forma de expresar que un |
|
22 |
* parametro ha sido mal usado en la libreria de jpotrace |
|
23 |
|
|
24 |
* @version 31/07/2008 |
|
25 |
* @author BorSanZa - Borja S?nchez Zamorano (borja.sanchez@iver.es) |
|
26 |
*/ |
|
27 |
public class PotraceException extends Exception { |
|
28 |
private static final long serialVersionUID = -5761750440639572006L; |
|
29 |
|
|
30 |
public PotraceException(String msg) { |
|
31 |
super(msg); |
|
32 |
} |
|
33 |
} |
tags/gvsig_redes-1_0_0-1235/libraries/libjni-potrace/src/main/java/org/gvsig/jpotrace/Potrace.java | ||
---|---|---|
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
2 |
* |
|
3 |
* Copyright (C) 2005 IVER T.I. and Generalitat Valenciana. |
|
4 |
* |
|
5 |
* This program is free software; you can redistribute it and/or |
|
6 |
* modify it under the terms of the GNU General Public License |
|
7 |
* as published by the Free Software Foundation; either version 2 |
|
8 |
* of the License, or (at your option) any later version. |
|
9 |
* |
|
10 |
* This program is distributed in the hope that it will be useful, |
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 |
* GNU General Public License for more details. |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License |
|
16 |
* along with this program; if not, write to the Free Software |
|
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
18 |
*/ |
|
19 |
package org.gvsig.jpotrace; |
|
20 |
/** |
|
21 |
* La clase <code>Potrace</code> contiene los metodos que comunican la libreria |
|
22 |
* nativa con Java |
|
23 |
* |
|
24 |
* @version 31/07/2008 |
|
25 |
* @author BorSanZa - Borja S?nchez Zamorano (borja.sanchez@iver.es) |
|
26 |
*/ |
|
27 |
public class Potrace extends JNIBase { |
|
28 |
private static native double[] vectorizeBufferRasterNat(int[] bufferIn, int width, int height, String[] params); |
|
29 |
|
|
30 |
/** |
|
31 |
* Vectoriza un buffer pasado por parametro y es devuelto en forma de array |
|
32 |
* de doubles. Hay que especificar el ancho y alto del buffer y el buffer ha |
|
33 |
* de ser pasado en el formato que soporta potrace, que es en forma de bits. |
|
34 |
* |
|
35 |
* El parametro params es un array de Strings como se usaria en el tipico |
|
36 |
* main(char[]) para expresar los parametros de potrace, es una forma de poder |
|
37 |
* aprovechar todos los parametros del comando potrace desde Java. Algunos |
|
38 |
* no funcionan, como especificar el fichero origen o destino |
|
39 |
* |
|
40 |
* @param bufferIn |
|
41 |
* @param width |
|
42 |
* @param height |
|
43 |
* @param params |
|
44 |
* @return |
|
45 |
* @throws PotraceException |
|
46 |
*/ |
|
47 |
public static double[] vectorizeBufferRaster(int[] bufferIn, int width, int height, String[] params) throws PotraceException { |
|
48 |
if (bufferIn == null) |
|
49 |
throw new PotraceException("El parametro Buffer no puede estar vacio"); |
|
50 |
|
|
51 |
if (width <= 0) |
|
52 |
throw new PotraceException("El ancho del buffer ha de ser mayor a 0"); |
|
53 |
|
|
54 |
if (height <= 0) |
|
55 |
throw new PotraceException("El alto del buffer ha de ser mayor a 0"); |
|
56 |
|
|
57 |
return vectorizeBufferRasterNat(bufferIn, width, height, params); |
|
58 |
} |
|
59 |
} |
tags/gvsig_redes-1_0_0-1235/libraries/libjni-potrace/CMakeModules/ModuleInstall.cmake | ||
---|---|---|
1 |
# INSTALL and SOURCE_GROUP commands for OSG/OT/Producer Modules |
|
2 |
|
|
3 |
# Required Vars: |
|
4 |
# ${LIB_NAME} |
|
5 |
# ${LIB_PUBLIC_HEADERS} |
|
6 |
|
|
7 |
SET(INSTALL_INCDIR include) |
|
8 |
SET(INSTALL_BINDIR bin) |
|
9 |
IF(WIN32) |
|
10 |
SET(INSTALL_BINDIR .) |
|
11 |
SET(INSTALL_LIBDIR .) |
|
12 |
SET(INSTALL_ARCHIVEDIR lib) |
|
13 |
ELSE(WIN32) |
|
14 |
SET(INSTALL_BINDIR .) |
|
15 |
SET(INSTALL_LIBDIR .) |
|
16 |
SET(INSTALL_ARCHIVEDIR lib) |
|
17 |
ENDIF(WIN32) |
|
18 |
|
|
19 |
SET(HEADERS_GROUP "Header Files") |
|
20 |
|
|
21 |
SOURCE_GROUP( |
|
22 |
${HEADERS_GROUP} |
|
23 |
FILES ${LIB_PUBLIC_HEADERS} |
|
24 |
) |
|
25 |
|
|
26 |
|
|
27 |
INSTALL( |
|
28 |
TARGETS ${LIB_NAME} |
|
29 |
RUNTIME DESTINATION ${INSTALL_BINDIR} |
|
30 |
LIBRARY DESTINATION ${INSTALL_LIBDIR} |
|
31 |
ARCHIVE DESTINATION ${INSTALL_ARCHIVEDIR} |
|
32 |
) |
|
33 |
|
|
34 |
|
|
35 |
|
|
36 |
# FIXME: Do not run for OS X framework |
|
37 |
#INSTALL( |
|
38 |
# FILES ${LIB_PUBLIC_HEADERS} |
|
39 |
# DESTINATION ${INSTALL_INCDIR}/${LIB_NAME} |
|
40 |
#) |
tags/gvsig_redes-1_0_0-1235/libraries/libjni-potrace/CMakeModules/FindPOTRACE.cmake | ||
---|---|---|
1 |
# Locate potrace |
|
2 |
# This module defines |
|
3 |
# POTRACE_LIBRARY |
|
4 |
# POTRACE_FOUND, if false, do not try to link to potrace |
|
5 |
# POTRACE_INCLUDE_DIR, where to find the headers |
|
6 |
# |
|
7 |
# $POTRACE_DIR is an environment variable that would |
|
8 |
# correspond to the ./configure --prefix=$POTRACE_DIR |
|
9 |
# |
|
10 |
# Created by Borja Sanchez Zamorano |
|
11 |
|
|
12 |
FIND_PATH(POTRACE_INCLUDE_DIR potracelib.h |
|
13 |
C:/workspace/workspace-HEADRASTER/potrace-1.8/src |
|
14 |
/home/borsanza/nacho/WRaster/potrace/src |
|
15 |
) |
|
16 |
|
|
17 |
FIND_LIBRARY(POTRACE_LIBRARY |
|
18 |
NAMES libpotrace180 potrace POTRACE |
|
19 |
PATHS |
|
20 |
C:/workspace/workspace-HEADRASTER/binaries/w32 |
|
21 |
/home/borsanza/nacho/WRaster/binaries/linux |
|
22 |
) |
|
23 |
|
|
24 |
SET(POTRACE_FOUND "NO") |
|
25 |
IF(POTRACE_LIBRARY AND POTRACE_INCLUDE_DIR) |
|
26 |
SET(POTRACE_FOUND "YES") |
|
27 |
ENDIF(POTRACE_LIBRARY AND POTRACE_INCLUDE_DIR) |
|
28 |
|
|
29 |
IF(POTRACE_LIBRARY) |
|
30 |
MESSAGE(STATUS "POTRACE_LIBRARY: " ${POTRACE_LIBRARY}) |
|
31 |
ELSE(POTRACE_LIBRARY) |
|
32 |
MESSAGE(STATUS "POTRACE_LIBRARY: NOT FOUND") |
|
33 |
ENDIF(POTRACE_LIBRARY) |
|
34 |
|
|
35 |
IF(POTRACE_INCLUDE_DIR) |
|
36 |
MESSAGE(STATUS "POTRACE_INCLUDE_DIR: " ${POTRACE_INCLUDE_DIR}) |
|
37 |
ELSE(POTRACE_INCLUDE_DIR) |
|
38 |
MESSAGE(STATUS "POTRACE_INCLUDE_DIR: NOT FOUND") |
|
39 |
ENDIF(POTRACE_INCLUDE_DIR) |
tags/gvsig_redes-1_0_0-1235/libraries/libjni-potrace/resources/potrace-1.8/.project | ||
---|---|---|
1 |
<?xml version="1.0" encoding="UTF-8"?> |
|
2 |
<projectDescription> |
|
3 |
<name>potrace-Release@potrace-1.8</name> |
|
4 |
<comment></comment> |
|
5 |
<projects> |
|
6 |
</projects> |
|
7 |
<buildSpec> |
|
8 |
<buildCommand> |
|
9 |
<name>org.eclipse.cdt.make.core.makeBuilder</name> |
|
10 |
<triggers>clean,full,incremental,</triggers> |
|
11 |
<arguments> |
|
12 |
<dictionary> |
|
13 |
<key>org.eclipse.cdt.make.core.cleanBuildTarget</key> |
|
14 |
<value>clean</value> |
|
15 |
</dictionary> |
|
16 |
<dictionary> |
|
17 |
<key>org.eclipse.cdt.make.core.enableCleanBuild</key> |
|
18 |
<value>true</value> |
|
19 |
</dictionary> |
|
20 |
<dictionary> |
|
21 |
<key>org.eclipse.cdt.make.core.append_environment</key> |
|
22 |
<value>true</value> |
|
23 |
</dictionary> |
|
24 |
<dictionary> |
|
25 |
<key>org.eclipse.cdt.make.core.stopOnError</key> |
|
26 |
<value>true</value> |
|
27 |
</dictionary> |
|
28 |
<dictionary> |
|
29 |
<key>org.eclipse.cdt.make.core.enabledIncrementalBuild</key> |
|
30 |
<value>true</value> |
|
31 |
</dictionary> |
|
32 |
<dictionary> |
|
33 |
<key>org.eclipse.cdt.make.core.build.command</key> |
|
34 |
<value>C:/MinGW/bin/mingw32-make.exe</value> |
|
35 |
</dictionary> |
|
36 |
<dictionary> |
|
37 |
<key>org.eclipse.cdt.make.core.contents</key> |
|
38 |
<value>org.eclipse.cdt.make.core.activeConfigSettings</value> |
|
39 |
</dictionary> |
|
40 |
<dictionary> |
|
41 |
<key>org.eclipse.cdt.make.core.build.target.inc</key> |
|
42 |
<value>all</value> |
|
43 |
</dictionary> |
|
44 |
<dictionary> |
|
45 |
<key>org.eclipse.cdt.make.core.build.arguments</key> |
|
46 |
<value></value> |
|
47 |
</dictionary> |
|
48 |
<dictionary> |
|
49 |
<key>org.eclipse.cdt.make.core.buildLocation</key> |
|
50 |
<value>C:/workspace/workspace-HEADRASTER/potrace-1.8</value> |
|
51 |
</dictionary> |
|
52 |
<dictionary> |
|
53 |
<key>org.eclipse.cdt.make.core.useDefaultBuildCmd</key> |
|
54 |
<value>false</value> |
|
55 |
</dictionary> |
|
56 |
<dictionary> |
|
57 |
<key>org.eclipse.cdt.make.core.environment</key> |
|
58 |
<value></value> |
|
59 |
</dictionary> |
|
60 |
<dictionary> |
|
61 |
<key>org.eclipse.cdt.make.core.enableFullBuild</key> |
|
62 |
<value>true</value> |
|
63 |
</dictionary> |
|
64 |
<dictionary> |
|
65 |
<key>org.eclipse.cdt.make.core.build.target.auto</key> |
|
66 |
<value>all</value> |
|
67 |
</dictionary> |
|
68 |
<dictionary> |
|
69 |
<key>org.eclipse.cdt.make.core.enableAutoBuild</key> |
|
70 |
<value>false</value> |
|
71 |
</dictionary> |
|
72 |
<dictionary> |
|
73 |
<key>org.eclipse.cdt.make.core.build.target.clean</key> |
|
74 |
<value>clean</value> |
|
75 |
</dictionary> |
|
76 |
<dictionary> |
|
77 |
<key>org.eclipse.cdt.make.core.fullBuildTarget</key> |
|
78 |
<value>all</value> |
|
79 |
</dictionary> |
|
80 |
<dictionary> |
|
81 |
<key>org.eclipse.cdt.make.core.buildArguments</key> |
|
82 |
<value></value> |
|
83 |
</dictionary> |
|
84 |
<dictionary> |
|
85 |
<key>org.eclipse.cdt.make.core.build.location</key> |
|
86 |
<value>C:/workspace/workspace-HEADRASTER/potrace-1.8</value> |
|
87 |
</dictionary> |
|
88 |
<dictionary> |
|
89 |
<key>org.eclipse.cdt.make.core.autoBuildTarget</key> |
|
90 |
<value>all</value> |
|
91 |
</dictionary> |
|
92 |
<dictionary> |
|
93 |
<key>org.eclipse.cdt.core.errorOutputParser</key> |
|
94 |
<value>org.eclipse.cdt.core.MakeErrorParser;org.eclipse.cdt.core.GCCErrorParser;org.eclipse.cdt.core.GASErrorParser;org.eclipse.cdt.core.GLDErrorParser;</value> |
|
95 |
</dictionary> |
|
96 |
</arguments> |
|
97 |
</buildCommand> |
|
98 |
<buildCommand> |
|
99 |
<name>org.eclipse.cdt.make.core.ScannerConfigBuilder</name> |
|
100 |
<arguments> |
|
101 |
</arguments> |
|
102 |
</buildCommand> |
|
103 |
</buildSpec> |
|
104 |
<natures> |
|
105 |
<nature>org.eclipse.cdt.core.ccnature</nature> |
|
106 |
<nature>org.eclipse.cdt.make.core.makeNature</nature> |
|
107 |
<nature>org.eclipse.cdt.make.core.ScannerConfigNature</nature> |
|
108 |
<nature>org.eclipse.cdt.core.cnature</nature> |
|
109 |
</natures> |
|
110 |
</projectDescription> |
tags/gvsig_redes-1_0_0-1235/libraries/libjni-potrace/resources/potrace-1.8/.cproject | ||
---|---|---|
1 |
<?xml version="1.0" encoding="UTF-8"?> |
|
2 |
<?fileVersion 4.0.0?> |
|
3 |
|
|
4 |
<cproject> |
|
5 |
<storageModule moduleId="org.eclipse.cdt.core.settings"> |
|
6 |
<cconfiguration id="org.eclipse.cdt.core.default.config.1"> |
|
7 |
<storageModule buildSystemId="org.eclipse.cdt.core.defaultConfigDataProvider" id="org.eclipse.cdt.core.default.config.1" moduleId="org.eclipse.cdt.core.settings" name="Configuration"> |
|
8 |
<externalSettings/> |
|
9 |
<extensions> |
|
10 |
<extension id="org.eclipse.cdt.core.PE" point="org.eclipse.cdt.core.BinaryParser"/> |
|
11 |
</extensions> |
|
12 |
</storageModule> |
|
13 |
<storageModule moduleId="org.eclipse.cdt.core.language.mapping"> |
|
14 |
<project-mappings/> |
|
15 |
</storageModule> |
|
16 |
<storageModule moduleId="org.eclipse.cdt.core.externalSettings"/> |
|
17 |
<storageModule moduleId="org.eclipse.cdt.core.pathentry"> |
|
18 |
<pathentry excluding="**/CMakeFiles/" kind="out" path=""/> |
|
19 |
</storageModule> |
|
20 |
<storageModule moduleId="org.eclipse.cdt.make.core.buildtargets"> |
|
21 |
<buildTargets> |
|
22 |
<target name="all" path="" targetID="org.eclipse.cdt.make.MakeTargetBuilder"> |
|
23 |
<buildCommand>C:/MinGW/bin/mingw32-make.exe</buildCommand> |
|
24 |
<buildArguments/> |
|
25 |
<buildTarget>all</buildTarget> |
|
26 |
<stopOnError>true</stopOnError> |
|
27 |
<useDefaultCommand>false</useDefaultCommand> |
|
28 |
</target> |
|
29 |
<target name="preinstall" path="" targetID="org.eclipse.cdt.make.MakeTargetBuilder"> |
|
30 |
<buildCommand>C:/MinGW/bin/mingw32-make.exe</buildCommand> |
|
31 |
<buildArguments/> |
|
32 |
<buildTarget>preinstall</buildTarget> |
|
33 |
<stopOnError>true</stopOnError> |
|
34 |
<useDefaultCommand>false</useDefaultCommand> |
|
35 |
</target> |
|
36 |
<target name="clean" path="" targetID="org.eclipse.cdt.make.MakeTargetBuilder"> |
|
37 |
<buildCommand>C:/MinGW/bin/mingw32-make.exe</buildCommand> |
|
38 |
<buildArguments/> |
|
39 |
<buildTarget>clean</buildTarget> |
|
40 |
<stopOnError>true</stopOnError> |
|
41 |
<useDefaultCommand>false</useDefaultCommand> |
|
42 |
</target> |
|
43 |
<target name="edit_cache" path="" targetID="org.eclipse.cdt.make.MakeTargetBuilder"> |
|
44 |
<buildCommand>C:/MinGW/bin/mingw32-make.exe</buildCommand> |
|
45 |
<buildArguments/> |
|
46 |
<buildTarget>edit_cache</buildTarget> |
|
47 |
<stopOnError>true</stopOnError> |
|
48 |
<useDefaultCommand>false</useDefaultCommand> |
|
49 |
</target> |
|
50 |
<target name="install" path="" targetID="org.eclipse.cdt.make.MakeTargetBuilder"> |
|
51 |
<buildCommand>C:/MinGW/bin/mingw32-make.exe</buildCommand> |
|
52 |
<buildArguments/> |
|
53 |
<buildTarget>install</buildTarget> |
|
54 |
<stopOnError>true</stopOnError> |
|
55 |
<useDefaultCommand>false</useDefaultCommand> |
|
56 |
</target> |
|
57 |
<target name="install/strip" path="" targetID="org.eclipse.cdt.make.MakeTargetBuilder"> |
|
58 |
<buildCommand>C:/MinGW/bin/mingw32-make.exe</buildCommand> |
|
59 |
<buildArguments/> |
|
60 |
<buildTarget>install/strip</buildTarget> |
|
61 |
<stopOnError>true</stopOnError> |
|
62 |
<useDefaultCommand>false</useDefaultCommand> |
|
63 |
</target> |
|
64 |
<target name="rebuild_cache" path="" targetID="org.eclipse.cdt.make.MakeTargetBuilder"> |
|
65 |
<buildCommand>C:/MinGW/bin/mingw32-make.exe</buildCommand> |
|
66 |
<buildArguments/> |
|
67 |
<buildTarget>rebuild_cache</buildTarget> |
|
68 |
<stopOnError>true</stopOnError> |
|
69 |
<useDefaultCommand>false</useDefaultCommand> |
|
70 |
</target> |
|
71 |
<target name="potrace" path="" targetID="org.eclipse.cdt.make.MakeTargetBuilder"> |
|
72 |
<buildCommand>C:/MinGW/bin/mingw32-make.exe</buildCommand> |
|
73 |
<buildArguments/> |
|
74 |
<buildTarget>potrace</buildTarget> |
|
75 |
<stopOnError>true</stopOnError> |
|
76 |
<useDefaultCommand>false</useDefaultCommand> |
|
77 |
</target> |
|
78 |
<target name="potrace180" path="" targetID="org.eclipse.cdt.make.MakeTargetBuilder"> |
|
79 |
<buildCommand>C:/MinGW/bin/mingw32-make.exe</buildCommand> |
|
80 |
<buildArguments/> |
|
81 |
<buildTarget>potrace180</buildTarget> |
|
82 |
<stopOnError>true</stopOnError> |
|
83 |
<useDefaultCommand>false</useDefaultCommand> |
|
84 |
</target> |
|
85 |
</buildTargets> |
|
86 |
</storageModule> |
|
87 |
<storageModule moduleId="scannerConfiguration"> |
|
88 |
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.make.core.GCCStandardMakePerProjectProfile"/> |
|
89 |
<profile id="org.eclipse.cdt.make.core.GCCStandardMakePerProjectProfile"> |
|
90 |
<buildOutputProvider> |
|
91 |
<openAction enabled="true" filePath=""/> |
|
92 |
<parser enabled="true"/> |
|
93 |
</buildOutputProvider> |
|
94 |
<scannerInfoProvider id="specsFile"> |
|
95 |
<runAction arguments="-E -P -v -dD ${plugin_state_location}/${specs_file}" command="gcc" useDefault="true"/> |
|
96 |
<parser enabled="true"/> |
|
97 |
</scannerInfoProvider> |
|
98 |
</profile> |
|
99 |
<profile id="org.eclipse.cdt.make.core.GCCStandardMakePerFileProfile"> |
|
100 |
<buildOutputProvider> |
|
101 |
<openAction enabled="true" filePath=""/> |
|
102 |
<parser enabled="true"/> |
|
103 |
</buildOutputProvider> |
|
104 |
<scannerInfoProvider id="makefileGenerator"> |
|
105 |
<runAction arguments="-f ${project_name}_scd.mk" command="make" useDefault="true"/> |
|
106 |
<parser enabled="true"/> |
|
107 |
</scannerInfoProvider> |
|
108 |
</profile> |
|
109 |
</storageModule> |
|
110 |
</cconfiguration> |
|
111 |
</storageModule> |
|
112 |
<storageModule moduleId="cdtBuildSystem" version="4.0.0"> |
|
113 |
<project id="potrace.null.1" name="potrace"/> |
|
114 |
</storageModule> |
|
115 |
</cproject> |
tags/gvsig_redes-1_0_0-1235/libraries/libjni-potrace/resources/potrace-1.8/src/backend_pdf.c | ||
---|---|---|
1 |
/* Copyright (C) 2001-2007 Peter Selinger. |
|
2 |
This file is part of Potrace. It is free software and it is covered |
|
3 |
by the GNU General Public License. See the file COPYING for details. */ |
|
4 |
|
|
5 |
/* $Id: backend_pdf.c 147 2007-04-09 00:44:09Z selinger $ */ |
|
6 |
|
|
7 |
/* The PDF backend of Potrace. Stream compression is optionally |
|
8 |
supplied via the functions in flate.c. */ |
|
9 |
|
|
10 |
#include <stdio.h> |
|
11 |
#include <stdarg.h> |
|
12 |
#include <string.h> |
|
13 |
#include <math.h> |
|
14 |
#include <stdlib.h> |
|
15 |
|
|
16 |
#include "main.h" |
|
17 |
#include "backend_pdf.h" |
|
18 |
#include "flate.h" |
|
19 |
#include "lists.h" |
|
20 |
#include "potracelib.h" |
|
21 |
#include "auxiliary.h" |
|
22 |
|
|
23 |
#ifdef HAVE_CONFIG_H |
|
24 |
#include "config.h" |
|
25 |
#endif |
|
26 |
|
|
27 |
typedef int color_t; |
|
28 |
|
|
29 |
#define black 0x000000 |
|
30 |
#define red 0xff0000 |
|
31 |
#define green 0x008000 |
|
32 |
#define blue 0x0000ff |
|
33 |
|
|
34 |
/* ---------------------------------------------------------------------- */ |
|
35 |
/* auxiliary: growing arrays */ |
|
36 |
|
|
37 |
struct intarray_s { |
|
38 |
int size; |
|
39 |
int *data; |
|
40 |
}; |
|
41 |
typedef struct intarray_s intarray_t; |
|
42 |
|
|
43 |
static inline void intarray_init(intarray_t *ar) { |
|
44 |
ar->size = 0; |
|
45 |
ar->data = NULL; |
|
46 |
} |
|
47 |
|
|
48 |
static inline void intarray_term(intarray_t *ar) { |
|
49 |
free(ar->data); |
|
50 |
ar->size = 0; |
|
51 |
ar->data = NULL; |
|
52 |
} |
|
53 |
|
|
54 |
/* Set ar[n]=val. Expects n>=0. Grows array if necessary. Return 0 on |
|
55 |
success and -1 on error with errno set. */ |
|
56 |
static inline int intarray_set(intarray_t *ar, int n, int val) { |
|
57 |
int *p; |
|
58 |
int s; |
|
59 |
|
|
60 |
if (n >= ar->size) { |
|
61 |
s = n+1024; |
|
62 |
p = (int *)realloc(ar->data, s * sizeof(int)); |
|
63 |
if (!p) { |
|
64 |
return -1; |
|
65 |
} |
|
66 |
ar->data = p; |
|
67 |
ar->size = s; |
|
68 |
} |
|
69 |
ar->data[n] = val; |
|
70 |
return 0; |
|
71 |
} |
|
72 |
|
|
73 |
/* ---------------------------------------------------------------------- */ |
|
74 |
/* some global variables */ |
|
75 |
|
|
76 |
static intarray_t xref; |
|
77 |
static int nxref = 0; |
|
78 |
static intarray_t pages; |
|
79 |
static int npages; |
|
80 |
static int streamofs; |
|
81 |
static size_t outcount; /* output file position */ |
|
82 |
|
|
83 |
/* ---------------------------------------------------------------------- */ |
|
84 |
/* functions for interfacing with compression backend */ |
|
85 |
|
|
86 |
/* xship: callback function that must be initialized before calling |
|
87 |
any other functions of the "ship" family. xship_file must be |
|
88 |
initialized too. */ |
|
89 |
|
|
90 |
/* print the token to f, but filtered through a compression |
|
91 |
filter in case filter!=0 */ |
|
92 |
static int (*xship)(FILE *f, int filter, char *s, int len); |
|
93 |
static FILE *xship_file; |
|
94 |
|
|
95 |
/* ship PDF code, filtered */ |
|
96 |
static int ship(const char *fmt, ...) { |
|
97 |
va_list args; |
|
98 |
static char buf[4096]; /* static string limit is okay here because |
|
99 |
we only use constant format strings - for |
|
100 |
the same reason, it is okay to use |
|
101 |
vsprintf instead of vsnprintf below. */ |
|
102 |
va_start(args, fmt); |
|
103 |
vsprintf(buf, fmt, args); |
|
104 |
buf[4095] = 0; |
|
105 |
va_end(args); |
|
106 |
|
|
107 |
outcount += xship(xship_file, 1, buf, strlen(buf)); |
|
108 |
return 0; |
|
109 |
} |
|
110 |
|
|
111 |
/* ship PDF code, unfiltered */ |
|
112 |
static int shipclear(char *fmt, ...) { |
|
113 |
static char buf[4096]; |
|
114 |
va_list args; |
|
115 |
|
|
116 |
va_start(args, fmt); |
|
117 |
vsprintf(buf, fmt, args); |
|
118 |
buf[4095] = 0; |
|
119 |
va_end(args); |
|
120 |
|
|
121 |
outcount += xship(xship_file, 0, buf, strlen(buf)); |
|
122 |
return 0; |
|
123 |
} |
|
124 |
|
|
125 |
/* set all callback functions */ |
|
126 |
static void pdf_callbacks(FILE *fout) { |
|
127 |
|
|
128 |
if (info.compress) { |
|
129 |
xship = pdf_xship; |
|
130 |
} else { |
|
131 |
xship = dummy_xship; |
|
132 |
} |
|
133 |
xship_file = fout; |
|
134 |
} |
|
135 |
|
|
136 |
/* ---------------------------------------------------------------------- */ |
|
137 |
/* PDF path-drawing auxiliary functions */ |
|
138 |
|
|
139 |
/* coordinate quantization */ |
|
140 |
static inline point_t unit(dpoint_t p) { |
|
141 |
point_t q; |
|
142 |
|
|
143 |
q.x = (long)(floor(p.x*info.unit+.5)); |
|
144 |
q.y = (long)(floor(p.y*info.unit+.5)); |
|
145 |
return q; |
|
146 |
} |
|
147 |
|
|
148 |
static void pdf_coords(dpoint_t p) { |
|
149 |
point_t cur = unit(p); |
|
150 |
ship("%ld %ld ", cur.x, cur.y); |
|
151 |
} |
|
152 |
|
|
153 |
static void pdf_moveto(dpoint_t p) { |
|
154 |
pdf_coords(p); |
|
155 |
ship("m\n"); |
|
156 |
} |
|
157 |
|
|
158 |
static void pdf_lineto(dpoint_t p) { |
|
159 |
pdf_coords(p); |
|
160 |
ship("l\n"); |
|
161 |
} |
|
162 |
|
|
163 |
static void pdf_curveto(dpoint_t p1, dpoint_t p2, dpoint_t p3) { |
|
164 |
point_t q1, q2, q3; |
|
165 |
|
|
166 |
q1 = unit(p1); |
|
167 |
q2 = unit(p2); |
|
168 |
q3 = unit(p3); |
|
169 |
|
|
170 |
ship("%ld %ld %ld %ld %ld %ld c\n", q1.x, q1.y, q2.x, q2.y, q3.x, q3.y); |
|
171 |
} |
|
172 |
|
|
173 |
/* this procedure returns a statically allocated string */ |
|
174 |
static char *pdf_colorstring(const color_t col) { |
|
175 |
double r, g, b; |
|
176 |
static char buf[100]; |
|
177 |
|
|
178 |
r = (col & 0xff0000) >> 16; |
|
179 |
g = (col & 0x00ff00) >> 8; |
|
180 |
b = (col & 0x0000ff) >> 0; |
|
181 |
|
|
182 |
if (r==0 && g==0 && b==0) { |
|
183 |
return "0 g"; |
|
184 |
} else if (r==255 && g==255 && b==255) { |
|
185 |
return "1 g"; |
|
186 |
} else if (r == g && g == b) { |
|
187 |
sprintf(buf, "%.3f g", r/255.0); |
|
188 |
return buf; |
|
189 |
} else { |
|
190 |
sprintf(buf, "%.3f %.3f %.3f rg", r/255.0, g/255.0, b/255.0); |
|
191 |
return buf; |
|
192 |
} |
|
193 |
} |
|
194 |
|
|
195 |
static color_t pdf_color = -1; |
|
196 |
static double pdf_width = -1; |
|
197 |
|
|
198 |
static void pdf_setcolor(const color_t col) { |
|
199 |
if (col == pdf_color) { |
|
200 |
return; |
|
201 |
} |
|
202 |
pdf_color = col; |
|
203 |
|
|
204 |
ship("%s\n", pdf_colorstring(col)); |
|
205 |
} |
|
206 |
|
|
207 |
/* explicit encoding, does not use special macros */ |
|
208 |
static int pdf_path(potrace_curve_t *curve) { |
|
209 |
int i; |
|
210 |
dpoint_t *c; |
|
211 |
int m = curve->n; |
|
212 |
|
|
213 |
c = curve->c[m-1]; |
|
214 |
pdf_moveto(c[2]); |
|
215 |
|
|
216 |
for (i=0; i<m; i++) { |
|
217 |
c = curve->c[i]; |
|
218 |
switch (curve->tag[i]) { |
|
219 |
case POTRACE_CORNER: |
|
220 |
pdf_lineto(c[1]); |
|
221 |
pdf_lineto(c[2]); |
|
222 |
break; |
|
223 |
case POTRACE_CURVETO: |
|
224 |
pdf_curveto(c[0], c[1], c[2]); |
|
225 |
break; |
|
226 |
} |
|
227 |
} |
|
228 |
return 0; |
|
229 |
} |
|
230 |
|
|
231 |
/* ---------------------------------------------------------------------- */ |
|
232 |
/* Backends for various types of output. */ |
|
233 |
|
|
234 |
/* Normal output: black on transparent */ |
|
235 |
static int render0(potrace_path_t *plist) { |
|
236 |
potrace_path_t *p; |
|
237 |
|
|
238 |
pdf_setcolor(info.color); |
|
239 |
list_forall (p, plist) { |
|
240 |
pdf_path(&p->curve); |
|
241 |
ship("h\n"); |
|
242 |
if (p->next == NULL || p->next->sign == '+') { |
|
243 |
ship("f\n"); |
|
244 |
} |
|
245 |
} |
|
246 |
return 0; |
|
247 |
} |
|
248 |
|
|
249 |
/* Opaque output: alternating black and white */ |
|
250 |
static int render0_opaque(potrace_path_t *plist) { |
|
251 |
potrace_path_t *p; |
|
252 |
|
|
253 |
list_forall (p, plist) { |
|
254 |
pdf_path(&p->curve); |
|
255 |
ship("h\n"); |
|
256 |
pdf_setcolor(p->sign=='+' ? info.color : info.fillcolor); |
|
257 |
ship("f\n"); |
|
258 |
} |
|
259 |
return 0; |
|
260 |
} |
|
261 |
|
|
262 |
/* select the appropriate rendering function from above */ |
|
263 |
static int pdf_render(potrace_path_t *plist) |
|
264 |
{ |
|
265 |
if (info.opaque) { |
|
266 |
return render0_opaque(plist); |
|
267 |
} |
|
268 |
return render0(plist); |
|
269 |
} |
|
270 |
|
|
271 |
/* ---------------------------------------------------------------------- */ |
|
272 |
/* PDF header and footer */ |
|
273 |
|
|
274 |
int init_pdf(FILE *fout) |
|
275 |
{ |
|
276 |
intarray_init(&xref); |
|
277 |
intarray_init(&pages); |
|
278 |
nxref = 0; |
|
279 |
npages = 0; |
|
280 |
|
|
281 |
/* set callback functions for shipping routines */ |
|
282 |
pdf_callbacks(fout); |
|
283 |
outcount = 0; |
|
284 |
|
|
285 |
shipclear("%%PDF-1.3\n"); |
|
286 |
|
|
287 |
intarray_set(&xref, nxref++, outcount); |
|
288 |
shipclear("1 0 obj\n<</Type/Catalog/Pages 3 0 R>>\nendobj\n"); |
|
289 |
|
|
290 |
intarray_set(&xref, nxref++, outcount); |
|
291 |
shipclear("2 0 obj\n" |
|
292 |
"<</Creator" |
|
293 |
"("POTRACE" "VERSION", written by Peter Selinger 2001-2007)>>\n" |
|
294 |
"endobj\n"); |
|
295 |
|
|
296 |
/* delay obj #3 (pages) until end */ |
|
297 |
nxref++; |
|
298 |
|
|
299 |
fflush(fout); |
|
300 |
return 0; |
|
301 |
} |
|
302 |
|
|
303 |
int term_pdf(FILE *fout) |
|
304 |
{ |
|
305 |
int startxref; |
|
306 |
int i; |
|
307 |
|
|
308 |
pdf_callbacks(fout); |
|
309 |
|
|
310 |
intarray_set(&xref, 2, outcount); |
|
311 |
shipclear("3 0 obj\n" |
|
312 |
"<</Type/Pages/Count %d/Kids[\n", npages); |
|
313 |
for (i = 0; i < npages; i++) |
|
314 |
shipclear("%d 0 R\n", pages.data[i]); |
|
315 |
shipclear("]>>\nendobj\n"); |
|
316 |
|
|
317 |
startxref = outcount; |
|
318 |
|
|
319 |
shipclear("xref\n0 %d\n", nxref + 1); |
|
320 |
shipclear("0000000000 65535 f \n"); |
|
321 |
for (i = 0; i < nxref; i++) |
|
322 |
shipclear("%0.10d 00000 n \n", xref.data[i]); |
|
323 |
|
|
324 |
shipclear("trailer\n<</Size %d/Root 1 0 R/Info 2 0 R>>\n", nxref + 1); |
|
325 |
shipclear("startxref\n%d\n%%%%EOF\n", startxref); |
|
326 |
|
|
327 |
fflush(fout); |
|
328 |
intarray_term(&xref); |
|
329 |
intarray_term(&pages); |
|
330 |
return 0; |
|
331 |
} |
|
332 |
|
|
333 |
static void pdf_pageinit(imginfo_t *imginfo) |
|
334 |
{ |
|
335 |
double s, c; |
|
336 |
|
|
337 |
double origx = imginfo->trans.orig[0] + imginfo->lmar; |
|
338 |
double origy = imginfo->trans.orig[1] + imginfo->bmar; |
|
339 |
double scalex = imginfo->width / imginfo->pixwidth / info.unit; |
|
340 |
double scaley = imginfo->height / imginfo->pixheight / info.unit; |
|
341 |
int pagew = (int)ceil(imginfo->trans.bb[0]+imginfo->lmar+imginfo->rmar); |
|
342 |
int pageh = (int)ceil(imginfo->trans.bb[1]+imginfo->tmar+imginfo->bmar); |
|
343 |
|
|
344 |
pdf_color = -1; |
|
345 |
pdf_width = -1; |
|
346 |
|
|
347 |
intarray_set(&xref, nxref++, outcount); |
|
348 |
shipclear("%d 0 obj\n", nxref); |
|
349 |
shipclear("<</Type/Page/Parent 3 0 R/Resources<</ProcSet[/PDF]>>"); |
|
350 |
shipclear("/MediaBox[0 0 %d %d]", pagew, pageh); |
|
351 |
shipclear("/Contents %d 0 R>>\n", nxref + 1); |
|
352 |
shipclear("endobj\n"); |
|
353 |
|
|
354 |
intarray_set(&pages, npages++, nxref); |
|
355 |
|
|
356 |
intarray_set(&xref, nxref++, outcount); |
|
357 |
shipclear("%d 0 obj\n", nxref); |
|
358 |
if (info.compress) |
|
359 |
shipclear("<</Filter/FlateDecode/Length %d 0 R>>\n", nxref + 1); |
|
360 |
else |
|
361 |
shipclear("<</Length %d 0 R>>\n", nxref + 1); |
|
362 |
shipclear("stream\n"); |
|
363 |
|
|
364 |
streamofs = outcount; |
|
365 |
|
|
366 |
s = sin(info.angle * M_PI / 180.0); |
|
367 |
c = cos(info.angle * M_PI / 180.0); |
|
368 |
|
|
369 |
ship("%f %f %f %f %.0f %.0f cm\n", scalex*c, scalex*s, -scaley*s, scaley*c, origx, origy); |
|
370 |
} |
|
371 |
|
|
372 |
static void pdf_pageterm(void) |
|
373 |
{ |
|
374 |
int streamlen; |
|
375 |
|
|
376 |
shipclear(""); |
|
377 |
|
|
378 |
streamlen = outcount - streamofs; |
|
379 |
shipclear("endstream\nendobj\n"); |
|
380 |
|
|
381 |
intarray_set(&xref, nxref++, outcount); |
|
382 |
shipclear("%d 0 obj\n%d\nendobj\n", nxref, streamlen); |
|
383 |
} |
|
384 |
|
|
385 |
int page_pdf(FILE *fout, potrace_path_t *plist, imginfo_t *imginfo) |
|
386 |
{ |
|
387 |
int r; |
|
388 |
|
|
389 |
pdf_callbacks(fout); |
|
390 |
|
|
391 |
pdf_pageinit(imginfo); |
|
392 |
|
|
393 |
r = pdf_render(plist); |
|
394 |
if (r) { |
|
395 |
return r; |
|
396 |
} |
|
397 |
|
|
398 |
pdf_pageterm(); |
|
399 |
|
|
400 |
fflush(fout); |
|
401 |
|
|
402 |
return 0; |
|
403 |
} |
|
404 |
|
tags/gvsig_redes-1_0_0-1235/libraries/libjni-potrace/resources/potrace-1.8/src/getopt1.c | ||
---|---|---|
1 |
/* getopt_long and getopt_long_only entry points for GNU getopt. |
|
2 |
Copyright (C) 1987,88,89,90,91,92,93,94,96,97,98 |
|
3 |
Free Software Foundation, Inc. |
|
4 |
This file is part of the GNU C Library. |
|
5 |
|
|
6 |
The GNU C Library is free software; you can redistribute it and/or |
|
7 |
modify it under the terms of the GNU Library General Public License as |
|
8 |
published by the Free Software Foundation; either version 2 of the |
|
9 |
License, or (at your option) any later version. |
|
10 |
|
|
11 |
The GNU C Library is distributed in the hope that it will be useful, |
|
12 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
14 |
Library General Public License for more details. |
|
15 |
|
|
16 |
You should have received a copy of the GNU Library General Public |
|
17 |
License along with the GNU C Library; see the file COPYING.LIB. If not, |
|
18 |
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
|
19 |
Boston, MA 02111-1307, USA. */ |
|
20 |
|
|
21 |
#ifdef HAVE_CONFIG_H |
|
22 |
#include <config.h> |
|
23 |
#endif |
|
24 |
|
|
25 |
#include "getopt.h" |
|
26 |
|
|
27 |
#if !defined __STDC__ || !__STDC__ |
|
28 |
/* This is a separate conditional since some stdc systems |
|
29 |
reject `defined (const)'. */ |
|
30 |
#ifndef const |
|
31 |
#define const |
|
32 |
#endif |
|
33 |
#endif |
|
34 |
|
|
35 |
#include <stdio.h> |
|
36 |
|
|
37 |
/* Comment out all this code if we are using the GNU C Library, and are not |
|
38 |
actually compiling the library itself. This code is part of the GNU C |
|
39 |
Library, but also included in many other GNU distributions. Compiling |
|
40 |
and linking in this code is a waste when using the GNU C library |
|
41 |
(especially if it is a shared library). Rather than having every GNU |
|
42 |
program understand `configure --with-gnu-libc' and omit the object files, |
|
43 |
it is simpler to just do this in the source for each such file. */ |
|
44 |
|
|
45 |
#define GETOPT_INTERFACE_VERSION 2 |
|
46 |
#if !defined _LIBC && defined __GLIBC__ && __GLIBC__ >= 2 |
|
47 |
#include <gnu-versions.h> |
|
48 |
#if _GNU_GETOPT_INTERFACE_VERSION == GETOPT_INTERFACE_VERSION |
|
49 |
#define ELIDE_CODE |
|
50 |
#endif |
|
51 |
#endif |
|
52 |
|
|
53 |
#ifndef ELIDE_CODE |
|
54 |
|
|
55 |
|
|
56 |
/* This needs to come after some library #include |
|
57 |
to get __GNU_LIBRARY__ defined. */ |
|
58 |
#ifdef __GNU_LIBRARY__ |
|
59 |
#include <stdlib.h> |
|
60 |
#endif |
|
61 |
|
|
62 |
#ifndef NULL |
|
63 |
#define NULL 0 |
|
64 |
#endif |
|
65 |
|
|
66 |
int |
|
67 |
getopt_long (argc, argv, options, long_options, opt_index) |
|
68 |
int argc; |
|
69 |
char *const *argv; |
|
70 |
const char *options; |
|
71 |
const struct option *long_options; |
|
72 |
int *opt_index; |
|
73 |
{ |
|
74 |
return _getopt_internal (argc, argv, options, long_options, opt_index, 0); |
|
75 |
} |
|
76 |
|
|
77 |
/* Like getopt_long, but '-' as well as '--' can indicate a long option. |
|
78 |
If an option that starts with '-' (not '--') doesn't match a long option, |
|
79 |
but does match a short option, it is parsed as a short option |
|
80 |
instead. */ |
|
81 |
|
|
82 |
int |
|
83 |
getopt_long_only (argc, argv, options, long_options, opt_index) |
|
84 |
int argc; |
|
85 |
char *const *argv; |
|
86 |
const char *options; |
|
87 |
const struct option *long_options; |
|
88 |
int *opt_index; |
|
89 |
{ |
|
90 |
return _getopt_internal (argc, argv, options, long_options, opt_index, 1); |
|
91 |
} |
|
92 |
|
|
93 |
|
|
94 |
#endif /* Not ELIDE_CODE. */ |
|
95 |
|
|
96 |
#ifdef TEST |
|
97 |
|
|
98 |
#include <stdio.h> |
|
99 |
|
|
100 |
int |
|
101 |
main (argc, argv) |
|
102 |
int argc; |
|
103 |
char **argv; |
|
104 |
{ |
|
105 |
int c; |
|
106 |
int digit_optind = 0; |
|
107 |
|
|
108 |
while (1) |
|
109 |
{ |
|
110 |
int this_option_optind = optind ? optind : 1; |
|
111 |
int option_index = 0; |
|
112 |
static struct option long_options[] = |
|
113 |
{ |
|
114 |
{"add", 1, 0, 0}, |
|
115 |
{"append", 0, 0, 0}, |
|
116 |
{"delete", 1, 0, 0}, |
|
117 |
{"verbose", 0, 0, 0}, |
|
118 |
{"create", 0, 0, 0}, |
|
119 |
{"file", 1, 0, 0}, |
|
120 |
{0, 0, 0, 0} |
|
121 |
}; |
|
122 |
|
|
123 |
c = getopt_long (argc, argv, "abc:d:0123456789", |
|
124 |
long_options, &option_index); |
|
125 |
if (c == -1) |
|
126 |
break; |
|
127 |
|
|
128 |
switch (c) |
|
129 |
{ |
|
130 |
case 0: |
|
131 |
printf ("option %s", long_options[option_index].name); |
|
132 |
if (optarg) |
|
133 |
printf (" with arg %s", optarg); |
|
134 |
printf ("\n"); |
|
135 |
break; |
|
136 |
|
|
137 |
case '0': |
|
138 |
case '1': |
|
139 |
case '2': |
|
140 |
case '3': |
|
141 |
case '4': |
|
142 |
case '5': |
|
143 |
case '6': |
|
144 |
case '7': |
|
145 |
case '8': |
|
146 |
case '9': |
|
147 |
if (digit_optind != 0 && digit_optind != this_option_optind) |
|
148 |
printf ("digits occur in two different argv-elements.\n"); |
|
149 |
digit_optind = this_option_optind; |
|
150 |
printf ("option %c\n", c); |
|
151 |
break; |
|
152 |
|
|
153 |
case 'a': |
|
154 |
printf ("option a\n"); |
|
155 |
break; |
|
156 |
|
|
157 |
case 'b': |
|
158 |
printf ("option b\n"); |
|
159 |
break; |
|
160 |
|
|
161 |
case 'c': |
|
162 |
printf ("option c with value `%s'\n", optarg); |
|
163 |
break; |
|
164 |
|
|
165 |
case 'd': |
|
166 |
printf ("option d with value `%s'\n", optarg); |
|
167 |
break; |
|
168 |
|
|
169 |
case '?': |
|
170 |
break; |
|
171 |
|
|
172 |
default: |
|
173 |
printf ("?? getopt returned character code 0%o ??\n", c); |
|
174 |
} |
|
175 |
} |
|
176 |
|
|
177 |
if (optind < argc) |
|
178 |
{ |
|
179 |
printf ("non-option ARGV-elements: "); |
|
180 |
while (optind < argc) |
|
181 |
printf ("%s ", argv[optind++]); |
|
182 |
printf ("\n"); |
|
183 |
} |
|
184 |
|
|
185 |
exit (0); |
|
186 |
} |
|
187 |
|
|
188 |
#endif /* TEST */ |
tags/gvsig_redes-1_0_0-1235/libraries/libjni-potrace/resources/potrace-1.8/src/curve.c | ||
---|---|---|
1 |
/* Copyright (C) 2001-2007 Peter Selinger. |
|
2 |
This file is part of Potrace. It is free software and it is covered |
|
3 |
by the GNU General Public License. See the file COPYING for details. */ |
|
4 |
|
|
5 |
/* $Id: curve.c 147 2007-04-09 00:44:09Z selinger $ */ |
|
6 |
/* private part of the path and curve data structures */ |
|
7 |
|
|
8 |
#include <stdio.h> |
|
9 |
#include <stdlib.h> |
|
10 |
#include <string.h> |
|
11 |
|
|
12 |
#include "potracelib.h" |
|
13 |
#include "lists.h" |
|
14 |
#include "curve.h" |
|
15 |
|
|
16 |
#define SAFE_MALLOC(var, n, typ) \ |
|
17 |
if ((var = (typ *)malloc((n)*sizeof(typ))) == NULL) goto malloc_error |
|
18 |
|
|
19 |
/* ---------------------------------------------------------------------- */ |
|
20 |
/* allocate and free path objects */ |
|
21 |
|
|
22 |
path_t *path_new(void) { |
|
23 |
path_t *p = NULL; |
|
24 |
privpath_t *priv = NULL; |
|
25 |
|
|
26 |
SAFE_MALLOC(p, 1, path_t); |
|
27 |
memset(p, 0, sizeof(path_t)); |
|
28 |
SAFE_MALLOC(priv, 1, privpath_t); |
|
29 |
memset(priv, 0, sizeof(privpath_t)); |
|
30 |
p->priv = priv; |
|
31 |
return p; |
|
32 |
|
|
33 |
malloc_error: |
|
34 |
free(p); |
|
35 |
free(priv); |
|
36 |
return NULL; |
|
37 |
} |
|
38 |
|
|
39 |
/* free the members of the given curve structure. Leave errno unchanged. */ |
|
40 |
static void privcurve_free_members(privcurve_t *curve) { |
|
41 |
free(curve->tag); |
|
42 |
free(curve->c); |
|
43 |
free(curve->vertex); |
|
44 |
free(curve->alpha); |
|
45 |
free(curve->alpha0); |
|
46 |
free(curve->beta); |
|
47 |
} |
|
48 |
|
|
49 |
/* free a path. Leave errno untouched. */ |
|
50 |
void path_free(path_t *p) { |
|
51 |
if (p) { |
|
52 |
if (p->priv) { |
|
53 |
free(p->priv->pt); |
|
54 |
free(p->priv->lon); |
|
55 |
free(p->priv->sums); |
|
56 |
free(p->priv->po); |
|
57 |
privcurve_free_members(&p->priv->curve); |
|
58 |
privcurve_free_members(&p->priv->ocurve); |
|
59 |
} |
|
60 |
free(p->priv); |
|
61 |
/* do not free p->fcurve ! */ |
|
62 |
} |
|
63 |
free(p); |
|
64 |
} |
|
65 |
|
|
66 |
/* free a pathlist, leaving errno untouched. */ |
|
67 |
void pathlist_free(path_t *plist) { |
|
68 |
path_t *p; |
|
69 |
|
|
70 |
list_forall_unlink(p, plist) { |
|
71 |
path_free(p); |
|
72 |
} |
|
73 |
} |
|
74 |
|
|
75 |
/* ---------------------------------------------------------------------- */ |
|
76 |
/* initialize and finalize curve structures */ |
|
77 |
|
|
78 |
typedef dpoint_t dpoint3_t[3]; |
|
79 |
|
|
80 |
/* initialize the members of the given curve structure to size m. |
|
81 |
Return 0 on success, 1 on error with errno set. */ |
|
82 |
int privcurve_init(privcurve_t *curve, int n) { |
|
83 |
memset(curve, 0, sizeof(privcurve_t)); |
|
84 |
curve->n = n; |
|
85 |
SAFE_MALLOC(curve->tag, n, int); |
|
86 |
SAFE_MALLOC(curve->c, n, dpoint3_t); |
|
87 |
SAFE_MALLOC(curve->vertex, n, dpoint_t); |
|
88 |
SAFE_MALLOC(curve->alpha, n, double); |
|
89 |
SAFE_MALLOC(curve->alpha0, n, double); |
|
90 |
SAFE_MALLOC(curve->beta, n, double); |
|
91 |
return 0; |
|
92 |
|
|
93 |
malloc_error: |
|
94 |
free(curve->tag); |
|
95 |
free(curve->c); |
|
96 |
free(curve->vertex); |
|
97 |
free(curve->alpha); |
|
98 |
free(curve->alpha0); |
|
99 |
free(curve->beta); |
|
100 |
return 1; |
|
101 |
} |
|
102 |
|
|
103 |
/* copy private to public curve structure */ |
|
104 |
void privcurve_to_curve(privcurve_t *pc, potrace_curve_t *c) { |
|
105 |
c->n = pc->n; |
|
106 |
c->tag = pc->tag; |
|
107 |
c->c = pc->c; |
|
108 |
} |
|
109 |
|
tags/gvsig_redes-1_0_0-1235/libraries/libjni-potrace/resources/potrace-1.8/src/potracelib.c | ||
---|---|---|
1 |
/* Copyright (C) 2001-2007 Peter Selinger. |
|
2 |
This file is part of Potrace. It is free software and it is covered |
|
3 |
by the GNU General Public License. See the file COPYING for details. */ |
|
4 |
|
|
5 |
#include <stdlib.h> |
|
6 |
#include <string.h> |
|
7 |
|
|
8 |
#include "potracelib.h" |
|
9 |
#include "curve.h" |
|
10 |
#include "decompose.h" |
|
11 |
#include "trace.h" |
|
12 |
#include "progress.h" |
|
13 |
|
|
14 |
#ifdef HAVE_CONFIG_H |
|
15 |
#include "config.h" |
|
16 |
#endif |
|
17 |
|
|
18 |
/* default parameters */ |
|
19 |
static const potrace_param_t param_default = { |
|
20 |
2, /* turdsize */ |
|
21 |
POTRACE_TURNPOLICY_MINORITY, /* turnpolicy */ |
|
22 |
1.0, /* alphamax */ |
|
23 |
1, /* opticurve */ |
|
24 |
0.2, /* opttolerance */ |
|
25 |
{ |
|
26 |
NULL, /* callback function */ |
|
27 |
NULL, /* callback data */ |
|
28 |
0.0, 1.0, /* progress range */ |
|
29 |
0.0, /* granularity */ |
|
30 |
}, |
|
31 |
}; |
|
32 |
|
|
33 |
/* Return a fresh copy of the set of default parameters, or NULL on |
|
34 |
failure with errno set. */ |
|
35 |
potrace_param_t *potrace_param_default(void) { |
|
36 |
potrace_param_t *p; |
|
37 |
|
|
38 |
p = (potrace_param_t *) malloc(sizeof(potrace_param_t)); |
|
39 |
if (!p) { |
|
40 |
return NULL; |
|
41 |
} |
|
42 |
memcpy(p, ¶m_default, sizeof(potrace_param_t)); |
|
43 |
return p; |
|
44 |
} |
|
45 |
|
|
46 |
/* On success, returns a Potrace state st with st->status == |
|
47 |
POTRACE_STATUS_OK. On failure, returns NULL if no Potrace state |
|
48 |
could be created (with errno set), or returns an incomplete Potrace |
|
49 |
state (with st->status == POTRACE_STATUS_INCOMPLETE). Complete or |
|
50 |
incomplete Potrace state can be freed with potrace_state_free(). */ |
|
51 |
potrace_state_t *potrace_trace(const potrace_param_t *param, const potrace_bitmap_t *bm) { |
|
52 |
int r; |
|
53 |
path_t *plist = NULL; |
|
54 |
potrace_state_t *st; |
|
55 |
progress_t prog; |
|
56 |
progress_t subprog; |
|
57 |
|
|
58 |
/* prepare private progress bar state */ |
|
59 |
prog.callback = param->progress.callback; |
|
60 |
prog.data = param->progress.data; |
|
61 |
prog.min = param->progress.min; |
|
62 |
prog.max = param->progress.max; |
|
63 |
prog.epsilon = param->progress.epsilon; |
|
64 |
prog.d_prev = param->progress.min; |
|
65 |
|
|
66 |
/* allocate state object */ |
|
67 |
st = (potrace_state_t *)malloc(sizeof(potrace_state_t)); |
|
68 |
if (!st) { |
|
69 |
return NULL; |
|
70 |
} |
|
71 |
|
|
72 |
progress_subrange_start(0.0, 0.1, &prog, &subprog); |
|
73 |
|
|
74 |
/* process the image */ |
|
75 |
r = bm_to_pathlist(bm, &plist, param, &subprog); |
|
76 |
if (r) { |
|
77 |
free(st); |
|
78 |
return NULL; |
|
79 |
} |
|
80 |
|
|
81 |
st->status = POTRACE_STATUS_OK; |
|
82 |
st->plist = plist; |
|
83 |
st->priv = NULL; /* private state currently unused */ |
|
84 |
|
|
85 |
progress_subrange_end(&prog, &subprog); |
|
86 |
|
|
87 |
progress_subrange_start(0.1, 1.0, &prog, &subprog); |
|
88 |
|
|
89 |
/* partial success. */ |
|
90 |
r = process_path(plist, param, &subprog); |
|
91 |
if (r) { |
|
92 |
st->status = POTRACE_STATUS_INCOMPLETE; |
|
93 |
} |
|
94 |
|
|
95 |
progress_subrange_end(&prog, &subprog); |
|
96 |
|
|
97 |
return st; |
|
98 |
} |
|
99 |
|
|
100 |
/* free a Potrace state, without disturbing errno. */ |
|
101 |
void potrace_state_free(potrace_state_t *st) { |
|
102 |
pathlist_free(st->plist); |
|
103 |
free(st); |
|
104 |
} |
|
105 |
|
|
106 |
/* free a parameter list, without disturbing errno. */ |
|
107 |
void potrace_param_free(potrace_param_t *p) { |
|
108 |
free(p); |
|
109 |
} |
|
110 |
|
|
111 |
char *potrace_version(void) { |
|
112 |
return "potracelib "VERSION""; |
|
113 |
} |
tags/gvsig_redes-1_0_0-1235/libraries/libjni-potrace/resources/potrace-1.8/src/backend_pdf.h | ||
---|---|---|
1 |
/* Copyright (C) 2001-2007 Peter Selinger. |
|
2 |
This file is part of Potrace. It is free software and it is covered |
|
3 |
by the GNU General Public License. See the file COPYING for details. */ |
|
4 |
|
|
5 |
/* $Id: backend_pdf.h 147 2007-04-09 00:44:09Z selinger $ */ |
|
6 |
|
|
7 |
#ifndef BACKEND_PDF_H |
|
8 |
#define BACKEND_PDF_H |
|
9 |
|
|
10 |
#include "potracelib.h" |
|
11 |
#include "main.h" |
|
12 |
|
|
13 |
int init_pdf(FILE *fout); |
|
14 |
int page_pdf(FILE *fout, potrace_path_t *plist, imginfo_t *imginfo); |
|
15 |
int term_pdf(FILE *fout); |
|
16 |
|
|
17 |
int page_pdf(FILE *fout, potrace_path_t *plist, imginfo_t *imginfo); |
|
18 |
|
|
19 |
#endif /* BACKEND_PDF_H */ |
|
20 |
|
tags/gvsig_redes-1_0_0-1235/libraries/libjni-potrace/resources/potrace-1.8/src/potracelib_demo.c | ||
---|---|---|
1 |
/* Copyright (C) 2001-2007 Peter Selinger. |
|
2 |
This file is part of Potrace. It is free software and it is covered |
|
3 |
by the GNU General Public License. See the file COPYING for details. */ |
|
4 |
|
|
5 |
/* A simple and self-contained demo of the potracelib API */ |
|
6 |
|
|
7 |
#include <stdio.h> |
|
8 |
#include <string.h> |
|
9 |
#include <errno.h> |
|
10 |
#include <stdlib.h> |
|
11 |
|
|
12 |
#include "potracelib.h" |
|
13 |
|
|
14 |
#define WIDTH 250 |
|
15 |
#define HEIGHT 250 |
|
16 |
|
|
17 |
/* ---------------------------------------------------------------------- */ |
|
18 |
/* auxiliary bitmap functions */ |
|
19 |
|
|
20 |
/* macros for writing individual bitmap pixels */ |
|
21 |
#define BM_WORDSIZE ((int)sizeof(potrace_word)) |
|
22 |
#define BM_WORDBITS (8*BM_WORDSIZE) |
|
23 |
#define BM_HIBIT (((potrace_word)1)<<(BM_WORDBITS-1)) |
|
24 |
#define bm_scanline(bm, y) ((bm)->map + (y)*(bm)->dy) |
|
25 |
#define bm_index(bm, x, y) (&bm_scanline(bm, y)[(x)/BM_WORDBITS]) |
|
26 |
#define bm_mask(x) (BM_HIBIT >> ((x) & (BM_WORDBITS-1))) |
|
27 |
#define bm_range(x, a) ((int)(x) >= 0 && (int)(x) < (a)) |
Also available in: Unified diff