Search in sources :

Example 1 with ImageEncodeProcessor

use of org.polymap.core.data.image.ImageEncodeProcessor in project polymap4-core by Polymap4.

the class ImageGrayscaleProcessor method eop.

@Consumes({ EndOfProcessing.class })
@Produces({ EndOfProcessing.class })
public void eop(ProcessorResponse r, ProcessorContext context) throws Exception {
    ByteArrayOutputStream buf = (ByteArrayOutputStream) context.get("buf");
    if (buf != null) {
        Image image = Toolkit.getDefaultToolkit().createImage(buf.toByteArray());
        Image gray = grayscale(image);
        ImageEncodeProcessor encodeProcessor = new ImageEncodeProcessor();
        encodeProcessor.encodeImageResponse(new ImageResponse(gray), context);
    } else {
        context.sendResponse(r);
    }
}
Also used : ImageEncodeProcessor(org.polymap.core.data.image.ImageEncodeProcessor) ImageResponse(org.polymap.core.data.image.ImageResponse) EncodedImageResponse(org.polymap.core.data.image.EncodedImageResponse) ByteArrayOutputStream(java.io.ByteArrayOutputStream) Image(java.awt.Image) BufferedImage(java.awt.image.BufferedImage) Consumes(org.polymap.core.data.pipeline.Consumes) Produces(org.polymap.core.data.pipeline.Produces)

Example 2 with ImageEncodeProcessor

use of org.polymap.core.data.image.ImageEncodeProcessor in project polymap4-core by Polymap4.

the class ProcessorSignatureTest method testImageEncodeCompatibelFeatureRender.

@Test
public void testImageEncodeCompatibelFeatureRender() throws Exception {
    ImageEncodeProcessor proc1 = new ImageEncodeProcessor();
    FeatureRenderProcessor2 proc2 = new FeatureRenderProcessor2();
    ProcessorSignature sig1 = new ProcessorSignature(proc1.getClass());
    ProcessorSignature sig2 = new ProcessorSignature(proc2.getClass());
    // log.info( "ImageEncode:\n" + sig1 );
    // log.info( "FeatureRender:\n" + sig2 );
    assertTrue(sig1.isCompatible(sig2));
}
Also used : ImageEncodeProcessor(org.polymap.core.data.image.ImageEncodeProcessor) FeatureRenderProcessor2(org.polymap.core.data.feature.FeatureRenderProcessor2) Test(org.junit.Test)

Aggregations

ImageEncodeProcessor (org.polymap.core.data.image.ImageEncodeProcessor)2 Image (java.awt.Image)1 BufferedImage (java.awt.image.BufferedImage)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 Test (org.junit.Test)1 FeatureRenderProcessor2 (org.polymap.core.data.feature.FeatureRenderProcessor2)1 EncodedImageResponse (org.polymap.core.data.image.EncodedImageResponse)1 ImageResponse (org.polymap.core.data.image.ImageResponse)1 Consumes (org.polymap.core.data.pipeline.Consumes)1 Produces (org.polymap.core.data.pipeline.Produces)1