Skip to content
Snippets Groups Projects
Commit 399abb1d authored by Tuukka Lehtonen's avatar Tuukka Lehtonen
Browse files

Implement ImageDescriptor.getImageData(int zoom)

gitlab #228

Change-Id: I0b0294a8a48d6d633c452fee780be502f4d58406
parent 662ee6d0
Branches
Tags
No related merge requests found
...@@ -36,8 +36,24 @@ public class ColorImageDescriptor extends ImageDescriptor { ...@@ -36,8 +36,24 @@ public class ColorImageDescriptor extends ImageDescriptor {
this.selected = selected; this.selected = selected;
} }
@Override
public ImageData getImageData(int zoom) {
int w = width;
int h = height;
if (zoom > 100) {
float s = zoom / 100.0f;
w = Math.round(width * s);
h = Math.round(height * s);
}
return getImageData(w, h);
}
@Override @Override
public ImageData getImageData() { public ImageData getImageData() {
return getImageData(100);
}
private ImageData getImageData(int width, int height) {
ImageData id = new ImageData(width, height, 24, PALETTEDATA); ImageData id = new ImageData(width, height, 24, PALETTEDATA);
int cx = width / 2; int cx = width / 2;
int cy = height / 2; int cy = height / 2;
......
...@@ -53,8 +53,22 @@ public class TextImageDescriptor extends ImageDescriptor { ...@@ -53,8 +53,22 @@ public class TextImageDescriptor extends ImageDescriptor {
} }
@Override @Override
public ImageData getImageData() { public ImageData getImageData(int zoom) {
int w = width;
int h = height;
int fs = fontSize;
if (zoom > 100) {
float s = zoom / 100.0f;
w = Math.round(width * s);
h = Math.round(height * s);
fs = Math.round(fontSize * s);
}
return getImageData(w, h, fs);
}
private ImageData getImageData(int width, int height, int fontSize) {
ImageData id = new ImageData(width, height, 24, _RGB); ImageData id = new ImageData(width, height, 24, _RGB);
BufferedImage bi = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB); BufferedImage bi = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
Graphics2D g = (Graphics2D) bi.getGraphics(); Graphics2D g = (Graphics2D) bi.getGraphics();
g.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON); g.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment