Use Image.getScaledInstance() in resize method and immediately set new width and height. Some reformatting.
This commit is contained in:
parent
bd1d880506
commit
90efca76fa
1 changed files with 11 additions and 8 deletions
|
@ -42,9 +42,9 @@ public abstract class ImageWrapper {
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public void setFont (String name, int style, int size) {
|
public void setFont (String name, int style, int size) {
|
||||||
this.fontname = name;
|
this.fontname = name;
|
||||||
this.fontstyle = style;
|
this.fontstyle = style;
|
||||||
this.fontsize = size;
|
this.fontsize = size;
|
||||||
g.setFont (new Font (name, style, size));
|
g.setFont (new Font (name, style, size));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -94,8 +94,11 @@ public abstract class ImageWrapper {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void resize (int w, int h) {
|
public void resize (int w, int h) {
|
||||||
ImageFilter filter = new AreaAveragingScaleFilter (w, h);
|
// ImageFilter filter = new ReplicateScaleFilter (w, h);
|
||||||
img = Toolkit.getDefaultToolkit ().createImage(new FilteredImageSource(img.getSource(), filter));
|
// img = Toolkit.getDefaultToolkit ().createImage(new FilteredImageSource(img.getSource(), filter));
|
||||||
|
img = img.getScaledInstance (w, h, Image.SCALE_SMOOTH);
|
||||||
|
width = w;
|
||||||
|
height = h;
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract void reduceColors (int colors);
|
public abstract void reduceColors (int colors);
|
||||||
|
@ -221,7 +224,7 @@ public abstract class ImageWrapper {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void paint (Graphics g, int xadd, int yadd) {
|
public void paint (Graphics g, int xadd, int yadd) {
|
||||||
g.drawString (text, xoff+xadd, yoff+ascent+yadd);
|
g.drawString (text, xoff+xadd, yoff+ascent+yadd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue