Skip to content

Commit

Permalink
Remove unused methods
Browse files Browse the repository at this point in the history
  • Loading branch information
datazuul authored and jbaiter committed May 15, 2020
1 parent ff58051 commit 1a25cb7
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 44 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,35 +56,6 @@ public static boolean containsAlphaChannel(BufferedImage image) {
return image.getColorModel().hasAlpha();
}

/**
* @param image buffered image to check for transparent pixels
* @return true, if image contains transparent pixels
*/
public static boolean containsTransparency(BufferedImage image) {
for (int i = 0; i < image.getHeight(); i++) {
for (int j = 0; j < image.getWidth(); j++) {
if (isTransparent(image, j, i)) {
return true;
}
}
}
return false;
}

/**
* @param image buffered image to check for transparent pixels
* @param x x coordinate of pixel to check
* @param y y coordinate of pixel to check
* @return
* @see <a
* href="https://docs.oracle.com/javase/8/docs/api/java/awt/image/BufferedImage.html#getRGB-int-int-">Javadoc
* BufferedImage</a>
*/
public static boolean isTransparent(BufferedImage image, int x, int y) {
int pixel = image.getRGB(x, y);
return (pixel >> 24) == 0x00;
}

private final ImageSecurityService imageSecurityService;
private final ResolvedFileResourceServiceImpl fileResourceService;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,4 @@ public void testContainsAlphaChannel() throws FileNotFoundException, IOException
result = ImageServiceImpl.containsAlphaChannel(image);
assertEquals(expResult, result);
}

@Test
public void testContainsTransparency() throws FileNotFoundException, IOException {
File file = ResourceUtils.getFile("classpath:test-alpha-transparency-yes.png");
BufferedImage image = ImageIO.read(file);
boolean expResult = true;
boolean result = ImageServiceImpl.containsTransparency(image);
assertEquals(expResult, result);

file = ResourceUtils.getFile("classpath:test-alpha-transparency-no.png");
image = ImageIO.read(file);
expResult = false;
result = ImageServiceImpl.containsTransparency(image);
assertEquals(expResult, result);
}
}

0 comments on commit 1a25cb7

Please sign in to comment.