java.awt.image.ByteLookupTable Java Examples

The following examples show how to use java.awt.image.ByteLookupTable. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MainPanel.java    From java-swing-tips with MIT License 6 votes vote down vote up
public static BufferedImage getFilteredImage(URL url) {
  BufferedImage image = Optional.ofNullable(url)
      .map(u -> {
        try {
          return ImageIO.read(u);
        } catch (IOException ex) {
          return makeMissingImage();
        }
      }).orElseGet(ImageUtil::makeMissingImage);

  BufferedImage dest = new BufferedImage(image.getWidth(), image.getHeight(), BufferedImage.TYPE_INT_RGB);
  byte[] b = new byte[256];
  IntStream.range(0, b.length).forEach(i -> b[i] = (byte) (i * .5));
  BufferedImageOp op = new LookupOp(new ByteLookupTable(0, b), null);
  op.filter(image, dest);
  return dest;
}
 
Example #2
Source File: MainPanel.java    From java-swing-tips with MIT License 6 votes vote down vote up
private static BufferedImage getFilteredImage(URL url) {
  BufferedImage image = Optional.ofNullable(url)
      .map(u -> {
        try {
          return ImageIO.read(u);
        } catch (IOException ex) {
          return makeMissingImage();
        }
      }).orElseGet(MainPanel::makeMissingImage);

  BufferedImage dest = new BufferedImage(image.getWidth(), image.getHeight(), BufferedImage.TYPE_INT_RGB);
  byte[] b = new byte[256];
  for (int i = 0; i < b.length; i++) {
    b[i] = (byte) (i * .5);
  }
  BufferedImageOp op = new LookupOp(new ByteLookupTable(0, b), null);
  op.filter(image, dest);
  return dest;
}
 
Example #3
Source File: MainPanel.java    From java-swing-tips with MIT License 6 votes vote down vote up
private static BufferedImage getFilteredImage(URL url) {
  BufferedImage image = Optional.ofNullable(url).map(u -> {
    try {
      return ImageIO.read(u);
    } catch (IOException ex) {
      return makeMissingImage();
    }
  }).orElseGet(MainPanel::makeMissingImage);

  BufferedImage dest = new BufferedImage(image.getWidth(), image.getHeight(), BufferedImage.TYPE_INT_RGB);
  byte[] b = new byte[256];
  for (int i = 0; i < b.length; i++) {
    b[i] = (byte) (i * .2f);
  }
  BufferedImageOp op = new LookupOp(new ByteLookupTable(0, b), null);
  op.filter(image, dest);
  return dest;
}
 
Example #4
Source File: MainPanel.java    From java-swing-tips with MIT License 6 votes vote down vote up
private static BufferedImage getFilteredImage(URL url) {
  BufferedImage image = Optional.ofNullable(url)
      .map(u -> {
        try {
          return ImageIO.read(u);
        } catch (IOException ex) {
          return makeMissingImage();
        }
      }).orElseGet(MainPanel::makeMissingImage);

  BufferedImage dest = new BufferedImage(image.getWidth(), image.getHeight(), BufferedImage.TYPE_INT_RGB);
  byte[] b = new byte[256];
  for (int i = 0; i < b.length; i++) {
    b[i] = (byte) (i * .2f);
  }
  BufferedImageOp op = new LookupOp(new ByteLookupTable(0, b), null);
  op.filter(image, dest);
  return dest;
}
 
Example #5
Source File: RasterOpNullDestinationRasterTest.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
public static void main(String[] args) {

        byte[][] data = new byte[1][10];
        ByteLookupTable lut = new ByteLookupTable(0, data);
        RasterOp op = new LookupOp(lut, null);

        int[] bandOffsets = {0};
        Point location = new Point(0, 0);
        DataBuffer db = new DataBufferByte(10 * 10);
        SampleModel sm = new PixelInterleavedSampleModel(DataBuffer.TYPE_BYTE,
                                                         10, 10, 1, 10,
                                                         bandOffsets);

        Raster src = Raster.createRaster(sm, db, location);

        op.filter(src, null); // this used to result in NullPointerException
    }
 
Example #6
Source File: IntImageReverseTest.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Reverse image color components, leave alpha unchanged.
 */
