Search in sources :

Example 71 with ImageBuffer

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);
        }
    }
}
Also used : ImageBuffer(com.b3dgs.lionengine.graphic.ImageBuffer) SpriteTiled(com.b3dgs.lionengine.graphic.SpriteTiled) RasterImage(com.b3dgs.lionengine.core.RasterImage)

Example 72 with ImageBuffer

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));
}
Also used : ImageBuffer(com.b3dgs.lionengine.graphic.ImageBuffer) SpriteTiled(com.b3dgs.lionengine.graphic.SpriteTiled) Test(org.junit.Test)

Example 73 with ImageBuffer

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());
}
Also used : ImageBuffer(com.b3dgs.lionengine.graphic.ImageBuffer) Test(org.junit.Test)

Example 74 with ImageBuffer

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());
}
Also used : ImageBuffer(com.b3dgs.lionengine.graphic.ImageBuffer) Test(org.junit.Test)

Example 75 with ImageBuffer

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());
}
Also used : ImageBuffer(com.b3dgs.lionengine.graphic.ImageBuffer) Test(org.junit.Test)

Aggregations

ImageBuffer (com.b3dgs.lionengine.graphic.ImageBuffer)110 Test (org.junit.Test)34 Test (org.junit.jupiter.api.Test)28 Media (com.b3dgs.lionengine.Media)16 Graphic (com.b3dgs.lionengine.graphic.Graphic)12 GraphicTest (com.b3dgs.lionengine.graphic.GraphicTest)12 FactoryGraphic (com.b3dgs.lionengine.graphic.FactoryGraphic)9 BufferedImage (java.awt.image.BufferedImage)9 SpriteTiled (com.b3dgs.lionengine.graphic.SpriteTiled)6 SpriteTiled (com.b3dgs.lionengine.graphic.drawable.SpriteTiled)5 ColorRgba (com.b3dgs.lionengine.graphic.ColorRgba)3 FactoryGraphicTest (com.b3dgs.lionengine.graphic.FactoryGraphicTest)3 Image (com.b3dgs.lionengine.graphic.Image)3 Sprite (com.b3dgs.lionengine.graphic.Sprite)3 SpriteAnimated (com.b3dgs.lionengine.graphic.SpriteAnimated)3 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)3 TilesExtractor (com.b3dgs.lionengine.game.feature.tile.TilesExtractor)2 ArrayList (java.util.ArrayList)2 BeforeAll (org.junit.jupiter.api.BeforeAll)2 Config (com.b3dgs.lionengine.Config)1