Search in sources :

Example 1 with ImagingOpException

use of java.awt.image.ImagingOpException in project jdk8u_jdk by JetBrains.

the class SamePackingTypeTest method main.

public static void main(String[] args) {
    BufferedImageOp op = createTestOp();
    try {
        System.out.print("Integer-based images... ");
        doTest(op, TYPE_INT_ARGB, TYPE_INT_ARGB_PRE);
        System.out.println("done.");
        System.out.print("Byte-based images... ");
        doTest(op, TYPE_4BYTE_ABGR, TYPE_4BYTE_ABGR_PRE);
        System.out.println("done");
    } catch (ImagingOpException e) {
        throw new RuntimeException("Test FAILED", e);
    }
}
Also used : BufferedImageOp(java.awt.image.BufferedImageOp) ImagingOpException(java.awt.image.ImagingOpException)

Example 2 with ImagingOpException

use of java.awt.image.ImagingOpException in project jdk8u_jdk by JetBrains.

the class EdgeNoOpCrash method crashTest.

private static void crashTest() {
    Raster src = createSrcRaster();
    WritableRaster dst = createDstRaster();
    ConvolveOp op = createConvolveOp(ConvolveOp.EDGE_NO_OP);
    try {
        op.filter(src, dst);
    } catch (ImagingOpException e) {
    /*
             * The test pair of source and destination rasters
             * may cause failure of the medialib convolution routine,
             * so this exception is expected.
             *
             * The JVM crash is the only manifestation of this
             * test failure.
             */
    }
    System.out.println("Test PASSED.");
}
Also used : WritableRaster(java.awt.image.WritableRaster) Raster(java.awt.image.Raster) WritableRaster(java.awt.image.WritableRaster) ImagingOpException(java.awt.image.ImagingOpException) ConvolveOp(java.awt.image.ConvolveOp)

Example 3 with ImagingOpException

use of java.awt.image.ImagingOpException in project jdk8u_jdk by JetBrains.

the class OpCompatibleImageTest method doTest.

public void doTest(int type) {
    System.out.println("Test for type " + describeType(type));
    BufferedImage src = createTestImage(type);
    BufferedImage res = null;
    System.out.println("Testing null destination...");
    try {
        res = op.filter(src, null);
    } catch (ImagingOpException e) {
        throw new RuntimeException("Test FAILED!", e);
    }
    if (res == null || ((src.getType() != BufferedImage.TYPE_BYTE_INDEXED) && (res.getType() != src.getType()))) {
        throw new RuntimeException("Test FAILED!");
    }
    System.out.println("Test PASSED.");
}
Also used : ImagingOpException(java.awt.image.ImagingOpException) BufferedImage(java.awt.image.BufferedImage)

Example 4 with ImagingOpException

use of java.awt.image.ImagingOpException in project jdk8u_jdk by JetBrains.

the class InvalidTransformParameterTest method main.

public static void main(String[] args) {
    int count = 0;
    final int testScenarios = 12;
    double NaNArg = 0.0 / 0.0;
    double positiveInfArg = 1.0 / 0.0;
    double negativeInfArg = -1.0 / 0.0;
    BufferedImage img = new BufferedImage(5, 5, BufferedImage.TYPE_INT_ARGB);
    AffineTransform[] inputTransforms = new AffineTransform[testScenarios];
    for (int i = 0; i < inputTransforms.length; i++) {
        inputTransforms[i] = new AffineTransform();
    }
    inputTransforms[0].rotate(NaNArg, img.getWidth() / 2, img.getHeight() / 2);
    inputTransforms[1].translate(NaNArg, NaNArg);
    inputTransforms[2].scale(NaNArg, NaNArg);
    inputTransforms[3].shear(NaNArg, NaNArg);
    inputTransforms[4].rotate(positiveInfArg, img.getWidth() / 2, img.getHeight() / 2);
    inputTransforms[5].translate(positiveInfArg, positiveInfArg);
    inputTransforms[6].scale(positiveInfArg, positiveInfArg);
    inputTransforms[7].shear(positiveInfArg, positiveInfArg);
    inputTransforms[8].rotate(negativeInfArg, img.getWidth() / 2, img.getHeight() / 2);
    inputTransforms[9].translate(negativeInfArg, negativeInfArg);
    inputTransforms[10].scale(negativeInfArg, negativeInfArg);
    inputTransforms[11].shear(negativeInfArg, negativeInfArg);
    for (int i = 0; i < inputTransforms.length; i++) {
        try {
            testImageTransform(img, inputTransforms[i]);
        } catch (ImagingOpException ex) {
            count++;
        }
    }
    if (count != testScenarios) {
        throw new RuntimeException("Test failed. All test scenarios did not" + " result in exception as expected.");
    }
    // Test Raster AffineTransform ---------------------------------
    count = 0;
    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);
    WritableRaster dst = Raster.createWritableRaster(sm, db, location);
    for (int i = 0; i < inputTransforms.length; i++) {
        try {
            testRasterTransform(src, dst, inputTransforms[i]);
        } catch (ImagingOpException ex) {
            count++;
        }
    }
    if (count != testScenarios) {
        throw new RuntimeException("Test failed. All test scenarios did not" + " result in exception as expected.");
    }
}
Also used : PixelInterleavedSampleModel(java.awt.image.PixelInterleavedSampleModel) Raster(java.awt.image.Raster) WritableRaster(java.awt.image.WritableRaster) Point(java.awt.Point) DataBufferByte(java.awt.image.DataBufferByte) Point(java.awt.Point) BufferedImage(java.awt.image.BufferedImage) PixelInterleavedSampleModel(java.awt.image.PixelInterleavedSampleModel) SampleModel(java.awt.image.SampleModel) WritableRaster(java.awt.image.WritableRaster) ImagingOpException(java.awt.image.ImagingOpException) AffineTransform(java.awt.geom.AffineTransform) DataBuffer(java.awt.image.DataBuffer)

Aggregations

ImagingOpException (java.awt.image.ImagingOpException)4 BufferedImage (java.awt.image.BufferedImage)2 Raster (java.awt.image.Raster)2 WritableRaster (java.awt.image.WritableRaster)2 Point (java.awt.Point)1 AffineTransform (java.awt.geom.AffineTransform)1 BufferedImageOp (java.awt.image.BufferedImageOp)1 ConvolveOp (java.awt.image.ConvolveOp)1 DataBuffer (java.awt.image.DataBuffer)1 DataBufferByte (java.awt.image.DataBufferByte)1 PixelInterleavedSampleModel (java.awt.image.PixelInterleavedSampleModel)1 SampleModel (java.awt.image.SampleModel)1