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 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);
}
}
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;
}
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;
}
}
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;
}
Aggregations