コード例 #1
0
ファイル: JREImage.java プロジェクト: kazuyakuza/wh40kh
 /**
  * Returns a smoothly scaled image using getScaledInstance. This method has interesting behaviour.
  * The scaled image retains its type (indexed/rgb and bitmask/translucent), and the algorithm
  * tries to scale smoothly within these constraints. For indexed, interpolated pixels are rounded
  * to the existing indexed colours. For bitmask, the behaviour depends on the platform. On
  * WinXP/J1.2 I found that the colour _behind_ each transparent pixel is used to interpolate
  * between nontransparent and transparent pixels. On BSD/J1.4 I found that the colours of
  * transparent pixels are never used, and only the nontransparent pixels are used when
  * interpolating a region with mixed transparent/nontransparent pixels.
  */
 public JGImage scale(int width, int height) {
   // BufferedImage dstimg = createCompatibleImage(width,height);
   // BufferedImage srcimg = toBuffered(img);
   Image scaledimg = img.getScaledInstance(width, height, Image.SCALE_SMOOTH);
   try {
     /* this is necessary for scaled images too */
     ensureLoaded(scaledimg);
   } catch (Exception e) {
     System.err.println("Error scaling image.");
   }
   return new JREImage(scaledimg);
 }
コード例 #2
0
ファイル: JREImage.java プロジェクト: kazuyakuza/wh40kh
 public JGPoint getSize() {
   return new JGPoint(img.getWidth(observer), img.getHeight(observer));
 }