java.awt.image.LookupOp Java Examples

The following examples show how to use java.awt.image.LookupOp. 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: IntImageReverseTest.java    From jdk8u_jdk with GNU General Public License v2.0 6 votes vote down vote up
public static void main(String[] args) {
    LookupTable tbl = createReverseTable();
    LookupOp op = new LookupOp(tbl, null);

    for (ImageType t : ImageType.values()) {
        System.out.print(t);

        BufferedImage src = createSourceImage(t);

        BufferedImage dst = op.filter(src, null);

        int rgb = dst.getRGB(0, 0);

        System.out.printf(" Result: 0x%X ", rgb);

        if (rgb != argbReverse) {
            throw new RuntimeException("Test failed.");
        }
        System.out.println("Passed.");
    }
}
 
Example #2
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 #3
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 #4
Source File: IntImageReverseTest.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
public static void main(String[] args) {
    LookupTable tbl = createReverseTable();
    LookupOp op = new LookupOp(tbl, null);

    for (ImageType t : ImageType.values()) {
        System.out.print(t);

        BufferedImage src = createSourceImage(t);

        BufferedImage dst = op.filter(src, null);

        int rgb = dst.getRGB(0, 0);

        System.out.printf(" Result: 0x%X ", rgb);

        if (rgb != argbReverse) {
            throw new RuntimeException("Test failed.");
        }
        System.out.println("Passed.");
    }
}
 
Example #5
Source File: IntImageReverseTest.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
public static void main(String[] args) {
    LookupTable tbl = createReverseTable();
    LookupOp op = new LookupOp(tbl, null);

    for (ImageType t : ImageType.values()) {
        System.out.print(t);

        BufferedImage src = createSourceImage(t);

        BufferedImage dst = op.filter(src, null);

        int rgb = dst.getRGB(0, 0);

        System.out.printf(" Result: 0x%X ", rgb);

        if (rgb != argbReverse) {
            throw new RuntimeException("Test failed.");
        }
        System.out.println("Passed.");
    }
}
 
Example #6
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 #7
Source File: IntImageReverseTest.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
public static void main(String[] args) {
    LookupTable tbl = createReverseTable();
    LookupOp op = new LookupOp(tbl, null);

    for (ImageType t : ImageType.values()) {
        System.out.print(t);

        BufferedImage src = createSourceImage(t);

        BufferedImage dst = op.filter(src, null);

        int rgb = dst.getRGB(0, 0);

        System.out.printf(" Result: 0x%X ", rgb);

        if (rgb != argbReverse) {
            throw new RuntimeException("Test failed.");
        }
        System.out.println("Passed.");
    }
}
 
Example #8
Source File: IntImageReverseTest.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
public static void main(String[] args) {
    LookupTable tbl = createReverseTable();
    LookupOp op = new LookupOp(tbl, null);

    for (ImageType t : ImageType.values()) {
        System.out.print(t);

        BufferedImage src = createSourceImage(t);

        BufferedImage dst = op.filter(src, null);

        int rgb = dst.getRGB(0, 0);

        System.out.printf(" Result: 0x%X ", rgb);

        if (rgb != argbReverse) {
            throw new RuntimeException("Test failed.");
        }
        System.out.println("Passed.");
    }
}
 
Example #9
Source File: IntImageReverseTest.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
public static void main(String[] args) {
    LookupTable tbl = createReverseTable();
    LookupOp op = new LookupOp(tbl, null);

    for (ImageType t : ImageType.values()) {
        System.out.print(t);

        BufferedImage src = createSourceImage(t);

        BufferedImage dst = op.filter(src, null);

        int rgb = dst.getRGB(0, 0);

        System.out.printf(" Result: 0x%X ", rgb);

        if (rgb != argbReverse) {
            throw new RuntimeException("Test failed.");
        }
        System.out.println("Passed.");
    }
}
 
Example #10
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 #11
Source File: BufferedBufImgOps.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public static void disableBufImgOp(RenderQueue rq, BufferedImageOp biop) {
    if (biop instanceof ConvolveOp) {
        disableConvolveOp(rq);
    } else if (biop instanceof RescaleOp) {
        disableRescaleOp(rq);
    } else if (biop instanceof LookupOp) {
        disableLookupOp(rq);
    } else {
        throw new InternalError("Unknown BufferedImageOp");
    }
}
 
