use of com.b3dgs.lionengine.graphic.ImageBuffer in project lionengine by b3dgs.
the class WorldTest method prepare.
/**
* Prepare test.
*/
@BeforeEach
public void prepare() {
services.add(new Context() {
@Override
public int getX() {
return 0;
}
@Override
public int getY() {
return 0;
}
@Override
public int getWidth() {
return 0;
}
@Override
public int getHeight() {
return 0;
}
@Override
public <T extends InputDevice> T getInputDevice(Class<T> type) {
return null;
}
@Override
public Config getConfig() {
return config;
}
});
services.add(new SourceResolutionProvider() {
@Override
public int getWidth() {
return output.getWidth();
}
@Override
public int getHeight() {
return output.getHeight();
}
@Override
public int getRate() {
return output.getRate();
}
});
services.add(new Sequencer() {
@Override
public void end(Class<? extends Sequencable> nextSequenceClass, Object... arguments) {
// Mock
}
@Override
public void end() {
// Mock
}
@Override
public void load(Class<? extends Sequencable> nextSequenceClass, Object... arguments) {
// Mock
}
@Override
public void setSystemCursorVisible(boolean visible) {
// Mock
}
});
services.add(new Rasterbar() {
@Override
public void setRasterbarY(int y1, int y2) {
// Mock
}
@Override
public void setRasterbarOffset(int offsetY, int factorY) {
// Mock
}
@Override
public void renderRasterbar() {
// Mock
}
@Override
public void clearRasterbarColor() {
// Mock
}
@Override
public void addRasterbarColor(ImageBuffer buffer) {
// Mock
}
});
}
use of com.b3dgs.lionengine.graphic.ImageBuffer in project lionengine by b3dgs.
the class FilterBilinearTest method testBilinear.
/**
* Test bilinear filter
*/
@Test
void testBilinear() {
final Media media = Medias.create("image.png");
final ImageBuffer image = Graphics.getImageBuffer(media);
int i = 0;
for (int y = 0; y < image.getHeight(); y++) {
for (int x = 0; x < image.getWidth(); x++) {
i++;
if (y < 10) {
image.setRgb(x, y, i % 2);
} else if (y < 20) {
image.setRgb(x, y, i % 3);
} else if (y < 32) {
image.setRgb(x, y, i % 5);
}
}
}
final FilterBilinear bilinear = new FilterBilinear();
final ImageBuffer filtered = bilinear.filter(image);
assertNotEquals(image, filtered);
assertNotNull(bilinear.getTransform(1.0, 1.0));
assertEquals(image.getWidth(), filtered.getWidth());
assertEquals(image.getHeight(), filtered.getHeight());
image.dispose();
filtered.dispose();
}
use of com.b3dgs.lionengine.graphic.ImageBuffer in project lionengine by b3dgs.
the class Scene method load.
@Override
public void load() {
final Media levelrip = Medias.create("level.png");
final TilesExtractor tilesExtractor = new TilesExtractor();
final AtomicInteger p = new AtomicInteger();
tilesExtractor.addListener((percent, tiles) -> p.set(percent));
Collection<ImageBuffer> buffers = tilesExtractor.extract(16, 16, Arrays.asList(levelrip));
map.loadSheets(SheetsExtractor.extract(buffers, 16));
buffers.forEach(ImageBuffer::dispose);
assertEquals(100, p.get());
p.set(0);
tilesExtractor.addListener((percent, tiles) -> p.set(percent));
buffers = tilesExtractor.extract(() -> true, 16, 16, Arrays.asList(levelrip));
map.loadSheets(SheetsExtractor.extract(buffers, 16));
buffers.forEach(ImageBuffer::dispose);
assertEquals(0, p.get());
tilesExtractor.addListener((percent, tiles) -> p.set(percent));
buffers = tilesExtractor.extract(() -> false, 16, 16, Arrays.asList(levelrip));
map.loadSheets(SheetsExtractor.extract(buffers, 16));
buffers.forEach(ImageBuffer::dispose);
assertEquals(100, p.get());
p.set(0);
LevelRipConverter.start(levelrip, map, (percent, progressTileX, progressTileY) -> p.set(percent));
assertEquals(100, p.get());
mapViewer.prepare(map);
minimap.load();
minimap.automaticColor();
minimap.prepare();
camera.setView(0, 0, getWidth(), getHeight(), getHeight());
camera.setLimits(map);
tick.start();
}
use of com.b3dgs.lionengine.graphic.ImageBuffer in project lionengine by b3dgs.
the class FilterBlurTest method testParam.
/**
* Test with single pixel.
*
* @param width The width.
* @param height The height.
*/
@ParameterizedTest
@CsvSource({ "5,5", "5,8", "8,5" })
void testParam(int width, int height) {
final FilterBlur blur = new FilterBlur();
final ImageBuffer image = Graphics.createImageBuffer(width, height);
final ImageBuffer filtered = blur.filter(image);
assertNotEquals(image, filtered);
image.dispose();
filtered.dispose();
}
use of com.b3dgs.lionengine.graphic.ImageBuffer in project lionengine by b3dgs.
the class FilterHq3xTest method testHq3x.
/**
* Test filter.
*/
@Test
void testHq3x() {
final Media media = Medias.create("image.png");
final ImageBuffer image = Graphics.getImageBuffer(media);
int i = 0;
for (int y = 0; y < image.getHeight(); y++) {
for (int x = 0; x < image.getWidth(); x++) {
i++;
if (y < 10) {
image.setRgb(x, y, i % 2);
} else if (y < 20) {
image.setRgb(x, y, i % 3);
} else if (y < 32) {
image.setRgb(x, y, i % 5);
}
}
}
final FilterHq3x hq3x = new FilterHq3x();
final ImageBuffer filtered = hq3x.filter(image);
assertNotEquals(image, filtered);
assertNotNull(hq3x.getTransform(1.0, 1.0));
assertEquals(image.getWidth() * 3, filtered.getWidth());
assertEquals(image.getHeight() * 3, filtered.getHeight());
image.dispose();
filtered.dispose();
}
Aggregations