hi,
I'm not familiar with Java but have to use it to slice a map into smaller tiles. Actually I use Batik projects and it has the following .java file:
ImageTiler.java
[java]
package com.ajaxian.ama ps;
import org.apache.bati k.apps.rasteriz er.DestinationT ype;
import org.apache.bati k.apps.rasteriz er.SVGConverter ;
import javax.imageio.I mageIO;
import java.io.File;
import java.awt.*;
import java.awt.image. BufferedImage;
public class ImageTiler {
private static final String BASE_DIR = "rc/";
private static final int TILE_WIDTH = 100;
private static final int TILE_HEIGHT = 100;
public static void main(String[] args) throws Exception {
// create the tiles
String[][] sources = { { "mapSpain.j pg", "0" },
{"mapSpain-smaller.jpg", "1"} };
for (int i = 0; i < sources.length; i++) {
String[] source = sources[i];
BufferedImage bi = ImageIO.read(ne w File(BASE_DIR + source[0]));
int columns = bi.getWidth() / TILE_WIDTH;
int rows = bi.getHeight() / TILE_HEIGHT;
for (int x = 0; x < columns; x++) {
for (int y = 0; y < rows; y++) {
BufferedImage img = new BufferedImage(T ILE_WIDTH, TILE_HEIGHT,
bi.getType());
Graphics2D newGraphics = (Graphics2D) img.getGraphics ();
newGraphics.dra wImage(bi, 0, 0, TILE_WIDTH, TILE_HEIGHT,
TILE_WIDTH * x, TILE_HEIGHT * y,
TILE_WIDTH * x + TILE_WIDTH,
TILE_HEIGHT * y + TILE_HEIGHT,
null);
ImageIO.write(i mg, "JPG", new File(BASE_DIR + "tiles/" +
"x" + x + "y" + y + "z" + source[1] + ".jpg"));
}
}
}
}
}
[/java]
as guided I put all JAR files in D:\jcp and set it as classpath, using this command: java -classpath D:\jcp; com.ajaxian.ama ps but all I received is the error: "java.lang.NoCl assDefFoundErro r: com/ajaxian/amaps/ImageTiler
Exception in thread "main"
Process completed."
ImageTiler.java file is placed in D:\xampp\htdocs \MAP\code\Googl eMaps\src\com\a jaxian\amaps and inside D:\xampp\htdocs \MAP\code\Googl eMaps\rc are the two images.
what's the problem here? I know nothing about java. so plz guide me out :(
I'm not familiar with Java but have to use it to slice a map into smaller tiles. Actually I use Batik projects and it has the following .java file:
ImageTiler.java
[java]
package com.ajaxian.ama ps;
import org.apache.bati k.apps.rasteriz er.DestinationT ype;
import org.apache.bati k.apps.rasteriz er.SVGConverter ;
import javax.imageio.I mageIO;
import java.io.File;
import java.awt.*;
import java.awt.image. BufferedImage;
public class ImageTiler {
private static final String BASE_DIR = "rc/";
private static final int TILE_WIDTH = 100;
private static final int TILE_HEIGHT = 100;
public static void main(String[] args) throws Exception {
// create the tiles
String[][] sources = { { "mapSpain.j pg", "0" },
{"mapSpain-smaller.jpg", "1"} };
for (int i = 0; i < sources.length; i++) {
String[] source = sources[i];
BufferedImage bi = ImageIO.read(ne w File(BASE_DIR + source[0]));
int columns = bi.getWidth() / TILE_WIDTH;
int rows = bi.getHeight() / TILE_HEIGHT;
for (int x = 0; x < columns; x++) {
for (int y = 0; y < rows; y++) {
BufferedImage img = new BufferedImage(T ILE_WIDTH, TILE_HEIGHT,
bi.getType());
Graphics2D newGraphics = (Graphics2D) img.getGraphics ();
newGraphics.dra wImage(bi, 0, 0, TILE_WIDTH, TILE_HEIGHT,
TILE_WIDTH * x, TILE_HEIGHT * y,
TILE_WIDTH * x + TILE_WIDTH,
TILE_HEIGHT * y + TILE_HEIGHT,
null);
ImageIO.write(i mg, "JPG", new File(BASE_DIR + "tiles/" +
"x" + x + "y" + y + "z" + source[1] + ".jpg"));
}
}
}
}
}
[/java]
as guided I put all JAR files in D:\jcp and set it as classpath, using this command: java -classpath D:\jcp; com.ajaxian.ama ps but all I received is the error: "java.lang.NoCl assDefFoundErro r: com/ajaxian/amaps/ImageTiler
Exception in thread "main"
Process completed."
ImageTiler.java file is placed in D:\xampp\htdocs \MAP\code\Googl eMaps\src\com\a jaxian\amaps and inside D:\xampp\htdocs \MAP\code\Googl eMaps\rc are the two images.
what's the problem here? I know nothing about java. so plz guide me out :(
Comment