Example #12
Source File: BufferedBufImgOps.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
public static void disableBufImgOp(RenderQueue rq, BufferedImageOp biop) {
    if (biop instanceof ConvolveOp) {
        disableConvolveOp(rq);
    } else if (biop instanceof RescaleOp) {
        disableRescaleOp(rq);
    } else if (biop instanceof LookupOp) {
        disableLookupOp(rq);
    } else {
        throw new InternalError("Unknown BufferedImageOp");
    }
}
 
Example #13
Source File: BufferedBufImgOps.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
public static void enableBufImgOp(RenderQueue rq, SurfaceData srcData,
                                  BufferedImage srcImg,
                                  BufferedImageOp biop)
{
    if (biop instanceof ConvolveOp) {
        enableConvolveOp(rq, srcData, (ConvolveOp)biop);
    } else if (biop instanceof RescaleOp) {
        enableRescaleOp(rq, srcData, srcImg, (RescaleOp)biop);
    } else if (biop instanceof LookupOp) {
        enableLookupOp(rq, srcData, srcImg, (LookupOp)biop);
    } else {
        throw new InternalError("Unknown BufferedImageOp");
    }
}
 
Example #14
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 #15
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 #16
Source File: BufferedBufImgOps.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
public static void disableBufImgOp(RenderQueue rq, BufferedImageOp biop) {
    if (biop instanceof ConvolveOp) {
        disableConvolveOp(rq);
    } else if (biop instanceof RescaleOp) {
        disableRescaleOp(rq);
    } else if (biop instanceof LookupOp) {
        disableLookupOp(rq);
    } else {
        throw new InternalError("Unknown BufferedImageOp");
    }
}
 
Example #17
Source File: BufferedBufImgOps.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
public static void enableBufImgOp(RenderQueue rq, SurfaceData srcData,
                                  BufferedImage srcImg,
                                  BufferedImageOp biop)
{
    if (biop instanceof ConvolveOp) {
        enableConvolveOp(rq, srcData, (ConvolveOp)biop);
    } else if (biop instanceof RescaleOp) {
        enableRescaleOp(rq, srcData, srcImg, (RescaleOp)biop);
    } else if (biop instanceof LookupOp) {
        enableLookupOp(rq, srcData, srcImg, (LookupOp)biop);
    } else {
        throw new InternalError("Unknown BufferedImageOp");
    }
}
 
Example #18
Source File: BufferedBufImgOps.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
public static void enableBufImgOp(RenderQueue rq, SurfaceData srcData,
                                  BufferedImage srcImg,
                                  BufferedImageOp biop)
{
    if (biop instanceof ConvolveOp) {
        enableConvolveOp(rq, srcData, (ConvolveOp)biop);
    } else if (biop instanceof RescaleOp) {
        enableRescaleOp(rq, srcData, srcImg, (RescaleOp)biop);
    } else if (biop instanceof LookupOp) {
        enableLookupOp(rq, srcData, srcImg, (LookupOp)biop);
    } else {
        throw new InternalError("Unknown BufferedImageOp");
    }
}
 
Example #19
Source File: BufferedBufImgOps.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
public static void enableBufImgOp(RenderQueue rq, SurfaceData srcData,
                                  BufferedImage srcImg,
                                  BufferedImageOp biop)
{
    if (biop instanceof ConvolveOp) {
        enableConvolveOp(rq, srcData, (ConvolveOp)biop);
    } else if (biop instanceof RescaleOp) {
        enableRescaleOp(rq, srcData, srcImg, (RescaleOp)biop);
    } else if (biop instanceof LookupOp) {
        enableLookupOp(rq, srcData, srcImg, (LookupOp)biop);
    } else {
        throw new InternalError("Unknown BufferedImageOp");
    }
}
 
Example #20
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 #21
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);
    }
 
