Skip to main content

Resizing Images

1 reply [Last post]
Joined: 2008-07-03

Hello! I'm creating a WS to provide my modile app some imgs, but the images I get on the WS are too big to use in the mobile, so I need to reduce its size.

What I have right now:
I get the images through their URL, put it in a BufferedImage(bi - for future uses);
Then I put the RGB of the bi on a int[]
And finally use JSON to send it to the modile app

What I need:
I need a way to convert the images I get from the URLs into images with the size 20,20

My code:

private int[] retImg;
public int[] getImageRGB(URL url) {
try {

BufferedImage bigger =;

int[] resp = getArrayFromImage(bigger , bigger.getWidth(), bigger.getHeight());

retImg = resp;
return retImg;
} catch (Exception ex) {
return null;

private int[] getArrayFromImage(Image img, int width, int height)
throws InterruptedException {
int[] pixels = new int[width * height];
PixelGrabber pg = new PixelGrabber(img, 0, 0, width, height, pixels, 0,


return pixels;
Any solution/sugestion/comment is welcome! ^^

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Joined: 2008-07-03

problem solved, no need to reply