Search in sources :

Example 51 with ImageBuffer

use of com.b3dgs.lionengine.graphic.ImageBuffer in project lionengine by b3dgs.

the class FilterHq3x method filter.

/*
     * Filter
     */
@Override
public ImageBuffer filter(ImageBuffer source) {
    final int width = source.getWidth();
    final int height = source.getHeight();
    final int[] srcData = new int[width * height];
    source.getRgb(0, 0, width, height, srcData, 0, width);
    final RawScale3x scaler = new RawScale3x(width, height);
    final ImageBuffer image = Graphics.createImageBuffer(width * RawScale3x.SCALE, height * RawScale3x.SCALE, source.getTransparentColor());
    image.setRgb(0, 0, width * RawScale3x.SCALE, height * RawScale3x.SCALE, scaler.getScaledData(srcData), 0, width * RawScale3x.SCALE);
    return image;
}
Also used : ImageBuffer(com.b3dgs.lionengine.graphic.ImageBuffer)

Example 52 with ImageBuffer

use of com.b3dgs.lionengine.graphic.ImageBuffer in project lionengine by b3dgs.

the class MapTileCollisionRendererModel method createCollisionDraw.

@Override
public void createCollisionDraw() {
    clearCollisionDraw();
    final Collection<CollisionFormula> formulas = mapCollision.getCollisionFormulas();
    collisionCache = new HashMap<>(formulas.size());
    for (final CollisionFormula collision : formulas) {
        final ImageBuffer buffer = createFunctionDraw(collision, map.getTileWidth(), map.getTileHeight());
        collisionCache.put(collision, buffer);
    }
}
Also used : ImageBuffer(com.b3dgs.lionengine.graphic.ImageBuffer)

Example 53 with ImageBuffer

use of com.b3dgs.lionengine.graphic.ImageBuffer in project lionengine by b3dgs.

the class MapTileCollisionRendererModel method createFunctionDraw.

/**
 * Create the function draw to buffer.
 *
 * @param collision The collision reference.
 * @param tw The tile width.
 * @param th The tile height.
 * @return The created collision representation buffer.
 */
public static ImageBuffer createFunctionDraw(CollisionFormula collision, int tw, int th) {
    final ImageBuffer buffer = Graphics.createImageBuffer(tw, th, ColorRgba.TRANSPARENT);
    final Graphic g = buffer.createGraphic();
    g.setColor(ColorRgba.PURPLE);
    createFunctionDraw(g, collision, tw, th);
    g.dispose();
    return buffer;
}
Also used : ImageBuffer(com.b3dgs.lionengine.graphic.ImageBuffer) Graphic(com.b3dgs.lionengine.graphic.Graphic)

Example 54 with ImageBuffer

use of com.b3dgs.lionengine.graphic.ImageBuffer in project lionengine by b3dgs.

the class MapTileCollisionRendererModel method clearCollisionDraw.

@Override
public void clearCollisionDraw() {
    if (collisionCache != null) {
        for (final ImageBuffer buffer : collisionCache.values()) {
            buffer.dispose();
        }
        collisionCache.clear();
        collisionCache = null;
    }
}
Also used : ImageBuffer(com.b3dgs.lionengine.graphic.ImageBuffer)

Example 55 with ImageBuffer

use of com.b3dgs.lionengine.graphic.ImageBuffer in project lionengine by b3dgs.

the class RasterImage method createRaster.

/**
 * Create raster from data or load from cache.
 *
 * @param rasterMedia The raster media.
 * @param raster The raster data.
 * @param m The smooth index.
 * @param i The raster index.
 * @param imageHeight The image height.
 * @param save <code>true</code> to save generated raster, <code>false</code> else.
 * @return The created raster.
 */
private ImageBuffer createRaster(Media rasterMedia, Raster raster, int m, int i, int imageHeight, boolean save) {
    final ImageBuffer rasterBuffer;
    if (rasterMedia.exists()) {
        rasterBuffer = Graphics.getImageBuffer(rasterMedia);
        rasterBuffer.prepare();
    } else {
        final RasterColor red = RasterColor.load(raster.getRed(), m, i, rasterSmooth);
        final RasterColor green = RasterColor.load(raster.getGreen(), m, i, rasterSmooth);
        final RasterColor blue = RasterColor.load(raster.getBlue(), m, i, rasterSmooth);
        rasterBuffer = Graphics.getRasterBuffer(surface, red.getStart(), green.getStart(), blue.getStart(), red.getEnd(), green.getEnd(), blue.getEnd(), imageHeight);
        if (save) {
            Graphics.saveImage(rasterBuffer, rasterMedia);
        }
    }
    return rasterBuffer;
}
Also used : ImageBuffer(com.b3dgs.lionengine.graphic.ImageBuffer) RasterColor(com.b3dgs.lionengine.graphic.RasterColor)

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