Search in sources :

Example 36 with ImageBuffer

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

the class FactoryGraphicHeadless method createImageBufferAlpha.

@Override
public ImageBuffer createImageBufferAlpha(int width, int height) {
    final ImageBuffer buffer = new ImageBufferHeadless(width, height, Transparency.TRANSLUCENT);
    final Graphic g = buffer.createGraphic();
    g.setColor(ColorRgba.TRANSPARENT);
    g.drawRect(0, 0, width, height, true);
    g.dispose();
    return buffer;
}
Also used : ImageBuffer(com.b3dgs.lionengine.graphic.ImageBuffer) Graphic(com.b3dgs.lionengine.graphic.Graphic) FactoryGraphic(com.b3dgs.lionengine.graphic.FactoryGraphic)

Example 37 with ImageBuffer

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

the class FactoryGraphicHeadless method flipHorizontal.

@Override
public ImageBuffer flipHorizontal(ImageBuffer image) {
    Check.notNull(image);
    final ImageBuffer flip = new ImageBufferHeadless((ImageBufferHeadless) image);
    final int height = flip.getHeight();
    final int width = flip.getWidth();
    for (int y = 0; y < height; y++) {
        for (int x = 0; x < width; x++) {
            final int rgba = flip.getRgb(x, y);
            flip.setRgb(width - x - 1, y, rgba);
        }
    }
    return flip;
}
Also used : ImageBuffer(com.b3dgs.lionengine.graphic.ImageBuffer)

Example 38 with ImageBuffer

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

the class FactoryGraphicHeadless method applyMask.

@Override
public ImageBuffer applyMask(ImageBuffer image, ColorRgba maskColor) {
    Check.notNull(image);
    Check.notNull(maskColor);
    final ImageBuffer mask = new ImageBufferHeadless((ImageBufferHeadless) image);
    final int height = mask.getHeight();
    final int width = mask.getWidth();
    final int rgba = maskColor.getRgba();
    for (int y = 0; y < height; y++) {
        for (int x = 0; x < width; x++) {
            final int col = mask.getRgb(x, y);
            final int flag = 0x00_FF_FF_FF;
            if (col == rgba) {
                mask.setRgb(x, y, col & flag);
            }
        }
    }
    return mask;
}
Also used : ImageBuffer(com.b3dgs.lionengine.graphic.ImageBuffer)

Example 39 with ImageBuffer

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

the class FactoryGraphicHeadless method flipVertical.

@Override
public ImageBuffer flipVertical(ImageBuffer image) {
    Check.notNull(image);
    final ImageBuffer flip = new ImageBufferHeadless((ImageBufferHeadless) image);
    final int height = flip.getHeight();
    final int width = flip.getWidth();
    for (int y = 0; y < height; y++) {
        for (int x = 0; x < width; x++) {
            final int rgba = flip.getRgb(x, y);
            flip.setRgb(x, height - y - 1, rgba);
        }
    }
    return flip;
}
Also used : ImageBuffer(com.b3dgs.lionengine.graphic.ImageBuffer)

Example 40 with ImageBuffer

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

the class FactoryGraphicHeadless method createImageBuffer.

@Override
public ImageBuffer createImageBuffer(int width, int height, ColorRgba transparency) {
    Check.notNull(transparency);
    final ImageBuffer buffer = new ImageBufferHeadless(width, height, Transparency.BITMASK);
    final Graphic g = buffer.createGraphic();
    g.setColor(transparency);
    g.drawRect(0, 0, width, height, true);
    g.dispose();
    return buffer;
}
Also used : ImageBuffer(com.b3dgs.lionengine.graphic.ImageBuffer) Graphic(com.b3dgs.lionengine.graphic.Graphic) FactoryGraphic(com.b3dgs.lionengine.graphic.FactoryGraphic)

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