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, ColorRgba transparency) {
Check.notNull(transparency);
final BufferedImage image = ToolsAwt.createImage(width, height, java.awt.Transparency.BITMASK);
final ImageBuffer buffer = new ImageBufferAwt(image);
final Graphic g = buffer.createGraphic();
g.setColor(transparency);
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 FactoryGraphicAwtTest method testRotate.
/*
* FactoryGraphicTest
*/
@Test
@Override
protected void testRotate() {
final ImageBuffer image = Graphics.getImageBuffer(Medias.create("image.png"));
final ImageBuffer rotate = Graphics.rotate(image, 90);
assertNotEquals(image, rotate);
assertEquals(image.getWidth(), rotate.getHeight());
assertEquals(image.getHeight(), rotate.getWidth());
rotate.dispose();
image.dispose();
}
use of com.b3dgs.lionengine.graphic.ImageBuffer in project lionengine by b3dgs.
the class ImageBufferAwtTest method testImage.
/**
* Test image.
*/
@Test
void testImage() {
final BufferedImage buffer = new BufferedImage(100, 100, BufferedImage.TYPE_INT_RGB);
final ImageBuffer image = ToolsAwt.getImageBuffer(buffer);
assertNotNull(image.createGraphic());
image.prepare();
assertEquals(buffer, image.getSurface());
assertEquals(ColorRgba.BLACK.getRgba(), image.getRgb(0, 0));
assertNotNull(image.getRgb(0, 0, 1, 1, new int[1], 0, 0));
assertEquals(Transparency.OPAQUE, image.getTransparency());
assertEquals(Transparency.OPAQUE, ToolsAwt.getImageBuffer(ToolsAwt.copyImage(buffer)).getTransparency());
assertEquals(buffer.getWidth(), image.getWidth());
assertEquals(buffer.getHeight(), image.getHeight());
image.setRgb(0, 0, ColorRgba.BLUE.getRgba());
assertEquals(ColorRgba.BLUE.getRgba(), image.getRgb(0, 0));
image.setRgb(0, 0, 0, 0, new int[1], 0, 0);
image.dispose();
}
use of com.b3dgs.lionengine.graphic.ImageBuffer in project lionengine by b3dgs.
the class TextAwtTest method beforeTests.
/**
* Setup tests.
*/
@BeforeAll
public static void beforeTests() {
Graphics.setFactoryGraphic(new FactoryGraphicAwt());
final ImageBuffer buffer = Graphics.createImageBuffer(320, 240);
buffer.prepare();
g = buffer.createGraphic();
}
use of com.b3dgs.lionengine.graphic.ImageBuffer in project lionengine by b3dgs.
the class SpriteDigitTest method testHashCode.
/**
* Test hash code.
*/
@Test
void testHashCode() {
final ImageBuffer surface = Graphics.createImageBuffer(64, 32);
final SpriteDigit sprite = new SpriteDigitImpl(surface, 1, 1, 1);
final Media media = Medias.create("image.png");
final SpriteDigit spriteMedia = new SpriteDigitImpl(media, 1, 1, 1);
assertHashEquals(sprite, new SpriteDigitImpl(surface, 1, 1, 1));
assertHashNotEquals(sprite, new Object());
assertHashNotEquals(spriteMedia, new SpriteDigitImpl(media, 1, 1, 1));
assertHashNotEquals(sprite, new SpriteDigitImpl(Graphics.createImageBuffer(64, 32), 1, 1, 1));
assertHashNotEquals(sprite, new SpriteDigitImpl(Graphics.createImageBuffer(32, 32), 1, 1, 1));
assertHashNotEquals(sprite, new SpriteDigitImpl(Graphics.createImageBuffer(64, 64), 1, 1, 1));
assertHashNotEquals(sprite, new SpriteDigitImpl(Graphics.createImageBuffer(32, 64), 1, 1, 1));
sprite.dispose();
spriteMedia.dispose();
surface.dispose();
}
Aggregations