/ Published in: Java
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
import java.awt.Dimension; import javax.media.Buffer; import javax.media.Effect; import javax.media.Format; import javax.media.ResourceUnavailableException; import javax.media.format.RGBFormat; public class SimpleFilter implements Effect { public AngelMotionCodec() { } /****** Codec ******/ { return inputFormats; } { if(input != null) { if(matches(input, inputFormats) != null) else } return outputFormats; } public int process(Buffer input, Buffer output) { // Swap tra input & output input.setData(output.getData()); output.setData(tmp); return BUFFER_PROCESSED_OK; } { inputFormat = input; return input; } { if(output != null || matches(output, outputFormats) != null) { RGBFormat inRGB = (RGBFormat) output; int maxDataLength = inRGB.getMaxDataLength(); int lineStride = inRGB.getLineStride(); int flipped = inRGB.getFlipped(); if(size == null) return null; if(maxDataLength < size.width*size.height*3) maxDataLength = size.width*size.height*3; if(lineStride < size.width*3) lineStride = size.width*3; outputFormat = outputFormats[0].intersects(new RGBFormat(size, maxDataLength, inRGB.getDataType(), inRGB.getFrameRate(), inRGB.getBitsPerPixel(), inRGB.getRedMask(), inRGB.getGreenMask(), inRGB.getBlueMask(), inRGB.getPixelStride(), lineStride, flipped, inRGB.getEndian())); return outputFormat; } return null; } /****** Codec ******/ /****** PlugIn ******/ public void close() { } { return "Simple-Filter"; } public void open() throws ResourceUnavailableException { } public void reset() { } /****** PlugIn ******/ /****** Controls ******/ { return null; } { return null; } /****** Controls ******/ /****** Utility ******/ { if(in != null && out != null) { for(int i=0, cnt=out.length; i<cnt; i++) { if(in.matches(out[i])) return out[i]; } } return null; } /****** Utility ******/ }