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 rotate.
*/
@Test
@Override
public void testRotate() {
final ImageBuffer rotate = Graphics.rotate(image, 90);
Assert.assertNotEquals(image, rotate);
Assert.assertEquals(image.getWidth(), rotate.getHeight());
Assert.assertEquals(image.getHeight(), rotate.getWidth());
rotate.dispose();
}
use of com.b3dgs.lionengine.graphic.ImageBuffer in project lionengine by b3dgs.
the class ImageBufferAwtTest method testImageTransparency.
/**
* Test image transparency
*/
@Test
public void testImageTransparency() {
final ImageBuffer image = Graphics.createImageBuffer(100, 100, ColorRgba.RED);
Assert.assertEquals(Transparency.BITMASK, image.getTransparency());
Assert.assertEquals(ColorRgba.TRANSPARENT, image.getTransparentColor());
}
use of com.b3dgs.lionengine.graphic.ImageBuffer in project lionengine by b3dgs.
the class TextAwtTest method setUp.
/**
* Setup test.
*/
@BeforeClass
public static void setUp() {
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 LevelRipConverter method checkTile.
/**
* Check tile of sheet.
*
* @param map The destination map reference.
* @param tileSprite The tiled sprite
* @param sheet The sheet number.
* @param x The location x.
* @param y The location y.
* @return The tile found.
*/
private static Tile checkTile(MapTile map, ImageBuffer tileSprite, Integer sheet, int x, int y) {
final int tw = map.getTileWidth();
final int th = map.getTileHeight();
final SpriteTiled tileSheet = map.getSheet(sheet);
final ImageBuffer sheetImage = tileSheet.getSurface();
final int tilesInX = tileSheet.getWidth() / tw;
final int tilesInY = tileSheet.getHeight() / th;
for (int surfaceCurrentTileY = 0; surfaceCurrentTileY < tilesInY; surfaceCurrentTileY++) {
for (int surfaceCurrentTileX = 0; surfaceCurrentTileX < tilesInX; surfaceCurrentTileX++) {
// Tile number on tile sheet
final int number = surfaceCurrentTileX + surfaceCurrentTileY * tilesInX;
// Compare tiles between sheet and image map
final int xa = x * tw;
final int ya = y * th;
final int xb = surfaceCurrentTileX * tw;
final int yb = surfaceCurrentTileY * th;
if (TilesExtractor.compareTile(tw, th, tileSprite, xa, ya, sheetImage, xb, yb)) {
return map.createTile(sheet, number, xa, (map.getInTileHeight() - 1.0 - y) * th);
}
}
}
return null;
}
Aggregations