-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add check methods for alpha channel and transparency (inactive by def…
…ault and without further transformation consequences, yet)
- Loading branch information
Showing
5 changed files
with
116 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
src/test/java/de/digitalcollections/iiif/hymir/image/business/ImageServiceImplTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package de.digitalcollections.iiif.hymir.image.business; | ||
|
||
import static org.junit.jupiter.api.Assertions.*; | ||
|
||
import java.awt.image.BufferedImage; | ||
import java.io.File; | ||
import java.io.FileNotFoundException; | ||
import java.io.IOException; | ||
import javax.imageio.ImageIO; | ||
import org.junit.jupiter.api.Test; | ||
import org.springframework.util.ResourceUtils; | ||
|
||
public class ImageServiceImplTest { | ||
|
||
ImageServiceImpl instance = new ImageServiceImpl(null, null); | ||
|
||
@Test | ||
public void testContainsAlphaChannel() throws FileNotFoundException, IOException { | ||
File file = ResourceUtils.getFile("classpath:test-alpha-transparency-yes.png"); | ||
BufferedImage image = ImageIO.read(file); | ||
boolean expResult = true; | ||
boolean result = instance.containsAlphaChannel(image); | ||
assertEquals(expResult, result); | ||
|
||
file = ResourceUtils.getFile("classpath:test-alpha-transparency-no.png"); | ||
image = ImageIO.read(file); | ||
expResult = false; | ||
result = instance.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 = instance.containsTransparency(image); | ||
assertEquals(expResult, result); | ||
|
||
file = ResourceUtils.getFile("classpath:test-alpha-transparency-no.png"); | ||
image = ImageIO.read(file); | ||
expResult = false; | ||
result = instance.containsTransparency(image); | ||
assertEquals(expResult, result); | ||
} | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.