use of com.b3dgs.lionengine.graphic.ImageBuffer in project lionengine by b3dgs.
the class Minimap method computeSheet.
/**
* Compute the current sheet.
*
* @param colors The colors data.
* @param sheet The sheet number.
*/
private void computeSheet(Map<TileRef, ColorRgba> colors, Integer sheet) {
final SpriteTiled tiles = map.getSheet(sheet);
final ImageBuffer tilesSurface = tiles.getSurface();
final int tw = map.getTileWidth();
final int th = map.getTileHeight();
int number = 0;
for (int i = 0; i < tilesSurface.getWidth(); i += tw) {
for (int j = 0; j < tilesSurface.getHeight(); j += th) {
final int h = number * tw % tiles.getWidth();
final int v = number / tiles.getTilesHorizontal() * th;
final ColorRgba color = UtilColor.getWeightedColor(tilesSurface, h, v, tw, th);
if (!(NO_TILE.equals(color) || color.getAlpha() == 0)) {
colors.put(new TileRef(sheet, number), color);
}
number++;
}
}
}
use of com.b3dgs.lionengine.graphic.ImageBuffer in project lionengine by b3dgs.
the class SpriteTiledTest method testConstructorSurface.
/**
* Test constructor with surface.
*/
@Test
public void testConstructorSurface() {
final ImageBuffer surface = Graphics.createImageBuffer(64, 32);
final SpriteTiled sprite = new SpriteTiledImpl(surface, 16, 8);
Assert.assertTrue(sprite.isLoaded());
Assert.assertEquals(surface, sprite.getSurface());
Assert.assertEquals(64, sprite.getWidth());
Assert.assertEquals(32, sprite.getHeight());
Assert.assertEquals(16, sprite.getTileWidth());
Assert.assertEquals(8, sprite.getTileHeight());
Assert.assertEquals(4, sprite.getTilesHorizontal());
Assert.assertEquals(4, sprite.getTilesVertical());
}
use of com.b3dgs.lionengine.graphic.ImageBuffer in project lionengine by b3dgs.
the class FilterBlurTest method testLowHeight.
/**
* Test with low height.
*/
@Test
public void testLowHeight() {
final FilterBlur blur = new FilterBlur();
final ImageBuffer image = Graphics.createImageBuffer(3, 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 FilterBlurTest method testLowWidth.
/**
* Test with low width.
*/
@Test
public void testLowWidth() {
final FilterBlur blur = new FilterBlur();
final ImageBuffer image = Graphics.createImageBuffer(1, 3);
final ImageBuffer filtered = blur.filter(image);
Assert.assertEquals(image, filtered);
}
use of com.b3dgs.lionengine.graphic.ImageBuffer in project lionengine by b3dgs.
the class FilterBlurTest method testBlur.
/**
* Test blur filter
*/
@Test
public void testBlur() {
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 FilterBlur blur = new FilterBlur();
final ImageBuffer filtered = blur.filter(image);
Assert.assertNotEquals(image, filtered);
Assert.assertNotNull(blur.getTransform(1.0, 1.0));
Assert.assertEquals(image.getWidth(), filtered.getWidth());
Assert.assertEquals(image.getHeight(), filtered.getHeight());
blur.setAlpha(false);
Assert.assertNotNull(blur.filter(image));
blur.setEdgeMode(FilterBlur.WRAP_EDGES);
Assert.assertNotNull(blur.filter(image));
blur.setRadius(1.0f);
Assert.assertNotNull(blur.filter(image));
}
Aggregations