private static LookupTable createReverseTable() {
    byte[] data = new byte[256];

    for (int i = 0; i < 256; i++) {
        data[i] = (byte) (255 - i);
    }


    return new ByteLookupTable(0, data);
}
 
Example #7
Source File: MlibOpsTest.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
private static BufferedImageOp getLookupOp() {
    byte[] inv = new byte[256];
    for (int i = 0; i < 256; i++) {
        inv[i] = (byte)(255 - i);
    }
    ByteLookupTable table = new ByteLookupTable(0, inv);
    return new LookupOp(table, null);
}
 
Example #8
Source File: MlibOpsTest.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
private static BufferedImageOp getLookupOp() {
    byte[] inv = new byte[256];
    for (int i = 0; i < 256; i++) {
        inv[i] = (byte)(255 - i);
    }
    ByteLookupTable table = new ByteLookupTable(0, inv);
    return new LookupOp(table, null);
}
 
Example #9
Source File: SingleArrayTest.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
public SingleArrayTest() {

        byte[] array = new byte[256];
        for (int i = 0; i < 256; i++) {
            array[i] = (byte)i;
        }
        ByteLookupTable table = new ByteLookupTable(0, array);

        op = new LookupOp(table, null);
    }
 
Example #10
Source File: IntImageReverseTest.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Reverse image color components, leave alpha unchanged.
 */
private static LookupTable createReverseTable() {
    byte[] data = new byte[256];

    for (int i = 0; i < 256; i++) {
        data[i] = (byte) (255 - i);
    }


    return new ByteLookupTable(0, data);
}
 
Example #11
Source File: MlibOpsTest.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
private static BufferedImageOp getLookupOp() {
    byte[] inv = new byte[256];
    for (int i = 0; i < 256; i++) {
        inv[i] = (byte)(255 - i);
    }
    ByteLookupTable table = new ByteLookupTable(0, inv);
    return new LookupOp(table, null);
}
 
Example #12
Source File: SingleArrayTest.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
public SingleArrayTest() {

        byte[] array = new byte[256];
        for (int i = 0; i < 256; i++) {
            array[i] = (byte)i;
        }
        ByteLookupTable table = new ByteLookupTable(0, array);

        op = new LookupOp(table, null);
    }
 
Example #13
Source File: MlibOpsTest.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
private static BufferedImageOp getLookupOp() {
    byte[] inv = new byte[256];
    for (int i = 0; i < 256; i++) {
        inv[i] = (byte)(255 - i);
    }
    ByteLookupTable table = new ByteLookupTable(0, inv);
    return new LookupOp(table, null);
}
 
Example #14
Source File: SingleArrayTest.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public SingleArrayTest() {

        byte[] array = new byte[256];
        for (int i = 0; i < 256; i++) {
            array[i] = (byte)i;
        }
        ByteLookupTable table = new ByteLookupTable(0, array);

        op = new LookupOp(table, null);
    }
 
Example #15
Source File: IntImageReverseTest.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Reverse image color components, leave alpha unchanged.
 */
private static LookupTable createReverseTable() {
    byte[] data = new byte[256];

    for (int i = 0; i < 256; i++) {
        data[i] = (byte) (255 - i);
    }


    return new ByteLookupTable(0, data);
}
 
Example #16
Source File: MlibOpsTest.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
private static BufferedImageOp getLookupOp() {
    byte[] inv = new byte[256];
    for (int i = 0; i < 256; i++) {
        inv[i] = (byte)(255 - i);
    }
    ByteLookupTable table = new ByteLookupTable(0, inv);
    return new LookupOp(table, null);
}
 
Example #17
Source File: IntImageReverseTest.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Reverse image color components, leave alpha unchanged.
 */
private static LookupTable createReverseTable() {
    byte[] data = new byte[256];

    for (int i = 0; i < 256; i++) {
        data[i] = (byte) (255 - i);
    }


    return new ByteLookupTable(0, data);
}
 
Example #18
Source File: SingleArrayTest.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
public SingleArrayTest() {

        byte[] array = new byte[256];
        for (int i = 0; i < 256; i++) {
            array[i] = (byte)i;
        }
        ByteLookupTable table = new ByteLookupTable(0, array);

        op = new LookupOp(table, null);
    }
 
