I encountered this piece of code
do {
if (higherQuality && w > targetWidth) {
w /= 2;
if (w < targetWidth) {
w = targetWidth;
}
}
if (higherQuality && h > targetHeight) {
h /= 2;
if (h < targetHeight) {
h = targetHeight;
}
}
BufferedImage tmp = new BufferedImage(w, h, type);
Graphics2D g2 = tmp.createGraphics();
g2.setRenderingHint(RenderingHints.KEY_INTERPOLATION, hint);
g2.drawImage(ret, 0, 0, w, h, null);
g2.dispose();
ret = tmp;
} while (w != targetWidth || h != targetHeight);
I don't get the meaning of these if conditions
if (higherQuality && w > targetWidth)
and
if (higherQuality && h > targetHeight)
It resembles C's &variable reference operator to me. I am new to java but I know it doesn't support such thing and I was unable to google out any other meaning of ampersand in java aside from standard bitwise and logical AND. I would appreciate any explanation. Thank you.
&
and >
are HTML character references; it looks like the above code has simply been badly encoded on whatever website you found it on.
So for reference, this:
if (higherQuality && w > targetWidth)
should have been displayed as this:
if (higherQuality && w > targetWidth)