I've done a bit of research but I mostly see c++ answers. The closest I've come to is this. I also saw this page but it doesn't really explain anything.
Are there any advantages if I use the second piece of code? Will there be noticable performance differences? What about memory? What if it's done repetitively?
Right now I have this function. I'm sure the benefit of this is code readability:
private static Bitmap resize(Bitmap image, int maxWidth) {
float widthReducePercentage = ((float) maxWidth / image.getWidth());
int scaledHeight = Math.round(image.getHeight() * widthReducePercentage);
return Bitmap.createScaledBitmap(image, maxWidth, scaledHeight, true);
}
Now, I have this second snippet of code:
private static Bitmap resize(Bitmap image, int maxWidth) {
return Bitmap.createScaledBitmap(image, maxWidth, Math.round(image.getHeight() * (float) maxWidth / image.getWidth()), true);
}
A simpler example would be:
for(;;) {
String foo = "hello";
Console.print(foo + "world");
}
versus
for(;;) {
Console.print("hello" + "world");
}