All pastes #734051 Raw Edit

Untitled

public java v1 · immutable
·published 2007-10-12 10:23 UTC
rendered paste body
	private static Image resizeImage(final Image src, final int size) {		final int srcWidth = src.getWidth();		final int srcHeight = src.getHeight();		final Image tmp = Image.createImage(size, srcHeight);		Graphics g = tmp.getGraphics();		int ratio = (srcWidth << 16) / size;		int pos = ratio / 2;		for(int x = 0; x < size; x++) {			g.setClip(x, 0, 1, srcHeight);			g.drawImage(src, x - (pos >> 16), 0, Graphics.LEFT | Graphics.TOP);			pos += ratio;		}		final Image resizedImage = Image.createImage(size, size);		g = resizedImage.getGraphics();		ratio = (srcHeight << 16) / size;		pos = ratio / 2;		for(int y = 0; y < size; y++) {			g.setClip(0, y, size, 1);			g.drawImage(tmp, 0, y - (pos >> 16), Graphics.LEFT | Graphics.TOP);			pos += ratio;		}		return resizedImage;	}