i cant find any solution for my problem, hope you can help me. I have a Buffered image (e.g. img), und i want to resize it (with its array of pixels) to fit exactly 100px (100 x 100). All the solutions i found are just for "stretching" the image when drawing, but i really need the array. I thought about a algorithm and tried this one:
BufferedImage resized = new BufferedImage(100,100,BufferedImage.TYPE_INT_ARGB);
for(int i = 0; i < img.getWidth(); i++){
for(int j = 0; j < img.getHeight(); j++){
resized.setRGB(i*(100/img.getWidth()), j*(100/img.getHeight()), img.getRGB(i, j));
}
}
I cant explain it (well, not in english) what it does, but i think you can see it easily (for every pixel in the original image (img), put it in the new BufferedImage (resized) at the postition (the old position * resize factor). (hope that was a good description). But however, it doesnt work, i only get zeros :( Can somebody tell me what to modify or give me a other example for a algorithm? (doesnt matter how fast it is, as long as i can understand it)
(I really hope it isnt a repost, because i really could not find another problem/solution that aims at the array resizing :/ )
Greetings :)