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);
}
}
use of com.b3dgs.lionengine.graphic.ImageBuffer in project lionengine by b3dgs.
the class FilterBilinear method filter.
/*
* Filter
*/
@Override
public ImageBuffer filter(ImageBuffer source) {
final int width = source.getWidth();
final int height = source.getHeight();
final int[] inPixels = new int[width * height];
final int[] outPixels = new int[width * height];
source.getRgb(0, 0, width, height, inPixels, 0, width);
compute(inPixels, outPixels, width, height, 1);
compute(outPixels, inPixels, height, width, 1);
final ImageBuffer dest = Graphics.createImageBuffer(width, height, source.getTransparentColor());
dest.setRgb(0, 0, width, height, inPixels, 0, width);
return dest;
}
use of com.b3dgs.lionengine.graphic.ImageBuffer in project lionengine by b3dgs.
the class FilterHq2x 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 RawScale2x scaler = new RawScale2x(width, height);
final ImageBuffer image = Graphics.createImageBuffer(width * RawScale2x.SCALE, height * RawScale2x.SCALE, source.getTransparentColor());
image.setRgb(0, 0, width * RawScale2x.SCALE, height * RawScale2x.SCALE, scaler.getScaledData(srcData), 0, width * RawScale2x.SCALE);
return image;
}
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;
}
use of com.b3dgs.lionengine.graphic.ImageBuffer in project lionengine by b3dgs.
the class GraphicsTest method testSplitImage.
/**
* Test split image.
*/
@Test
public void testSplitImage() {
final ImageBuffer[] split = Graphics.splitImage(image, 2, 2);
for (final ImageBuffer img1 : split) {
for (final ImageBuffer img2 : split) {
Assert.assertEquals(img1.getWidth(), img2.getWidth());
Assert.assertEquals(img1.getHeight(), img2.getHeight());
}
}
Assert.assertEquals(image.getWidth() / 2, split[0].getWidth());
Assert.assertEquals(image.getHeight() / 2, split[0].getHeight());
for (final ImageBuffer image : split) {
image.dispose();
}
}
Aggregations