use of com.b3dgs.lionengine.graphic.ImageBuffer in project lionengine by b3dgs.
the class RasterImage method loadRasters.
/**
* Load rasters.
*
* @param imageHeight The local image height.
* @param save <code>true</code> to save generated (if) rasters, <code>false</code> else.
* @param prefix The folder prefix, if save is <code>true</code> (must not be <code>null</code>).
* @throws LionEngineException If the raster data from the media are invalid.
*/
public void loadRasters(int imageHeight, boolean save, String prefix) {
Check.notNull(prefix);
final Raster raster = Raster.load(rasterFile);
final int max = UtilConversion.boolToInt(rasterSmooth) + 1;
for (int m = 0; m < max; m++) {
for (int i = 1; i <= RasterColor.MAX_RASTERS; i++) {
final String folder = prefix + Constant.UNDERSCORE + UtilFile.removeExtension(rasterFile.getName());
final String file = String.valueOf(i + m * RasterColor.MAX_RASTERS) + Constant.DOT + ImageFormat.PNG;
final Media rasterMedia = Medias.create(rasterFile.getParentPath(), folder, file);
final ImageBuffer rasterBuffer = createRaster(rasterMedia, raster, m, i, imageHeight, save);
rasters.add(rasterBuffer);
}
}
}
use of com.b3dgs.lionengine.graphic.ImageBuffer in project lionengine by b3dgs.
the class FilterBlur method filter.
/*
* Filter
*/
@Override
public ImageBuffer filter(ImageBuffer source) {
final int width = source.getWidth();
final int height = source.getHeight();
if (width < MIN_SIZE || height < MIN_SIZE) {
return source;
}
final int[] inPixels = new int[width * height];
final int[] outPixels = new int[width * height];
source.getRgb(0, 0, width, height, inPixels, 0, width);
final Kernel kernel = createKernel(radius, width, height);
compute(kernel, inPixels, outPixels, width, height, alpha, edge);
compute(kernel, outPixels, inPixels, height, width, alpha, edge);
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 GraphicsTest method testCreateImageBuffer.
/**
* Test create image buffer.
*/
@Test
public void testCreateImageBuffer() {
final ImageBuffer imageBuffer = Graphics.createImageBuffer(16, 32);
Assert.assertEquals(16, imageBuffer.getWidth());
Assert.assertEquals(32, imageBuffer.getHeight());
imageBuffer.dispose();
}
use of com.b3dgs.lionengine.graphic.ImageBuffer in project lionengine by b3dgs.
the class GraphicsTest method testGetImageBufferFromMedia.
/**
* Test get image buffer from media.
*/
@Test
public void testGetImageBufferFromMedia() {
final ImageBuffer imageA = Graphics.getImageBuffer(mediaImage);
final ImageBuffer imageB = Graphics.getImageBuffer(mediaImage);
Assert.assertNotEquals(imageA, imageB);
Assert.assertEquals(imageB.getWidth(), imageA.getWidth());
Assert.assertEquals(imageB.getHeight(), imageA.getHeight());
imageA.dispose();
imageB.dispose();
}
use of com.b3dgs.lionengine.graphic.ImageBuffer in project lionengine by b3dgs.
the class GraphicsTest method testGetImageBufferFromImage.
/**
* Test get image buffer from image.
*/
@Test
public void testGetImageBufferFromImage() {
final ImageBuffer imageBuffer = Graphics.createImageBuffer(16, 32);
final ImageBuffer copy = Graphics.getImageBuffer(imageBuffer);
Assert.assertEquals(imageBuffer.getWidth(), copy.getWidth());
Assert.assertEquals(imageBuffer.getHeight(), copy.getHeight());
imageBuffer.dispose();
copy.dispose();
}
Aggregations