Merge master.
This commit is contained in:
@@ -5,27 +5,41 @@ import java.awt.Image;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.DataInputStream;
|
||||
|
||||
import org.insa.graphics.drawing.Drawing.AlphaMode;
|
||||
|
||||
public class MarkerUtils {
|
||||
|
||||
/**
|
||||
* Create an Image representing a marker of the given color.
|
||||
* Create an image to represent a marker using the given color for the outer and
|
||||
* inner part, and the given mode for the inner part.
|
||||
*
|
||||
* @param color Color of the marker.
|
||||
* @param outer Outer color of the marker.
|
||||
* @param inner Inner color of the marker.
|
||||
* @param mode Mode to use to fill the inner part of the marker.
|
||||
*
|
||||
* @return A new Image representing a marker with the given color.
|
||||
* @return An image representing a marker.
|
||||
*
|
||||
* @see MarkerUtils#getMarkerForColor(Color, AlphaMode)
|
||||
*/
|
||||
public static Image getMarkerForColor(Color color) {
|
||||
public static Image getMarkerForColor(Color outer, Color inner, AlphaMode mode) {
|
||||
// create image
|
||||
int[][] mask = readMarkerMask();
|
||||
BufferedImage image = new BufferedImage(mask[0].length, mask.length,
|
||||
BufferedImage.TYPE_4BYTE_ABGR);
|
||||
|
||||
// Color[] map = getColorMapping(color);
|
||||
int rgb = color.getRGB() & 0x00ffffff;
|
||||
int outerRGB = outer.getRGB() & 0x00ffffff;
|
||||
int innerRGB = inner.getRGB() & 0x00ffffff;
|
||||
for (int i = 0; i < image.getHeight(); ++i) {
|
||||
for (int j = 0; j < image.getWidth(); ++j) {
|
||||
// image.setRGB(j, i, map[MARKER_MASK[i][j]].getRGB());
|
||||
image.setRGB(j, i, rgb | (mask[i][j] << 24));
|
||||
if (i >= MIN_Y_CENTER && i < MAX_Y_CENTER && j >= MIN_X_CENTER
|
||||
&& j < MAX_X_CENTER) {
|
||||
image.setRGB(j, i, innerRGB
|
||||
| ((mode == AlphaMode.OPAQUE ? MAXIMUM_MAX_VALUE : mask[i][j]) << 24));
|
||||
}
|
||||
else {
|
||||
image.setRGB(j, i, outerRGB | (mask[i][j] << 24));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,6 +49,12 @@ public class MarkerUtils {
|
||||
// Mask cache
|
||||
private static int[][] MASK_CACHE = null;
|
||||
|
||||
// Hand-made... These defines the "center" of the marker, that can be filled
|
||||
// with a different color.
|
||||
private static final int MIN_X_CENTER = 40, MAX_X_CENTER = 101, MIN_Y_CENTER = 40,
|
||||
MAX_Y_CENTER = 100;
|
||||
private static final int MAXIMUM_MAX_VALUE = 249;
|
||||
|
||||
/**
|
||||
* @return Retrieve the mask from the mask file or from the cache.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user