MosaicBuilder
Mosaic made of square image tiles. Each pixel of the input image is replaced by a tile.
Add the .jar file in your project.
MosaicBuilder.jar (Library JAR file.).
Library under development!
Comming soon:
- Full multi-thread processing.
- DeltaE color difference algorithm.
- Better tile placement algorithm, to avoid sequencial repetition.
- Graphic interface implementation (for non-programmer users).
Packs
MegaPack.zip (over 12.000 50x50 tiles).
DayZPack.zip (over 1.200 50x50 dayz-themed tiles).
TW3Pack.zip (over 1.200 50x50 the-witcher-3-themed tiles).
Samples
Using MegaPack
Guerrero, Flamengo's striker.
DayZ's most famous image.
Computer Science Institute - UFF
Using TW3Pack
Geralt de Rivia
Usage
Constructor
MosaicBuilder mosaicBuilder = new MosaicBuilder(tilePath, inputImagePath, tileDimension);
tilePath
folder containing tiles.
inputImagePath
path of the inputImage.
tileDimen
Dimension of the tile. (e.g 50x50, 60x60, 40x40, ...).
Listener(Callback interface)
public interface MosaicBuilderListener{
public void onMosaicFinished(BufferedImage img);
public void onProgressChanged(int status);
}
public void onMosaicFinished(BufferedImage img);
is called when final image is done.
public void onProgressChanged(int status);
is called when the progress changes (e.g, init -> loading inputImage to memory).
Progress Status static constants
public static final int READING_INPUT_IMAGE_INTO_MEMORY;
public static final int READING_TILES_INTO_MEMORY;
public static final int SELECTING_TILES;
public static final int BUILDING_OUTPUT_IMAGE;
Exceptions
public class InvalidInputImagePath
public class InvalidOutputImagePath
public class InvalidTileFolderPath
Example
String tilePath = "D:\\SomeFolder\\my_pack_50x50";
String inputImagePath = "D:\\SomeFolder\\inputImage.jpg";
final String finalPath = "D:\\SomeFolder\\outPutImage.png";
int tileDimension = 50;
MosaicBuilder mosaicBuilder = new MosaicBuilder(tilePath, inputImagePath, tileDimension);
mosaicBuilder.setListener(new MosaicBuilder.MosaicBuilderListener() {
@Override
public void onMosaicFinished(BufferedImage img) {
try {
ImageIO.write(img, "png", new File(finalPath));
} catch (IOException ex) {
//TODO
//Warn user, etc...
}
}
@Override
public void onProgressChanged(int status) {
switch (status){
case MosaicBuilder.BUILDING_OUTPUT_IMAGE:
System.out.println("Building final image...");
break;
case MosaicBuilder.READING_INPUT_IMAGE_INTO_MEMORY:
System.out.println("Reading input image into memory...");
break;
case MosaicBuilder.READING_TILES_INTO_MEMORY:
System.out.println("Reading tiles into memory...");
break;
case MosaicBuilder.SELECTING_TILES:
System.out.println("Selecting best tiles for each input image's pixel...");
break;
}
}
});
try{
mosaicBuilder.build();
}catch(InvalidInputImagePath e){
//Show to user that somenthing gone wrong.
System.out.println("Invalid input path: " + inputImagePath);
}catch(InvalidTileFolderPath e){
//Show to user that somenthing gone wrong.
System.out.println("Invalid tile folder path: " + tilePath);
}
Developed by
Max Fratane