Example #19
Source File: MlibOpsTest.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
private static BufferedImageOp getLookupOp() {
    byte[] inv = new byte[256];
    for (int i = 0; i < 256; i++) {
        inv[i] = (byte)(255 - i);
    }
    ByteLookupTable table = new ByteLookupTable(0, inv);
    return new LookupOp(table, null);
}
 
Example #20
Source File: IntImageReverseTest.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Reverse image color components, leave alpha unchanged.
 */
private static LookupTable createReverseTable() {
    byte[] data = new byte[256];

    for (int i = 0; i < 256; i++) {
        data[i] = (byte) (255 - i);
    }


    return new ByteLookupTable(0, data);
}
 
Example #21
Source File: SingleArrayTest.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
public SingleArrayTest() {

        byte[] array = new byte[256];
        for (int i = 0; i < 256; i++) {
            array[i] = (byte)i;
        }
        ByteLookupTable table = new ByteLookupTable(0, array);

        op = new LookupOp(table, null);
    }
 
Example #22
Source File: MlibOpsTest.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
private static BufferedImageOp getLookupOp() {
    byte[] inv = new byte[256];
    for (int i = 0; i < 256; i++) {
        inv[i] = (byte)(255 - i);
    }
    ByteLookupTable table = new ByteLookupTable(0, inv);
    return new LookupOp(table, null);
}
 
Example #23
Source File: IntImageReverseTest.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Reverse image color components, leave alpha unchanged.
 */
private static LookupTable createReverseTable() {
    byte[] data = new byte[256];

    for (int i = 0; i < 256; i++) {
        data[i] = (byte) (255 - i);
    }


    return new ByteLookupTable(0, data);
}
 
Example #24
Source File: SingleArrayTest.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
public SingleArrayTest() {

        byte[] array = new byte[256];
        for (int i = 0; i < 256; i++) {
            array[i] = (byte)i;
        }
        ByteLookupTable table = new ByteLookupTable(0, array);

        op = new LookupOp(table, null);
    }
 
Example #25
Source File: MlibOpsTest.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
private static BufferedImageOp getLookupOp() {
    byte[] inv = new byte[256];
    for (int i = 0; i < 256; i++) {
        inv[i] = (byte)(255 - i);
    }
    ByteLookupTable table = new ByteLookupTable(0, inv);
    return new LookupOp(table, null);
}
 
Example #26
Source File: IntImageReverseTest.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Reverse image color components, leave alpha unchanged.
 */
private static LookupTable createReverseTable() {
    byte[] data = new byte[256];

    for (int i = 0; i < 256; i++) {
        data[i] = (byte) (255 - i);
    }


    return new ByteLookupTable(0, data);
}
 
Example #27
Source File: SingleArrayTest.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
public SingleArrayTest() {

        byte[] array = new byte[256];
        for (int i = 0; i < 256; i++) {
            array[i] = (byte)i;
        }
        ByteLookupTable table = new ByteLookupTable(0, array);

        op = new LookupOp(table, null);
    }
 
Example #28
Source File: MlibOpsTest.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
private static BufferedImageOp getLookupOp() {
    byte[] inv = new byte[256];
    for (int i = 0; i < 256; i++) {
        inv[i] = (byte)(255 - i);
    }
    ByteLookupTable table = new ByteLookupTable(0, inv);
    return new LookupOp(table, null);
}
 
Example #29
Source File: IntImageReverseTest.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Reverse image color components, leave alpha unchanged.
 */
private static LookupTable createReverseTable() {
    byte[] data = new byte[256];

    for (int i = 0; i < 256; i++) {
        data[i] = (byte) (255 - i);
    }


    return new ByteLookupTable(0, data);
}
 
Example #30
Source File: SingleArrayTest.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
public SingleArrayTest() {

        byte[] array = new byte[256];
        for (int i = 0; i < 256; i++) {
            array[i] = (byte)i;
        }
        ByteLookupTable table = new ByteLookupTable(0, array);

        op = new LookupOp(table, null);
    }