📄 negativeeffect.java
字号:
package jvideodemo2;import javax.media.*;import javax.media.Effect;import javax.media.format.*;import javax.media.Buffer;import javax.media.ResourceUnavailableException;public class NegativeEffect implements Effect { private static String EffectName = "NegativeEffect"; protected RGBFormat inputFormat; protected RGBFormat outputFormat; protected Format[] supportedInputFormats; protected Format[] supportedOutputFormats; public NegativeEffect() { supportedInputFormats = new Format[]{ new RGBFormat() }; supportedOutputFormats = new Format[]{ new RGBFormat() }; } public Format[] getSupportedInputFormats() { /**@todo Implement this javax.media.Codec method*/ //throw new java.lang.UnsupportedOperationException("Method getSupportedInputFormats() not yet implemented."); System.out.println("getSupportedInputFormats"); return supportedInputFormats; } public Format[] getSupportedOutputFormats(Format parm1) { /**@todo Implement this javax.media.Codec method*/ //throw new java.lang.UnsupportedOperationException("Method getSupportedOutputFormats() not yet implemented."); System.out.println("getSupportedOutputFormats [in = "+parm1+"]"); if (parm1 == null) return supportedOutputFormats; if (!(parm1 instanceof RGBFormat)) return new Format[0]; RGBFormat irf = (RGBFormat)parm1; RGBFormat orf = (RGBFormat)parm1.clone(); return new Format[]{orf}; } public Format setInputFormat(Format parm1) { /**@todo Implement this javax.media.Codec method*/ //throw new java.lang.UnsupportedOperationException("Method setInputFormat() not yet implemented."); System.out.println("setInputFormat [input = "+parm1+"]"); inputFormat = (RGBFormat)parm1; return (Format)inputFormat; } public Format setOutputFormat(Format parm1) { /**@todo Implement this javax.media.Codec method*/ //throw new java.lang.UnsupportedOperationException("Method setOutputFormat() not yet implemented."); System.out.println("setOutputFormat [ output = "+parm1+"]"); outputFormat = (RGBFormat)parm1; return (Format)outputFormat; } public Format getInputFormat(){ System.out.println("getInputFormat"); return inputFormat; } public Format getOutputFormat(){ System.out.println("getOutputFormat"); return outputFormat; } public int process(Buffer parm1, Buffer parm2) { /**@todo Implement this javax.media.Codec method*/ //throw new java.lang.UnsupportedOperationException("Method process() not yet implemented."); Object o1 = parm1.getData(); int inLength = parm1.getLength(); int inOffset = parm1.getOffset(); if (!(o1 instanceof short[])&&!(o1 instanceof int[])) return this.BUFFER_PROCESSED_FAILED; Object o2 = parm2.getData(); if (o2!=null){ if (!(o2 instanceof short[])&&!(o2 instanceof int[])) return this.BUFFER_PROCESSED_FAILED; }else{ if (o1 instanceof short[]) parm2.setData(new short[inLength]); else parm2.setData(new int[inLength]); o2 = parm2.getData(); } int outOffset = parm2.getOffset(); if (o1 instanceof short[]){ short[] inData = (short[])o1; short[] outData = (short[])o2; for (int i=0;i<inLength;i++) outData[outOffset++] = (short)~inData[inOffset++]; }else{ int[] inData =(int[])o1; int[] outData = (int[])o2; for (int i=0;i<inLength;i++) outData[outOffset++] = ~inData[inOffset++]; } parm2.setFormat(outputFormat); parm2.setLength(inLength); parm2.setOffset(0); return this.BUFFER_PROCESSED_OK; } public String getName() { /**@todo Implement this javax.media.PlugIn method*/ //throw new java.lang.UnsupportedOperationException("Method getName() not yet implemented."); System.out.println("getName"); return EffectName; } public void open() throws javax.media.ResourceUnavailableException { /**@todo Implement this javax.media.PlugIn method*/ //throw new java.lang.UnsupportedOperationException("Method open() not yet implemented."); System.out.println("open"); } public void close() { /**@todo Implement this javax.media.PlugIn method*/ //throw new java.lang.UnsupportedOperationException("Method close() not yet implemented."); System.out.println("close"); } public void reset() { /**@todo Implement this javax.media.PlugIn method*/ //throw new java.lang.UnsupportedOperationException("Method reset() not yet implemented."); System.out.println("reset"); } public Object[] getControls() { /**@todo Implement this javax.media.Controls method*/ //throw new java.lang.UnsupportedOperationException("Method getControls() not yet implemented."); System.out.println("getControls"); return new Controls[0]; } public Object getControl(String parm1) { /**@todo Implement this javax.media.Controls method*/ //throw new java.lang.UnsupportedOperationException("Method getControl() not yet implemented."); System.out.println("getControl [controlType = "+parm1+"]"); try{ Class cls = Class.forName(parm1); Object[] cs = this.getControls(); for (int i=0;i<cs.length;i++){ if (cls.isInstance(cs[i])){ return cs[i]; } } return null; }catch(Exception err){ return null; } }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -