use of com.b3dgs.lionengine.graphic.ImageBuffer in project lionengine by b3dgs.
the class ImageBufferAwtTest method testImageTransparency.
/**
* Test image transparency
*/
@Test
void testImageTransparency() {
final ImageBuffer image = Graphics.createImageBuffer(100, 100, ColorRgba.RED);
assertEquals(Transparency.BITMASK, image.getTransparency());
assertEquals(ColorRgba.TRANSPARENT, image.getTransparentColor());
image.setRgb(0, 0, ColorRgba.TRANSPARENT.getRgba());
assertEquals(ColorRgba.TRANSPARENT.getRgba(), image.getRgb(0, 0));
}
use of com.b3dgs.lionengine.graphic.ImageBuffer in project lionengine by b3dgs.
the class FactoryGraphicAwt method createImageBuffer.
@Override
public ImageBuffer createImageBuffer(int width, int height) {
final BufferedImage image = ToolsAwt.createImage(width, height, java.awt.Transparency.OPAQUE);
final ImageBuffer buffer = new ImageBufferAwt(image);
final Graphic g = buffer.createGraphic();
g.setColor(ColorRgba.BLACK);
g.drawRect(0, 0, width, height, true);
g.dispose();
return buffer;
}
use of com.b3dgs.lionengine.graphic.ImageBuffer in project lionengine by b3dgs.
the class FactoryGraphicAwt method createImageBufferAlpha.
@Override
public ImageBuffer createImageBufferAlpha(int width, int height) {
final BufferedImage image = ToolsAwt.createImage(width, height, java.awt.Transparency.TRANSLUCENT);
final ImageBuffer buffer = new ImageBufferAwt(image);
final Graphic g = buffer.createGraphic();
g.setColor(ColorRgba.TRANSPARENT);
g.drawRect(0, 0, width, height, true);
g.dispose();
return buffer;
}
use of com.b3dgs.lionengine.graphic.ImageBuffer in project lionengine by b3dgs.
the class FactoryGraphicAwt method splitImage.
@Override
public ImageBuffer[] splitImage(ImageBuffer image, int h, int v) {
Check.notNull(image);
final BufferedImage surface = image.getSurface();
final BufferedImage[] images = ToolsAwt.splitImage(surface, h, v);
final ImageBuffer[] imageBuffers = new ImageBuffer[h * v];
for (int i = 0; i < imageBuffers.length; i++) {
imageBuffers[i] = new ImageBufferAwt(images[i]);
}
return imageBuffers;
}
use of com.b3dgs.lionengine.graphic.ImageBuffer in project lionengine by b3dgs.
the class SpriteParallaxedImpl method load.
/*
* SpriteParallaxed
*/
@Override
public void load(boolean alpha) {
ImageBuffer surface = Graphics.getImageBuffer(media);
if (0 != Double.compare(factorH, 1.0) || 0 != Double.compare(factorV, 1.0)) {
final int x = (int) (surface.getWidth() * factorH);
final int y = (int) (surface.getHeight() * factorV);
surface = Graphics.resize(surface, x, y);
}
lineWidth = (int) Math.floor(surface.getWidth() * sx / 100.0);
lineHeight = (int) Math.floor(surface.getHeight() / (double) linesNumber * sy / 100.0);
lines = Graphics.splitImage(surface, 1, linesNumber);
final double factH = sx / 100.0 / AMPLITUDE_FACTOR;
for (int i = 0; i < linesNumber; i++) {
final int width = (int) Math.ceil(lines[i].getWidth() * (sx + i * 2 * factH) / 100);
final int height = lines[i].getHeight() * sy / 100;
lines[i] = Graphics.resize(lines[i], width, height);
}
}
Aggregations