use of com.b3dgs.lionengine.graphic.ImageBuffer in project lionengine by b3dgs.
the class FilterBlurTest method testSinglePixel.
/**
* Test with single pixel.
*/
@Test
public void testSinglePixel() {
final FilterBlur blur = new FilterBlur();
final ImageBuffer image = Graphics.createImageBuffer(1, 1);
final ImageBuffer filtered = blur.filter(image);
Assert.assertEquals(image, filtered);
}
use of com.b3dgs.lionengine.graphic.ImageBuffer in project lionengine by b3dgs.
the class FilterHq3xTest method testHq3x.
/**
* Test filter.
*/
@Test
public void testHq3x() {
final ImageBuffer image = Graphics.getImageBuffer(media);
int i = 0;
for (int y = 0; y < image.getHeight(); y++) {
for (int x = 0; x < image.getWidth(); x++) {
i++;
if (y < 10) {
image.setRgb(x, y, i % 2);
} else if (y < 20) {
image.setRgb(x, y, i % 3);
} else if (y < 32) {
image.setRgb(x, y, i % 5);
}
}
}
final FilterHq3x hq3x = new FilterHq3x();
final ImageBuffer filtered = hq3x.filter(image);
Assert.assertNotEquals(image, filtered);
Assert.assertNotNull(hq3x.getTransform(1.0, 1.0));
Assert.assertEquals(image.getWidth() * 3, filtered.getWidth());
Assert.assertEquals(image.getHeight() * 3, filtered.getHeight());
}
use of com.b3dgs.lionengine.graphic.ImageBuffer in project lionengine by b3dgs.
the class FactoryGraphicAwt method splitImage.
@Override
public ImageBuffer[] splitImage(ImageBuffer image, int h, int v) {
Check.notNull(image);
final BufferedImage surface = image.getSurface();
final BufferedImage[] images = ToolsAwt.splitImage(surface, h, v);
final ImageBuffer[] imageBuffers = new ImageBuffer[h * v];
for (int i = 0; i < imageBuffers.length; i++) {
imageBuffers[i] = new ImageBufferAwt(images[i]);
}
return imageBuffers;
}
use of com.b3dgs.lionengine.graphic.ImageBuffer in project lionengine by b3dgs.
the class FactoryGraphicAwt method createImageBuffer.
@Override
public ImageBuffer createImageBuffer(int width, int height) {
final BufferedImage image = ToolsAwt.createImage(width, height, java.awt.Transparency.OPAQUE);
final ImageBuffer buffer = new ImageBufferAwt(image);
final Graphic g = buffer.createGraphic();
g.setColor(ColorRgba.BLACK);
g.drawRect(0, 0, width, height, true);
g.dispose();
return buffer;
}
use of com.b3dgs.lionengine.graphic.ImageBuffer in project lionengine by b3dgs.
the class ImageBufferAwtTest method testImage.
/**
* Test image.
*/
@Test
public void testImage() {
final BufferedImage buffer = new BufferedImage(100, 100, BufferedImage.TYPE_INT_RGB);
final ImageBuffer image = ToolsAwt.getImageBuffer(buffer);
Assert.assertNotNull(image.createGraphic());
image.prepare();
Assert.assertEquals(buffer, image.getSurface());
Assert.assertEquals(ColorRgba.BLACK.getRgba(), image.getRgb(0, 0));
Assert.assertNotNull(image.getRgb(0, 0, 1, 1, new int[1], 0, 0));
Assert.assertEquals(Transparency.OPAQUE, image.getTransparency());
Assert.assertEquals(Transparency.OPAQUE, ToolsAwt.getImageBuffer(ToolsAwt.copyImage(buffer)).getTransparency());
Assert.assertEquals(buffer.getWidth(), image.getWidth());
Assert.assertEquals(buffer.getHeight(), image.getHeight());
image.setRgb(0, 0, ColorRgba.BLUE.getRgba());
Assert.assertEquals(ColorRgba.BLUE.getRgba(), image.getRgb(0, 0));
image.setRgb(0, 0, 0, 0, new int[1], 0, 0);
image.dispose();
}
Aggregations