use of com.b3dgs.lionengine.graphic.ImageBuffer in project lionengine by b3dgs.
the class MapTileRasteredModel method loadSheets.
/*
* MapTileRastered
*/
@Override
public void loadSheets(Media rasterConfig, boolean smooth) {
final Collection<Integer> sheets = map.getSheets();
final Iterator<Integer> itr = sheets.iterator();
final int th = map.getTileHeight();
while (itr.hasNext()) {
final Integer sheet = itr.next();
final RasterImage raster = new RasterImage(map.getSheet(sheet).getSurface(), rasterConfig, th, smooth);
raster.loadRasters(map.getTileHeight(), false, sheet.toString());
final List<SpriteTiled> rastersSheet = getRasters(sheet);
for (final ImageBuffer bufferRaster : raster.getRasters()) {
final SpriteTiled sheetRaster = Drawable.loadSpriteTiled(bufferRaster, map.getTileWidth(), th);
rastersSheet.add(sheetRaster);
}
}
}
use of com.b3dgs.lionengine.graphic.ImageBuffer in project lionengine by b3dgs.
the class SpriteTiledTest method testEquals.
/**
* Test equals.
*/
@Test
public void testEquals() {
final ImageBuffer surface = Graphics.createImageBuffer(64, 32);
final SpriteTiled sprite = new SpriteTiledImpl(surface, 16, 8);
final SpriteTiled spriteMedia = new SpriteTiledImpl(media, 16, 8);
spriteMedia.load();
Assert.assertEquals(sprite, sprite);
Assert.assertEquals(sprite, new SpriteTiledImpl(surface, 16, 8));
Assert.assertEquals(spriteMedia, spriteMedia);
Assert.assertNotEquals(sprite, null);
Assert.assertNotEquals(sprite, new Object());
Assert.assertNotEquals(sprite, new SpriteTiledImpl(media, 16, 8));
Assert.assertNotEquals(spriteMedia, new SpriteTiledImpl(media, 16, 8));
Assert.assertNotEquals(sprite, new SpriteTiledImpl(surface, 16, 16));
Assert.assertNotEquals(sprite, new SpriteTiledImpl(Graphics.createImageBuffer(64, 32), 16, 8));
Assert.assertNotEquals(sprite, new SpriteTiledImpl(Graphics.createImageBuffer(32, 32), 16, 8));
Assert.assertNotEquals(sprite, new SpriteTiledImpl(Graphics.createImageBuffer(64, 64), 16, 8));
Assert.assertNotEquals(sprite, new SpriteTiledImpl(Graphics.createImageBuffer(32, 64), 16, 8));
Assert.assertNotEquals(sprite, new SpriteTiledImpl(Graphics.createImageBuffer(64, 32), 8, 8));
Assert.assertNotEquals(sprite, new SpriteTiledImpl(Graphics.createImageBuffer(64, 32), 16, 16));
Assert.assertNotEquals(sprite, new SpriteTiledImpl(Graphics.createImageBuffer(32, 32), 8, 8));
Assert.assertNotEquals(sprite, new SpriteTiledImpl(Graphics.createImageBuffer(64, 64), 16, 16));
}
use of com.b3dgs.lionengine.graphic.ImageBuffer in project lionengine by b3dgs.
the class FilterBilinearTest method testBilinear.
/**
* Test bilinear filter
*/
@Test
public void testBilinear() {
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 FilterBilinear bilinear = new FilterBilinear();
final ImageBuffer filtered = bilinear.filter(image);
Assert.assertNotEquals(image, filtered);
Assert.assertNotNull(bilinear.getTransform(1.0, 1.0));
Assert.assertEquals(image.getWidth(), filtered.getWidth());
Assert.assertEquals(image.getHeight(), filtered.getHeight());
}
use of com.b3dgs.lionengine.graphic.ImageBuffer in project lionengine by b3dgs.
the class FilterBlurTest method testNoPixel.
/**
* Test without pixel.
*/
@Test
public void testNoPixel() {
final FilterBlur blur = new FilterBlur();
final ImageBuffer image = Graphics.createImageBuffer(0, 0);
final ImageBuffer filtered = blur.filter(image);
Assert.assertNotNull(filtered);
Assert.assertEquals(image.getWidth(), filtered.getWidth());
Assert.assertEquals(image.getHeight(), filtered.getHeight());
}
use of com.b3dgs.lionengine.graphic.ImageBuffer in project lionengine by b3dgs.
the class FilterHq2xTest method testHq2x.
/**
* Test filter.
*/
@Test
public void testHq2x() {
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 FilterHq2x hq2x = new FilterHq2x();
final ImageBuffer filtered = hq2x.filter(image);
Assert.assertNotEquals(image, filtered);
Assert.assertNotNull(hq2x.getTransform(1.0, 1.0));
Assert.assertEquals(image.getWidth() * 2, filtered.getWidth());
Assert.assertEquals(image.getHeight() * 2, filtered.getHeight());
}
Aggregations