"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "debugger/src/main/java/org/apache/pdfbox/debugger/ui/ImageUtil.java" between
pdfbox-2.0.23-src.zip and pdfbox-2.0.24-src.zip

About: Apache PDFBox is a Java PDF library tool that allows creation of new PDF documents, manipulation of existing documents and the ability to extract content from documents.

ImageUtil.java  (pdfbox-2.0.23-src):ImageUtil.java  (pdfbox-2.0.24-src)
skipping to change at line 39 skipping to change at line 39
private ImageUtil() private ImageUtil()
{ {
} }
/** /**
* Return an image rotated by a multiple of 90°. * Return an image rotated by a multiple of 90°.
* *
* @param image The image to rotate. * @param image The image to rotate.
* @param rotation The rotation in degrees. * @param rotation The rotation in degrees.
* @return The rotated image. * @return The rotated image.
* @throws IllegalArgumentException if the angle isn't a multiple of 90°.
*/ */
public static BufferedImage getRotatedImage(BufferedImage image, int rotatio n) public static BufferedImage getRotatedImage(BufferedImage image, int rotatio n)
{ {
int width = image.getWidth(); int width = image.getWidth();
int height = image.getHeight(); int height = image.getHeight();
double x = 0; int x = 0;
double y = 0; int y = 0;
BufferedImage rotatedImage; BufferedImage rotatedImage;
switch (rotation % 360) switch ((rotation + 360) % 360)
{ {
case 0:
return image;
case 90: case 90:
x = height; x = height;
rotatedImage = new BufferedImage(height, width, BufferedImage.TY PE_INT_RGB); rotatedImage = new BufferedImage(height, width, image.getType()) ;
break; break;
case 270: case 270:
y = width; y = width;
rotatedImage = new BufferedImage(height, width, BufferedImage.TY PE_INT_RGB); rotatedImage = new BufferedImage(height, width, image.getType()) ;
break; break;
case 180: case 180:
x = width; x = width;
y = height; y = height;
rotatedImage = new BufferedImage(width, height, BufferedImage.TY PE_INT_RGB); rotatedImage = new BufferedImage(width, height, image.getType()) ;
break; break;
default: default:
return image; throw new IllegalArgumentException("Only multiple of 90° are sup ported");
} }
Graphics2D g = (Graphics2D) rotatedImage.getGraphics(); Graphics2D g = (Graphics2D) rotatedImage.getGraphics();
g.translate(x, y); g.translate(x, y);
g.rotate(Math.toRadians(rotation)); g.rotate(Math.toRadians(rotation));
g.drawImage(image, 0, 0, null); g.drawImage(image, 0, 0, null);
g.dispose(); g.dispose();
return rotatedImage; return rotatedImage;
} }
} }
 End of changes. 8 change blocks. 
7 lines changed or deleted 10 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)