Package org.apache.xmlgraphics.image.loader

Examples of org.apache.xmlgraphics.image.loader.ImageContext


        assertEquals(1000, ilpng.getUsagePenalty());
    }

    @Test
    public void testLoadImageImageInfoMapImageSessionContext() throws ImageException, IOException {
        ImageContext context = MockImageContext.newSafeInstance();
        ImageSessionContext session = new MockImageSessionContext(context);
        ImageInfo info = new ImageInfo("basn2c08.png", MimeConstants.MIME_PNG);
        Image im = ilpng.loadImage(info, null, session);
        assertTrue(im instanceof ImageRendered);
    }
View Full Code Here


*/
public class ImageLoaderRawCCITTFaxTestCase extends TestCase {
    private ImageLoaderRawCCITTFax sut;

    public void testLoadImage() throws Exception {
        ImageContext context = MockImageContext.newSafeInstance();
        ImageSessionContext session = new MockImageSessionContext(context);
        // This image file is NOT a valid tif! It is the directory table ONLY.
        ImageInfo info = new ImageInfo("dirOnly.tif", MimeConstants.MIME_TIFF);
        ImageSize size = new ImageSize();
        // Size data can be retrieve by parsing the directory table in the TIFF
View Full Code Here

        URL imageURL = getClass().getResource("gray-vs-cmyk-profile.png");
        Assert.assertNotNull(imageURL);
        String uri = imageURL.toURI().toASCIIString();

        ImageLoaderImageIO loader = new ImageLoaderImageIO(ImageFlavor.RENDERED_IMAGE);
        ImageContext context = MockImageContext.newSafeInstance();
        ImageSessionContext session = new MockImageSessionContext(context);
        ImageInfo info = new ImageInfo(uri, MimeConstants.MIME_PNG);
        Image im = loader.loadImage(info, null, session);
        assertTrue(im instanceof ImageRendered);
    }
View Full Code Here

        testColorTypePNG("tbrn2c08.png", PNG_COLOR_RGB, true);
    }

    @Test
    public void testCorruptPNG() {
        ImageContext context = MockImageContext.newSafeInstance();
        ImageSessionContext session = new MockImageSessionContext(context);
        ImageInfo info = new ImageInfo("corrupt-image.png", MimeConstants.MIME_PNG);
        ImageLoaderRawPNG ilrpng = new ImageLoaderRawPNG();
        try {
            ImageRawPNG irpng = (ImageRawPNG) ilrpng.loadImage(info, null, session);
View Full Code Here

        testColorTypePNG(imageName, colorType, false);
    }

    private void testColorTypePNG(String imageName, int colorType, boolean isTransparent)
            throws ImageException, IOException {
        ImageContext context = MockImageContext.newSafeInstance();
        ImageSessionContext session = new MockImageSessionContext(context);
        ImageInfo info = new ImageInfo(imageName, MimeConstants.MIME_PNG);
        ImageLoaderRawPNG ilrpng = new ImageLoaderRawPNG();
        ImageRawPNG irpng = (ImageRawPNG) ilrpng.loadImage(info, null, session);
        ColorModel cm = irpng.getColorModel();
View Full Code Here

        assertEquals(1000, ilrpng.getUsagePenalty());
    }

    @Test
    public void testLoadImageBadMime() throws ImageException, IOException {
        ImageContext context = MockImageContext.newSafeInstance();
        ImageSessionContext session = new MockImageSessionContext(context);
        ImageInfo info = new ImageInfo("basn2c08.png", MimeConstants.MIME_JPEG);
        try {
            ImageRawPNG irpng = (ImageRawPNG) ilrpng.loadImage(info, null, session);
            fail("An exception should have been thrown above");
View Full Code Here

        assertEquals(ImageFlavor.RAW_PNG, ilrpng.getTargetFlavor());
    }

    @Test
    public void testLoadImageGoodMime() throws ImageException, IOException {
        ImageContext context = MockImageContext.newSafeInstance();
        ImageSessionContext session = new MockImageSessionContext(context);
        ImageInfo info = new ImageInfo("basn2c08.png", MimeConstants.MIME_PNG);
        Image im = ilrpng.loadImage(info, null, session);
        assertTrue(im instanceof ImageRawPNG);
    }
View Full Code Here

            throw new TranscoderException(ex);
        }
    }

    private void setupImageInfrastructure(final String baseURI) {
        final ImageContext imageContext = new ImageContext() {
            public float getSourceResolution() {
                return 25.4f / userAgent.getPixelUnitToMillimeter();
            }
        };
        this.imageManager = new ImageManager(imageContext);
View Full Code Here

    /**
     * Sets up the image infrastructure (the image loading framework).
     * @param baseURI the base URI of the current document
     */
    protected void setupImageInfrastructure(final String baseURI) {
        final ImageContext imageContext = new ImageContext() {
            public float getSourceResolution() {
                return UnitConv.IN2MM / userAgent.getPixelUnitToMillimeter();
            }
        };
        this.imageManager = new ImageManager(imageContext);
View Full Code Here

    /**
     * Sets up the image infrastructure (the image loading framework).
     * @param baseURI the base URI of the current document
     */
    protected void setupImageInfrastructure(final String baseURI) {
        final ImageContext imageContext = new ImageContext() {
            public float getSourceResolution() {
                return 25.4f / userAgent.getPixelUnitToMillimeter();
            }
        };
        this.imageManager = new ImageManager(imageContext);
View Full Code Here

TOP

Related Classes of org.apache.xmlgraphics.image.loader.ImageContext

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.