Are trying SEARCH here?
http://onesearch.sun.com/search/onesearch/index.jsp?qt=resize&subCat=siteforumid%3Ajava76%2Csiteforumid%3Ajava80%2Csiteforumid%3Ajava82&site=dev&dftab=siteforumid%3Ajava76%2Csiteforumid%3Ajava80%2Csiteforumid%3Ajava82&chooseCat=javaall&col=developer-forums
1) From SUN example
private Image resize(Image image, int width, int height) {
int sourceWidth = image.getWidth();
int sourceHeight = image.getHeight();
Image thumb = Image.createImage(width, height);
Graphics g = thumb.getGraphics();
for (int y = 0; y < height; y++) {
for (int x = 0; x < width; x++) {
g.setClip(x, y, 1, 1);
int deltaX = x * sourceWidth / width;
int deltaY = y * sourceHeight / height;
g.drawImage(image, x - deltaX, y - deltaY, Graphics.LEFT | Graphics.TOP);
}
}
Image immutableThumb = Image.createImage(thumb);
return immutableThumb;
}
2: From this forum
private int[] reescalaArray(int[] ini, int x, int y, int x2, int y2) {
int out[] = new int[x2*y2];
for (int yy = 0; yy < y2; yy++) {
int dy = yy * y / y2;
for (int xx = 0; xx < x2; xx++) {
int dx = xx * x / x2;
out[(x2*yy)+xx]=ini[(x*dy)+dx]; } }
return out;}
private Image getSmall(Image temp, int newX, int newY) throws Exception{
//Need an array (for RGB, with the size of original image)
int tX = temp.getWidth();
int tY = temp.getHeight();
int rgb[] = new int[tX*tY];//Get the RGB array of image into "rgb"
temp.getRGB(rgb,0,tX,0,0,tX,tY);//Call to our function and obtain RGB2
int rgb2[] = reescalaArray(rgb,tX,tY,newX,newY);//Create an image with that RGB array
rgb = null;
Image temp2 = Image.createRGBImage(rgb2,newX,newY,true);
rgb2 = null;
return temp2;
}