Example #22
Source File: SingleArrayTest.java    From openjdk-jdk8u 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 #23
Source File: BufferedBufImgOps.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public static void enableBufImgOp(RenderQueue rq, SurfaceData srcData,
                                  BufferedImage srcImg,
                                  BufferedImageOp biop)
{
    if (biop instanceof ConvolveOp) {
        enableConvolveOp(rq, srcData, (ConvolveOp)biop);
    } else if (biop instanceof RescaleOp) {
        enableRescaleOp(rq, srcData, srcImg, (RescaleOp)biop);
    } else if (biop instanceof LookupOp) {
        enableLookupOp(rq, srcData, srcImg, (LookupOp)biop);
    } else {
        throw new InternalError("Unknown BufferedImageOp");
    }
}
 
Example #24
Source File: BufferedBufImgOps.java    From Bytecoder with Apache License 2.0 5 votes vote down vote up
public static void enableBufImgOp(RenderQueue rq, SurfaceData srcData,
                                  BufferedImage srcImg,
                                  BufferedImageOp biop)
{
    if (biop instanceof ConvolveOp) {
        enableConvolveOp(rq, srcData, (ConvolveOp)biop);
    } else if (biop instanceof RescaleOp) {
        enableRescaleOp(rq, srcData, srcImg, (RescaleOp)biop);
    } else if (biop instanceof LookupOp) {
        enableLookupOp(rq, srcData, srcImg, (LookupOp)biop);
    } else {
        throw new InternalError("Unknown BufferedImageOp");
    }
}
 
Example #25
Source File: SingleArrayTest.java    From openjdk-jdk8u-backup 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 #26
Source File: FilterPanelSeparator.java    From jeveassets with GNU General Public License v2.0 5 votes vote down vote up
public FilterPanelSeparator(int group) {
	this.group = group;

	jPanel = new JPanel();

	GroupLayout layout = new GroupLayout(jPanel);
	jPanel.setLayout(layout);
	layout.setAutoCreateGaps(true);
	layout.setAutoCreateContainerGaps(false);

	BufferedImageOp lookup = new LookupOp(new ColorMapper(Color.WHITE, getColor("nimbusBlueGrey", "Separator.foreground")), null);
	BufferedImage convertedImage = lookup.filter((BufferedImage)Images.MISC_AND.getImage(), null);
	JLabel jIcon = new JLabel(new ImageIcon(convertedImage));

	layout.setHorizontalGroup(
		layout.createSequentialGroup()
			.addGap(30)
			.addComponent(jIcon, 12, 12, 12)
	);

	layout.setVerticalGroup(
		layout.createSequentialGroup()
			.addGap(1)
			.addGroup(layout.createParallelGroup(GroupLayout.Alignment.CENTER)
				.addComponent(jIcon, 4, 4, 4)
			)
			.addGap(1)
	);
}
 
Example #27
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 #28
Source File: BufferedBufImgOps.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
public static void disableBufImgOp(RenderQueue rq, BufferedImageOp biop) {
    if (biop instanceof ConvolveOp) {
        disableConvolveOp(rq);
    } else if (biop instanceof RescaleOp) {
        disableRescaleOp(rq);
    } else if (biop instanceof LookupOp) {
        disableLookupOp(rq);
    } else {
        throw new InternalError("Unknown BufferedImageOp");
    }
}
 
Example #29
Source File: BufferedBufImgOps.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
public static void enableBufImgOp(RenderQueue rq, SurfaceData srcData,
                                  BufferedImage srcImg,
                                  BufferedImageOp biop)
{
    if (biop instanceof ConvolveOp) {
        enableConvolveOp(rq, srcData, (ConvolveOp)biop);
    } else if (biop instanceof RescaleOp) {
        enableRescaleOp(rq, srcData, srcImg, (RescaleOp)biop);
    } else if (biop instanceof LookupOp) {
        enableLookupOp(rq, srcData, srcImg, (LookupOp)biop);
    } else {
        throw new InternalError("Unknown BufferedImageOp");
    }
}
 
Example #30
Source File: BufferedBufImgOps.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
public static void disableBufImgOp(RenderQueue rq, BufferedImageOp biop) {
    if (biop instanceof ConvolveOp) {
        disableConvolveOp(rq);
    } else if (biop instanceof RescaleOp) {
        disableRescaleOp(rq);
    } else if (biop instanceof LookupOp) {
        disableLookupOp(rq);
    } else {
        throw new InternalError("Unknown BufferedImageOp");
    }
}