예제 #1
0
  /**
   * Uses a ImageFilter to return a cropped version of the image. Hopefully useful when handling
   * tilesets.
   */
  public static Image getTile(Image tileset, int x1, int x2, int y1, int y2, int scale) {
    JPanel producer = new JPanel();
    // Crop tileset to grab tile
    ImageFilter cropper = new CropImageFilter(x1, y1, x2 - x1, y2 - y1);
    Image cropped = producer.createImage(new FilteredImageSource(tileset.getSource(), cropper));

    return scaleImage(cropped, scale);
  }
예제 #2
0
 static Icon getOceanDisabledButtonIcon(Image image) {
   Object[] range = (Object[]) UIManager.get("Button.disabledGrayRange");
   int min = 180;
   int max = 215;
   if (range != null) {
     min = ((Integer) range[0]).intValue();
     max = ((Integer) range[1]).intValue();
   }
   ImageProducer prod =
       new FilteredImageSource(image.getSource(), new OceanDisabledButtonImageFilter(min, max));
   return new ImageIconUIResource(Toolkit.getDefaultToolkit().createImage(prod));
 }
예제 #3
0
 static Image generateDisabledImage(final Image image) {
   final ImageProducer prod =
       new FilteredImageSource(
           image.getSource(),
           new IconImageFilter() {
             @Override
             int getGreyFor(final int gray) {
               return 255 - ((255 - gray) * 65 / 100);
             }
           });
   return Toolkit.getDefaultToolkit().createImage(prod);
 }
예제 #4
0
 static Image generateSelectedDarkImage(final Image image) {
   final ImageProducer prod =
       new FilteredImageSource(
           image.getSource(),
           new IconImageFilter() {
             @Override
             int getGreyFor(final int gray) {
               return gray * 75 / 100;
             }
           });
   return Toolkit.getDefaultToolkit().createImage(prod);
 }
예제 #5
0
  public static Image makeColorTransparent(Image im, final Color color) {
    ImageFilter filter =
        new RGBImageFilter() {
          public int markerRGB = color.getRGB() | 0xFF000000;

          public final int filterRGB(int x, int y, int rgb) {
            if ((rgb | 0xFF000000) == markerRGB) {
              return 0x00FFFFFF & rgb;
            } else {
              return rgb;
            }
          }
        };

    ImageProducer ip = new FilteredImageSource(im.getSource(), filter);
    return Toolkit.getDefaultToolkit().createImage(ip);
  }
예제 #6
0
 private static ImageIcon makeGrayImageIcon5(Image img) {
   // RGBImageFilter
   ImageProducer ip = new FilteredImageSource(img.getSource(), new GrayImageFilter());
   return new ImageIcon(Toolkit.getDefaultToolkit().createImage(ip));
 }
예제 #7
0
 private static ImageIcon makeGrayImageIcon4(Image img) {
   // GrayFilter2
   ImageProducer ip = new FilteredImageSource(img.getSource(), new GrayFilter(true, 50));
   return new ImageIcon(Toolkit.getDefaultToolkit().createImage(ip));
 }
예제 #8
0
 static Icon getOceanToolBarIcon(Image i) {
   ImageProducer prod = new FilteredImageSource(i.getSource(), new OceanToolBarImageFilter());
   return new ImageIconUIResource(Toolkit.getDefaultToolkit().createImage(prod));
 }
예제 #9
0
 static Image generateLightenedImage(Image image, ImageFilter filter) {
   final ImageProducer prod = new FilteredImageSource(image.getSource(), filter);
   return Toolkit.getDefaultToolkit().createImage(prod);
 }