Browse Source

first commit

master
独行之狼 4 years ago
commit
609688f12c
  1. 7
      build.gradle
  2. 125
      build.xml
  3. BIN
      install/fr-plugin-imageProcess-1.0.zip
  4. BIN
      lib/Filters.jar
  5. BIN
      lib/fine-core-10.0.2020.04.26.jar
  6. BIN
      lib/fine-decision-10.0-RELEASE-20200826.160755-1740.jar
  7. BIN
      lib/fine-report-designer-10.0.jar
  8. BIN
      lib/gson-2.3.1.jar
  9. 0
      lib/report/.gitkeep
  10. BIN
      lib/thumbnailator-0.4.8.jar
  11. 97
      plugin-function-image-process.iml
  12. 18
      plugin.xml
  13. 63
      pom.xml
  14. 45
      src/main/java/com/fr/plugin/image/process/FRImageAdjustRGB.java
  15. 57
      src/main/java/com/fr/plugin/image/process/FRImageChrome.java
  16. 44
      src/main/java/com/fr/plugin/image/process/FRImageColorGain.java
  17. 39
      src/main/java/com/fr/plugin/image/process/FRImageColorInvert.java
  18. 46
      src/main/java/com/fr/plugin/image/process/FRImageColorLevel.java
  19. 48
      src/main/java/com/fr/plugin/image/process/FRImageContrast.java
  20. 53
      src/main/java/com/fr/plugin/image/process/FRImageCrystallize.java
  21. 45
      src/main/java/com/fr/plugin/image/process/FRImageDiffusionDither.java
  22. 45
      src/main/java/com/fr/plugin/image/process/FRImageDissolve.java
  23. 48
      src/main/java/com/fr/plugin/image/process/FRImageEmboss.java
  24. 42
      src/main/java/com/fr/plugin/image/process/FRImageExposure.java
  25. 71
      src/main/java/com/fr/plugin/image/process/FRImageFlare.java
  26. 49
      src/main/java/com/fr/plugin/image/process/FRImageFromText.java
  27. 41
      src/main/java/com/fr/plugin/image/process/FRImageGamma.java
  28. 42
      src/main/java/com/fr/plugin/image/process/FRImageGaussianBlur.java
  29. 45
      src/main/java/com/fr/plugin/image/process/FRImageGlow.java
  30. 39
      src/main/java/com/fr/plugin/image/process/FRImageGrayScale.java
  31. 51
      src/main/java/com/fr/plugin/image/process/FRImageMixChannel.java
  32. 42
      src/main/java/com/fr/plugin/image/process/FRImageMosaic.java
  33. 44
      src/main/java/com/fr/plugin/image/process/FRImageOil.java
  34. 43
      src/main/java/com/fr/plugin/image/process/FRImagePosterize.java
  35. 43
      src/main/java/com/fr/plugin/image/process/FRImageReScale.java
  36. 49
      src/main/java/com/fr/plugin/image/process/FRImageScaleRotate.java
  37. 48
      src/main/java/com/fr/plugin/image/process/FRImageSize.java
  38. 39
      src/main/java/com/fr/plugin/image/process/FRImageSolar.java
  39. 46
      src/main/java/com/fr/plugin/image/process/FRImageSparkle.java
  40. 46
      src/main/java/com/fr/plugin/image/process/FRImageStamp.java
  41. 42
      src/main/java/com/fr/plugin/image/process/FRImageTransparency.java
  42. 51
      src/main/java/com/fr/plugin/image/process/FRImageWaterMark.java
  43. 48
      src/main/java/com/fr/plugin/image/process/FRImageWeave.java
  44. 72
      src/main/java/com/fr/plugin/image/process/FunctionConstants.java
  45. 59
      src/main/java/com/fr/plugin/image/process/ImageProcessFunction.java
  46. 10
      src/main/java/com/fr/plugin/image/process/MyLocaleFinder.java
  47. 33
      src/main/java/com/fr/plugin/image/process/Utils/FlarePoint2D.java
  48. 19
      src/main/java/com/fr/plugin/image/process/Utils/PositionNew.java
  49. 6
      src/main/resources/com/fr/com.fr.plugin.imageProcess/imageProcess.properties
  50. 1
      src/main/resources/com/fr/com.fr.plugin.imageProcess/imageProcess_zh_CN.properties

7
build.gradle

@ -0,0 +1,7 @@
/*
* This file was generated by the Gradle 'init' task.
*/
dependencies {
system 'com.fr.com.fr.plugin.imageProcess:gson:1.0'
}

125
build.xml

@ -0,0 +1,125 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<project basedir="." default="jar" name="plugin">
<!-- JDK路径,根据自己机器上实际位置修改-->
<property name="jdk.home" value="I:\Program Files\Java\jdk1.8.0_181" />
<property name="libs" value="${basedir}/lib"/>
<property name="publicLibs" value=""/>
<property name="destLoc" value="."/>
<property name="classes" value="classes"/>
<xmlproperty file="${basedir}/plugin.xml"/>
<property name="current-version" value="1.0"/>
<!-- 插件版本-->
<property name="plugin-version" value="${current-version}"/>
<!-- 插件名字-->
<property name="plugin-name" value="imageProcess"/>
<property name="plugin-jar" value="fr-plugin-${plugin-name}-${plugin-version}.jar"/>
<target name="prepare">
<delete dir="${classes}"/>
<delete dir="fr-plugin-${plugin-name}-${plugin-version}"/>
<xmlproperty file="${basedir}/plugin.xml"/>
<delete dir="${destLoc}/${plugin-name}"/>
</target>
<path id="compile.classpath">
<fileset dir="${libs}">
<include name="**/*.jar"/>
</fileset>
<fileset dir="${publicLibs}">
<include name="**/*.jar"/>
</fileset>
</path>
<patternset id="resources4Jar">
<exclude name="**/.settings/**"/>
<exclude name=".classpath"/>
<exclude name=".project"/>
<exclude name="**/*.java"/>
<exclude name="**/*.db"/>
<exclude name="**/*.g"/>
<exclude name="**/package.html"/>
</patternset>
<target name="copy_resources">
<echo message="从${resources_from}拷贝图片,JS,CSS等资源文件"/>
<delete dir="tmp"/>
<copy todir="tmp">
<fileset dir="${resources_from}\src">
<patternset refid="resources4Jar"/>
</fileset>
</copy>
<copy todir="${classes}">
<fileset dir="tmp"/>
</copy>
<delete dir="tmp"/>
</target>
<target name="compile_javas">
<echo message="编译${compile_files}下的Java文件"/>
<javac destdir="${classes}" debug="false" optimize="on" source="${source_jdk_version}"
target="${target_jdk_version}"
fork="true" memoryMaximumSize="512m" listfiles="false" srcdir="${basedir}"
executable="${compile_jdk_version}/bin/javac">
<src path="${basedir}/src"/>
<exclude name="**/.svn/**"/>
<compilerarg line="-encoding UTF8 "/>
<classpath refid="compile.classpath"/>
</javac>
</target>
<target name="jar_classes">
<echo message="打Jar包:${jar_name}"/>
<delete file="${basedir}/${jar_name}"/>
<jar jarfile="${basedir}/${jar_name}">
<fileset dir="${classes}">
</fileset>
<!--下面加入第三方包-->
<zipfileset excludes="META-INF/*.SF" src="${libs}/Filters.jar"></zipfileset>
<zipfileset excludes="META-INF/*.SF" src="${libs}/thumbnailator-0.4.8.jar"></zipfileset>
</jar>
</target>
<target name="super_jar" depends="prepare">
<antcall target="copy_resources">
<param name="resources_from" value="${basedir}"/>
</antcall>
<antcall target="compile_javas">
<param name="source_jdk_version" value="1.8"/>
<param name="target_jdk_version" value="1.8"/>
<param name="compile_jdk_version" value="${jdk.home}"/>
<param name="compile_files" value="${basedir}/src"/>
</antcall>
<echo message="compile plugin success!"/>
<antcall target="jar_classes">
<param name="jar_name" value="${plugin-jar}"/>
</antcall>
<delete dir="${classes}"/>
</target>
<target name="jar" depends="super_jar">
<antcall target="zip"/>
</target>
<target name="zip">
<property name="plugin-folder" value="fr-plugin-${plugin-name}-${plugin-version}"/>
<echo message="----------zip files----------"/>
<mkdir dir="${plugin-folder}"/>
<copy todir="${plugin-folder}">
<fileset dir=".">
<include name="${plugin-jar}"/>
<include name="plugin.xml"/>
</fileset>
</copy>
<zip destfile="${basedir}/${plugin-folder}.zip" basedir=".">
<include name="${plugin-folder}/*.jar"/>
<include name="${plugin-folder}/plugin.xml"/>
</zip>
<xmlproperty file="${basedir}/plugin.xml"/>
<move file="${plugin-folder}.zip" todir="${destLoc}/install"/>
<delete file="fr-plugin-${plugin-name}-${plugin-version}.jar"/>
</target>
</project>

BIN
install/fr-plugin-imageProcess-1.0.zip

Binary file not shown.

BIN
lib/Filters.jar

Binary file not shown.

BIN
lib/fine-core-10.0.2020.04.26.jar

Binary file not shown.

BIN
lib/fine-decision-10.0-RELEASE-20200826.160755-1740.jar

Binary file not shown.

BIN
lib/fine-report-designer-10.0.jar

Binary file not shown.

BIN
lib/gson-2.3.1.jar

Binary file not shown.

0
lib/report/.gitkeep

BIN
lib/thumbnailator-0.4.8.jar

Binary file not shown.

97
plugin-function-image-process.iml

@ -0,0 +1,97 @@
<?xml version="1.0" encoding="UTF-8"?>
<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_7">
<output url="file://$MODULE_DIR$/../webroot/WEB-INF/plugins/plugin-com.fr.plugin.function.test-1.0/classes" />
<output-test url="file://$MODULE_DIR$/target/test-classes" />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" />
<excludeFolder url="file://$MODULE_DIR$/target" />
<excludeFolder url="file://$MODULE_DIR$/../plugin-function/target" />
</content>
<orderEntry type="jdk" jdkName="1.8" jdkType="JavaSDK" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="module-library">
<library>
<CLASSES>
<root url="jar://$MODULE_DIR$/lib/Filters.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</orderEntry>
<orderEntry type="module-library">
<library>
<CLASSES>
<root url="jar://$MODULE_DIR$/lib/thumbnailator-0.4.8.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</orderEntry>
<orderEntry type="module-library">
<library>
<CLASSES>
<root url="jar://$MODULE_DIR$/../lib/genson-0.99.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</orderEntry>
<orderEntry type="module-library">
<library name="Maven: com.fr.plugin:gson:1.0">
<CLASSES>
<root url="jar://$MODULE_DIR$/lib/gson-2.3.1.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</orderEntry>
<orderEntry type="library" name="Maven: com.fr.core:fine-core:10.0.2020.04.26" level="project" />
<orderEntry type="library" name="Maven: io.netty:netty-all:4.1.17" level="project" />
<orderEntry type="library" name="Maven: com.jcraft:jzlib:1.1.3" level="project" />
<orderEntry type="library" name="Maven: com.fr.third:fine-third:10.0-RELEASE-SNAPSHOT" level="project" />
<orderEntry type="library" name="Maven: com.fr.activator:fine-activator:10.0-RELEASE-SNAPSHOT" level="project" />
<orderEntry type="library" name="Maven: com.fr.webui:fine-webui:10.0-RELEASE-SNAPSHOT" level="project" />
<orderEntry type="library" name="Maven: com.fr.datasource:fine-datasource:10.0-RELEASE-SNAPSHOT" level="project" />
<orderEntry type="library" name="Maven: com.fr.decision:fine-decision:10.0-RELEASE-SNAPSHOT" level="project" />
<orderEntry type="library" name="Maven: com.fr.decision:fine-decision-report:10.0-RELEASE-SNAPSHOT" level="project" />
<orderEntry type="library" name="Maven: com.fr.schedule:fine-schedule:10.0-RELEASE-SNAPSHOT" level="project" />
<orderEntry type="library" name="Maven: com.fr.schedule:fine-schedule-report:10.0-RELEASE-SNAPSHOT" level="project" />
<orderEntry type="library" name="Maven: com.fr.intelligence:fine-swift:10.0-RELEASE-SNAPSHOT" level="project" />
<orderEntry type="library" name="Maven: com.fineio:fineio:10.0-RELEASE-SNAPSHOT" level="project" />
<orderEntry type="library" name="Maven: com.fr.third.server:servlet-api:3.0" level="project" />
<orderEntry type="library" name="Maven: com.fr.intelligence:fine-accumulator:10.0-RELEASE-SNAPSHOT" level="project" />
<orderEntry type="library" name="Maven: com.fr.report:fine-report-engine:10.0-RELEASE-SNAPSHOT" level="project" />
<orderEntry type="library" name="Maven: com.fr.report:fine-report-designer:10.0-RELEASE-SNAPSHOT" level="project" />
<orderEntry type="library" name="Maven: io.socket:socket.io-client:0.7.0" level="project" />
<orderEntry type="library" name="Maven: io.socket:engine.io-client:0.7.0" level="project" />
<orderEntry type="library" name="Maven: com.squareup.okhttp3:okhttp-ws:3.0.1" level="project" />
<orderEntry type="library" name="Maven: com.squareup.okhttp3:okhttp:3.0.1" level="project" />
<orderEntry type="library" name="Maven: com.squareup.okio:okio:1.6.0" level="project" />
<orderEntry type="library" name="Maven: org.json:json:20090211" level="project" />
<orderEntry type="library" name="Maven: org.aspectj:aspectjrt:1.6.9" level="project" />
<orderEntry type="library" name="Maven: org.swingexplorer:swexpl:2.0" level="project" />
<orderEntry type="library" name="Maven: org.swingexplorer:swag:1.0" level="project" />
<orderEntry type="library" name="Maven: org.apache.tomcat:tomcat-catalina:8.5.32" level="project" />
<orderEntry type="library" name="Maven: org.apache.tomcat:tomcat-servlet-api:8.5.32" level="project" />
<orderEntry type="library" name="Maven: org.apache.tomcat:tomcat-jsp-api:8.5.32" level="project" />
<orderEntry type="library" name="Maven: org.apache.tomcat:tomcat-el-api:8.5.32" level="project" />
<orderEntry type="library" name="Maven: org.apache.tomcat:tomcat-juli:8.5.32" level="project" />
<orderEntry type="library" name="Maven: org.apache.tomcat:tomcat-annotations-api:8.5.32" level="project" />
<orderEntry type="library" name="Maven: org.apache.tomcat:tomcat-api:8.5.32" level="project" />
<orderEntry type="library" name="Maven: org.apache.tomcat:tomcat-jni:8.5.32" level="project" />
<orderEntry type="library" name="Maven: org.apache.tomcat:tomcat-coyote:8.5.32" level="project" />
<orderEntry type="library" name="Maven: org.apache.tomcat:tomcat-util:8.5.32" level="project" />
<orderEntry type="library" name="Maven: org.apache.tomcat:tomcat-util-scan:8.5.32" level="project" />
<orderEntry type="library" name="Maven: org.apache.tomcat:tomcat-jaspic-api:8.5.32" level="project" />
<orderEntry type="library" name="Maven: mysql:mysql-connector-java:5.1.44" level="project" />
<orderEntry type="library" name="Maven: com.fr.third:jxbrowser:6.23.1" level="project" />
<orderEntry type="library" name="Maven: com.fr.third:jxbrowser-mac:6.23.1" level="project" />
<orderEntry type="library" name="Maven: com.fr.third:jxbrowser-win64:6.23.1" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: junit:junit:4.12" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.hamcrest:hamcrest-core:1.3" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.easymock:easymock:3.5.1" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.objenesis:objenesis:2.6" level="project" />
</component>
</module>

18
plugin.xml

@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?><plugin>
<id>com.fr.plugin.function.image.process</id>
<name><![CDATA[图像处理函数]]></name>
<active>yes</active>
<version>1.0</version>
<env-version>10.0</env-version>
<jartime>2018-07-31</jartime>
<vendor>all100</vendor>
<description><![CDATA[一组图像处理函数]]></description>
<change-notes><![CDATA[
[2021-3-6]初始化插件。<br/>
]]></change-notes>
<extra-core>
<LocaleFinder class="com.fr.plugin.image.process.MyLocaleFinder"/>
<FunctionGroup class="com.fr.plugin.image.process.ImageProcessFunction" />
</extra-core>
<function-recorder class="com.fr.plugin.image.process.FRImageContrast"/>
</plugin>

63
pom.xml

@ -0,0 +1,63 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.fr.plugin</groupId>
<artifactId>starter</artifactId>
<version>10.0</version>
</parent>
<packaging>jar</packaging>
<artifactId>plugin-function</artifactId>
<dependencies>
<dependency>
<groupId>com.fr.plugin</groupId>
<artifactId>gson</artifactId>
<version>1.0</version>
<scope>system</scope>
<systemPath>${project.basedir}/lib/gson-2.3.1.jar</systemPath>
</dependency>
<dependency>
<groupId>com.fr.core</groupId>
<artifactId>fine-core</artifactId>
<version>10.0-PERSIST-20200326</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.fr.core</groupId>
<artifactId>fine-core</artifactId>
<version>10.0-PERSIST-20200326</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.fr.core</groupId>
<artifactId>fine-core</artifactId>
<version>10.0-PERSIST-20200326</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.fr.core</groupId>
<artifactId>fine-core</artifactId>
<version>10.0.2020.04.26</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.fr.core</groupId>
<artifactId>fine-core</artifactId>
<version>10.0.2020.04.26</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.fr.core</groupId>
<artifactId>fine-core</artifactId>
<version>10.0.2020.04.26</version>
<scope>compile</scope>
</dependency>
</dependencies>
<build>
<!---如果要更改调试插件,改这里的配置就可以了-->
<outputDirectory>${project.basedir}/../webroot/WEB-INF/plugins/plugin-com.fr.plugin.function.test-1.0/classes</outputDirectory>
</build>
</project>

45
src/main/java/com/fr/plugin/image/process/FRImageAdjustRGB.java

@ -0,0 +1,45 @@
package com.fr.plugin.image.process;
import com.fr.intelli.record.Focus;
import com.fr.intelli.record.Original;
import com.fr.plugin.context.PluginContexts;
import com.fr.record.analyzer.EnableMetrics;
import com.fr.script.AbstractFunction;
import com.fr.stable.Primitive;
import com.fr.stable.exception.FormulaException;
import com.fr.stable.fun.Authorize;
import com.jhlabs.image.RGBAdjustFilter;
import java.awt.image.BufferedImage;
//调整图像RGB
@EnableMetrics
@Authorize(callSignKey = FunctionConstants.PLUGIN_ID)
public class FRImageAdjustRGB extends AbstractFunction {
@Override
@Focus(id = FunctionConstants.PLUGIN_ID, text = "Plugin-Test_Function_FRImageAdjustRGB", source = Original.PLUGIN)
public Object run(Object[] args) throws FormulaException {
if (!PluginContexts.currentContext().isAvailable()) {
return FunctionConstants.AUTHOR_ERROR;
}
String checkRes=FunctionConstants.CheckArgs(args,4);
if(!checkRes.equals(FunctionConstants.CHECK_PASS)){
return Primitive.ERROR_VALUE+checkRes;
}
float red = Float.parseFloat(args[1].toString())-1;
float green = Float.parseFloat(args[2].toString())-1;
float blue = Float.parseFloat(args[3].toString())-1;
BufferedImage src = FunctionConstants.readImage(args[0]);
return setFilter(src,red,green,blue);
}
//调整图像RGB
private BufferedImage setFilter(BufferedImage src, float red, float green,float blue) {
BufferedImage result = new BufferedImage(src.getWidth(), src.getHeight(), BufferedImage.TYPE_4BYTE_ABGR);
RGBAdjustFilter rgbAdjustFilter = new RGBAdjustFilter();
rgbAdjustFilter.setRFactor(red);
rgbAdjustFilter.setGFactor(green);
rgbAdjustFilter.setBFactor(blue);
rgbAdjustFilter.filter(src, result);
return result;
}
}

57
src/main/java/com/fr/plugin/image/process/FRImageChrome.java

@ -0,0 +1,57 @@
package com.fr.plugin.image.process;
import com.fr.intelli.record.Focus;
import com.fr.intelli.record.Original;
import com.fr.plugin.context.PluginContexts;
import com.fr.record.analyzer.EnableMetrics;
import com.fr.script.AbstractFunction;
import com.fr.stable.Primitive;
import com.fr.stable.fun.Authorize;
import com.jhlabs.image.ChromeFilter;
import java.awt.image.BufferedImage;
//图像产生各种金属效果和更广泛的非常沉闷的效果
@EnableMetrics
@Authorize(callSignKey = FunctionConstants.PLUGIN_ID)
public class FRImageChrome extends AbstractFunction {
@Focus(id = FunctionConstants.PLUGIN_ID, text = "Plugin-Test_Function_FRImageChrome", source = Original.PLUGIN)
public Object run(Object[] args) {
if (!PluginContexts.currentContext().isAvailable()) {
return FunctionConstants.AUTHOR_ERROR;
}
String checkRes = FunctionConstants.CheckArgs(args, 6);
if (!checkRes.equals(FunctionConstants.CHECK_PASS)) {
return Primitive.ERROR_VALUE + checkRes;
}
int colorSource=1;
BufferedImage src = FunctionConstants.readImage(args[0]);
float bumpSoftness = Float.parseFloat(args[1].toString());
float bumpHeight = Float.parseFloat(args[2].toString());
float amount = Float.parseFloat(args[3].toString());
float exposure = Float.parseFloat(args[4].toString());
final String diffuseColorText=args[5].toString();
int color=FunctionConstants.ColorHexToDec(diffuseColorText);
if(color==-16888888){
return Primitive.ERROR_VALUE + "Color Value";
}
BufferedImage result = setFilter(src, bumpSoftness, bumpHeight,colorSource,amount,exposure,color);
return result;
}
//图像产生各种金属效果和更广泛的非常沉闷的效果
private BufferedImage setFilter(BufferedImage src, float bumpSoftness, float bumpHeight,int colorSource,float amount,float exposure,int color) {
BufferedImage result = new BufferedImage(src.getWidth(), src.getHeight(), BufferedImage.TYPE_4BYTE_ABGR);
ChromeFilter chromeFilter = new ChromeFilter();
chromeFilter.setBumpSoftness(bumpSoftness);
chromeFilter.setBumpHeight(bumpHeight);
chromeFilter.setColorSource(colorSource);
chromeFilter.setAmount(amount);
chromeFilter.setExposure(exposure);
chromeFilter.setDiffuseColor(color);
chromeFilter.filter(src, result);
return result;
}
}

44
src/main/java/com/fr/plugin/image/process/FRImageColorGain.java

@ -0,0 +1,44 @@
package com.fr.plugin.image.process;
import com.fr.intelli.record.Focus;
import com.fr.intelli.record.Original;
import com.fr.plugin.context.PluginContexts;
import com.fr.record.analyzer.EnableMetrics;
import com.fr.script.AbstractFunction;
import com.fr.stable.Primitive;
import com.fr.stable.fun.Authorize;
import com.jhlabs.image.GainFilter;
import java.awt.image.BufferedImage;
//图像增益效果
@EnableMetrics
@Authorize(callSignKey = FunctionConstants.PLUGIN_ID)
public class FRImageColorGain extends AbstractFunction {
@Focus(id = FunctionConstants.PLUGIN_ID, text = "Plugin-Test_Function_FRImageColorGain", source = Original.PLUGIN)
public Object run(Object[] args) {
if (!PluginContexts.currentContext().isAvailable()) {
return FunctionConstants.AUTHOR_ERROR;
}
String checkRes = FunctionConstants.CheckArgs(args, 3);
if (!checkRes.equals(FunctionConstants.CHECK_PASS)) {
return Primitive.ERROR_VALUE + checkRes;
}
BufferedImage src = FunctionConstants.readImage(args[0]);
float gain = Float.parseFloat(args[1].toString());
float bias = Float.parseFloat(args[2].toString());
BufferedImage result = setFilter(src, gain, bias);
return result;
}
//图像增益效果
private BufferedImage setFilter(BufferedImage src, float gain, float bias) {
BufferedImage result = new BufferedImage(src.getWidth(), src.getHeight(), BufferedImage.TYPE_4BYTE_ABGR);
GainFilter gainFilter = new GainFilter();
gainFilter.setGain(gain);
gainFilter.setBias(bias);
gainFilter.filter(src, result);
return result;
}
}

39
src/main/java/com/fr/plugin/image/process/FRImageColorInvert.java

@ -0,0 +1,39 @@
package com.fr.plugin.image.process;
import com.fr.intelli.record.Focus;
import com.fr.intelli.record.Original;
import com.fr.plugin.context.PluginContexts;
import com.fr.record.analyzer.EnableMetrics;
import com.fr.script.AbstractFunction;
import com.fr.stable.Primitive;
import com.fr.stable.fun.Authorize;
import com.jhlabs.image.InvertFilter;
import java.awt.image.BufferedImage;
//设置图像颜色反转
@EnableMetrics
@Authorize(callSignKey = FunctionConstants.PLUGIN_ID)
public class FRImageColorInvert extends AbstractFunction {
@Focus(id = FunctionConstants.PLUGIN_ID, text = "Plugin-Test_Function_FRImageColorInvert", source = Original.PLUGIN)
public Object run(Object[] args) {
if (!PluginContexts.currentContext().isAvailable()) {
return FunctionConstants.AUTHOR_ERROR;
}
String checkRes = FunctionConstants.CheckArgs(args, 1);
if (!checkRes.equals(FunctionConstants.CHECK_PASS)) {
return Primitive.ERROR_VALUE + checkRes;
}
BufferedImage src = FunctionConstants.readImage(args[0]);
BufferedImage result = setFilter(src);
return result;
}
//设置图像颜色反转
private BufferedImage setFilter(BufferedImage src) {
BufferedImage result = new BufferedImage(src.getWidth(), src.getHeight(), BufferedImage.TYPE_4BYTE_ABGR);
InvertFilter invertFilter = new InvertFilter();
invertFilter.filter(src, result);
return result;
}
}

46
src/main/java/com/fr/plugin/image/process/FRImageColorLevel.java

@ -0,0 +1,46 @@
package com.fr.plugin.image.process;
import com.fr.intelli.record.Focus;
import com.fr.intelli.record.Original;
import com.fr.plugin.context.PluginContexts;
import com.fr.record.analyzer.EnableMetrics;
import com.fr.script.AbstractFunction;
import com.fr.stable.Primitive;
import com.fr.stable.fun.Authorize;
import com.jhlabs.image.LevelsFilter;
import java.awt.image.BufferedImage;
//设置图像颜色Level
@EnableMetrics
@Authorize(callSignKey = FunctionConstants.PLUGIN_ID)
public class FRImageColorLevel extends AbstractFunction {
@Focus(id = FunctionConstants.PLUGIN_ID, text = "Plugin-Test_Function_FRImageColorLevel", source = Original.PLUGIN)
public Object run(Object[] args) {
if (!PluginContexts.currentContext().isAvailable()) {
return FunctionConstants.AUTHOR_ERROR;
}
String checkRes = FunctionConstants.CheckArgs(args, 5);
if (!checkRes.equals(FunctionConstants.CHECK_PASS)) {
return Primitive.ERROR_VALUE + checkRes;
}
BufferedImage src = FunctionConstants.readImage(args[0]);
float highLevel = Float.parseFloat(args[1].toString());
float highOutputLevel = Float.parseFloat(args[1].toString());
float lowLevel = Float.parseFloat(args[1].toString());
float lowOutputLevel = Float.parseFloat(args[1].toString());
return setFilter(src,highLevel,highOutputLevel,lowLevel,lowOutputLevel);
}
//设置图像颜色Level
private BufferedImage setFilter(BufferedImage src,float highLevel ,float highOutputLevel, float lowLevel,float lowOutputLevel) {
BufferedImage result = new BufferedImage(src.getWidth(), src.getHeight(), BufferedImage.TYPE_4BYTE_ABGR);
LevelsFilter levelsFilter = new LevelsFilter();
levelsFilter.setHighLevel(highLevel);
levelsFilter.setHighOutputLevel(highOutputLevel);
levelsFilter.setLowLevel(lowLevel);
levelsFilter.setLowOutputLevel(lowOutputLevel);
levelsFilter.filter(src, result);
return result;
}
}

48
src/main/java/com/fr/plugin/image/process/FRImageContrast.java

@ -0,0 +1,48 @@
package com.fr.plugin.image.process;
import com.fr.intelli.record.Focus;
import com.fr.intelli.record.Original;
import com.fr.plugin.context.PluginContexts;
import com.fr.record.analyzer.EnableMetrics;
import com.fr.script.AbstractFunction;
import com.fr.stable.Primitive;
import com.fr.stable.fun.Authorize;
import com.jhlabs.image.ContrastFilter;
import java.awt.image.BufferedImage;
//调整亮度对比度
@EnableMetrics
@Authorize(callSignKey = FunctionConstants.PLUGIN_ID)
public class FRImageContrast extends AbstractFunction {
@Focus(id = FunctionConstants.PLUGIN_ID, text = "Plugin-Test_Function_FRImageContrast", source = Original.PLUGIN)
public Object run(Object[] args) {
if (!PluginContexts.currentContext().isAvailable()) {
return FunctionConstants.AUTHOR_ERROR;
}
String checkRes = FunctionConstants.CheckArgs(args, 3);
if (!checkRes.equals(FunctionConstants.CHECK_PASS)) {
return Primitive.ERROR_VALUE + checkRes;
}
BufferedImage src = FunctionConstants.readImage(args[0]);
float contrast = Float.parseFloat(args[1].toString());
float brightness = Float.parseFloat(args[2].toString());
BufferedImage result = setFilter(src, contrast, brightness);
return result;
}
//调整亮度对比度
private BufferedImage setFilter(BufferedImage src, float contrast, float brightness) {
BufferedImage result = new BufferedImage(src.getWidth(), src.getHeight(), BufferedImage.TYPE_4BYTE_ABGR);
ContrastFilter contrastFilter = new ContrastFilter();
contrastFilter.setContrast(contrast);
contrastFilter.setBrightness(brightness);
contrastFilter.filter(src, result);
return result;
}
}

53
src/main/java/com/fr/plugin/image/process/FRImageCrystallize.java

@ -0,0 +1,53 @@
package com.fr.plugin.image.process;
import com.fr.intelli.record.Focus;
import com.fr.intelli.record.Original;
import com.fr.plugin.context.PluginContexts;
import com.fr.record.analyzer.EnableMetrics;
import com.fr.script.AbstractFunction;
import com.fr.stable.Primitive;
import com.fr.stable.fun.Authorize;
import com.jhlabs.image.CrystallizeFilter;
import java.awt.image.BufferedImage;
//设置图像结晶化效果
@EnableMetrics
@Authorize(callSignKey = FunctionConstants.PLUGIN_ID)
public class FRImageCrystallize extends AbstractFunction {
@Focus(id = FunctionConstants.PLUGIN_ID, text = "Plugin-Test_Function_FRImageCrystallize", source = Original.PLUGIN)
public Object run(Object[] args) {
if (!PluginContexts.currentContext().isAvailable()) {
return FunctionConstants.AUTHOR_ERROR;
}
String checkRes = FunctionConstants.CheckArgs(args, 6);
if (!checkRes.equals(FunctionConstants.CHECK_PASS)) {
return Primitive.ERROR_VALUE + checkRes;
}
BufferedImage src = FunctionConstants.readImage(args[0]);
float scale = Float.parseFloat(args[1].toString());
float randomness = Float.parseFloat(args[2].toString());
float edgeThickness = Float.parseFloat(args[3].toString());
int gridType=Integer.parseInt(args[4].toString());
String colorText=args[5].toString();
int color=FunctionConstants.ColorHexToDec(colorText);
if(color==-16888888){
return Primitive.ERROR_VALUE + "Color Value!";
}
BufferedImage result = setFilter(src, scale,randomness,edgeThickness,gridType,color);
return result;
}
//设置图像结晶化效果
private BufferedImage setFilter(BufferedImage src, float scale,float randomness,float edgeThickness,int gridType,int color) {
BufferedImage result = new BufferedImage(src.getWidth(), src.getHeight(), BufferedImage.TYPE_4BYTE_ABGR);
CrystallizeFilter crystallizeFilter = new CrystallizeFilter();
crystallizeFilter.setScale(scale);
crystallizeFilter.setRandomness(randomness);
crystallizeFilter.setEdgeThickness(edgeThickness);
crystallizeFilter.setGridType(gridType);
crystallizeFilter.setEdgeColor(color);
crystallizeFilter.filter(src, result);
return result;
}
}

45
src/main/java/com/fr/plugin/image/process/FRImageDiffusionDither.java

@ -0,0 +1,45 @@
package com.fr.plugin.image.process;
import com.fr.intelli.record.Focus;
import com.fr.intelli.record.Original;
import com.fr.plugin.context.PluginContexts;
import com.fr.record.analyzer.EnableMetrics;
import com.fr.script.AbstractFunction;
import com.fr.stable.Primitive;
import com.fr.stable.exception.FormulaException;
import com.fr.stable.fun.Authorize;
import com.jhlabs.image.DiffusionFilter;
import java.awt.image.BufferedImage;
//调整发散抖动
@EnableMetrics
@Authorize(callSignKey = FunctionConstants.PLUGIN_ID)
public class FRImageDiffusionDither extends AbstractFunction {
@Override
@Focus(id = FunctionConstants.PLUGIN_ID, text = "Plugin-Test_Function_FRImageDiffusionDither", source = Original.PLUGIN)
public Object run(Object[] args) throws FormulaException {
if (!PluginContexts.currentContext().isAvailable()) {
return FunctionConstants.AUTHOR_ERROR;
}
String checkRes=FunctionConstants.CheckArgs(args,4);
if(!checkRes.equals(FunctionConstants.CHECK_PASS)){
return Primitive.ERROR_VALUE+checkRes;
}
int levels = Integer.parseInt(args[1].toString());
boolean serpentine = Boolean.parseBoolean(args[2].toString());
boolean colorDither = Boolean.parseBoolean(args[3].toString());
BufferedImage src = FunctionConstants.readImage(args[0]);
return setFilter(src,levels,serpentine,colorDither);
}
//调整发散抖动
private BufferedImage setFilter(BufferedImage src, int levels, boolean serpentine,boolean colorDither) {
BufferedImage result = new BufferedImage(src.getWidth(), src.getHeight(), BufferedImage.TYPE_4BYTE_ABGR);
DiffusionFilter diffusionFilter = new DiffusionFilter();
diffusionFilter.setLevels(levels);
diffusionFilter.setColorDither(colorDither);
diffusionFilter.setSerpentine(serpentine);
diffusionFilter.filter(src,result);
return result;
}
}

45
src/main/java/com/fr/plugin/image/process/FRImageDissolve.java

@ -0,0 +1,45 @@
package com.fr.plugin.image.process;
import com.fr.intelli.record.Focus;
import com.fr.intelli.record.Original;
import com.fr.plugin.context.PluginContexts;
import com.fr.record.analyzer.EnableMetrics;
import com.fr.script.AbstractFunction;
import com.fr.stable.Primitive;
import com.fr.stable.fun.Authorize;
import com.jhlabs.image.DissolveFilter;
import java.awt.image.BufferedImage;
//设置图像溶解效果
@EnableMetrics
@Authorize(callSignKey = FunctionConstants.PLUGIN_ID)
public class FRImageDissolve extends AbstractFunction {
@Focus(id = FunctionConstants.PLUGIN_ID, text = "Plugin-Test_Function_FRImageDissolve", source = Original.PLUGIN)
public Object run(Object[] args) {
if (!PluginContexts.currentContext().isAvailable()) {
return FunctionConstants.AUTHOR_ERROR;
}
String checkRes = FunctionConstants.CheckArgs(args, 3);
if (!checkRes.equals(FunctionConstants.CHECK_PASS)) {
return Primitive.ERROR_VALUE + checkRes;
}
BufferedImage src = FunctionConstants.readImage(args[0]);
float density = Float.parseFloat(args[1].toString());
float softness = Float.parseFloat(args[2].toString());
BufferedImage result = setFilter(src, density, softness);
return result;
}
//设置图像溶解效果
private BufferedImage setFilter(BufferedImage src, float density, float softness) {
BufferedImage result = new BufferedImage(src.getWidth(), src.getHeight(), BufferedImage.TYPE_4BYTE_ABGR);
DissolveFilter dissolveFilter = new DissolveFilter();
dissolveFilter.setDensity(density);
dissolveFilter.setSoftness(softness);
dissolveFilter.filter(src, result);
return result;
}
}

48
src/main/java/com/fr/plugin/image/process/FRImageEmboss.java

@ -0,0 +1,48 @@
package com.fr.plugin.image.process;
import com.fr.intelli.record.Focus;
import com.fr.intelli.record.Original;
import com.fr.plugin.context.PluginContexts;
import com.fr.record.analyzer.EnableMetrics;
import com.fr.script.AbstractFunction;
import com.fr.stable.Primitive;
import com.fr.stable.fun.Authorize;
import com.jhlabs.image.EmbossFilter;
import java.awt.image.BufferedImage;
//设置浮雕图像
@EnableMetrics
@Authorize(callSignKey = FunctionConstants.PLUGIN_ID)
public class FRImageEmboss extends AbstractFunction {
@Focus(id = FunctionConstants.PLUGIN_ID, text = "Plugin-Test_Function_FRImageEmboss", source = Original.PLUGIN)
public Object run(Object[] args) {
if (!PluginContexts.currentContext().isAvailable()) {
return FunctionConstants.AUTHOR_ERROR;
}
String checkRes = FunctionConstants.CheckArgs(args, 5);
if (!checkRes.equals(FunctionConstants.CHECK_PASS)) {
return Primitive.ERROR_VALUE + checkRes;
}
BufferedImage src = FunctionConstants.readImage(args[0]);
float azimuth = Float.parseFloat(args[1].toString());
float bumpHeight = Float.parseFloat(args[2].toString());
float elevation=Float.parseFloat(args[3].toString());
boolean emboss=Boolean.parseBoolean(args[4].toString());
BufferedImage result = setFilter(src, azimuth,bumpHeight,elevation,emboss);
return result;
}
//设置浮雕图像
private BufferedImage setFilter(BufferedImage src, float azimuth,float bumpHeight,float elevation,boolean emboss) {
BufferedImage result = new BufferedImage(src.getWidth(), src.getHeight(), BufferedImage.TYPE_4BYTE_ABGR);
EmbossFilter embossFilter = new EmbossFilter();
embossFilter.setAzimuth(azimuth);
embossFilter.setBumpHeight(bumpHeight);
embossFilter.setElevation(elevation);
embossFilter.setEmboss(emboss);
embossFilter.filter(src, result);
return result;
}
}

42
src/main/java/com/fr/plugin/image/process/FRImageExposure.java

@ -0,0 +1,42 @@
package com.fr.plugin.image.process;
import com.fr.intelli.record.Focus;
import com.fr.intelli.record.Original;
import com.fr.plugin.context.PluginContexts;
import com.fr.record.analyzer.EnableMetrics;
import com.fr.script.AbstractFunction;
import com.fr.stable.Primitive;
import com.fr.stable.exception.FormulaException;
import com.fr.stable.fun.Authorize;
import com.jhlabs.image.ExposureFilter;
import java.awt.image.BufferedImage;
//调整胶片曝光
@EnableMetrics
@Authorize(callSignKey = FunctionConstants.PLUGIN_ID)
public class FRImageExposure extends AbstractFunction {
@Override
@Focus(id = FunctionConstants.PLUGIN_ID, text = "Plugin-Test_Function_FRImageExposure", source = Original.PLUGIN)
public Object run(Object[] args) throws FormulaException {
if (!PluginContexts.currentContext().isAvailable()) {
return FunctionConstants.AUTHOR_ERROR;
}
String checkRes=FunctionConstants.CheckArgs(args,2);
if(!checkRes.equals(FunctionConstants.CHECK_PASS)){
return Primitive.ERROR_VALUE+checkRes;
}
float levels = Float.parseFloat(args[1].toString());
BufferedImage src = FunctionConstants.readImage(args[0]);
return setFilter(src,levels);
}
//调整胶片曝光
private BufferedImage setFilter(BufferedImage src, float levels) {
BufferedImage result = new BufferedImage(src.getWidth(), src.getHeight(), BufferedImage.TYPE_4BYTE_ABGR);
ExposureFilter exposureFilter = new ExposureFilter();
exposureFilter.setExposure(levels);
exposureFilter.filter(src,result);
return result;
}
}

71
src/main/java/com/fr/plugin/image/process/FRImageFlare.java

@ -0,0 +1,71 @@
package com.fr.plugin.image.process;
import com.fr.plugin.image.process.Utils.FlarePoint2D;
import com.fr.intelli.record.Focus;
import com.fr.intelli.record.Original;
import com.fr.plugin.context.PluginContexts;
import com.fr.record.analyzer.EnableMetrics;
import com.fr.script.AbstractFunction;
import com.fr.stable.Primitive;
import com.fr.stable.fun.Authorize;
import com.jhlabs.image.FlareFilter;
import java.awt.geom.Point2D;
import java.awt.image.BufferedImage;
//图像产生各种闪光效果
@EnableMetrics
@Authorize(callSignKey = FunctionConstants.PLUGIN_ID)
public class FRImageFlare extends AbstractFunction {
@Focus(id = FunctionConstants.PLUGIN_ID, text = "Plugin-Test_Function_FRImageFlare", source = Original.PLUGIN)
public Object run(Object[] args) {
if (!PluginContexts.currentContext().isAvailable()) {
return FunctionConstants.AUTHOR_ERROR;
}
String checkRes = FunctionConstants.CheckArgs(args, 9);
if (!checkRes.equals(FunctionConstants.CHECK_PASS)) {
return Primitive.ERROR_VALUE + checkRes;
}
BufferedImage src = FunctionConstants.readImage(args[0]);
double pointX = Double.parseDouble(args[1].toString());
double pointY = Double.parseDouble(args[2].toString());
float radius = Float.parseFloat(args[3].toString());
float baseAmount = Float.parseFloat(args[4].toString());
float ringAmount = Float.parseFloat(args[5].toString());
float ringWidth = Float.parseFloat(args[6].toString());
float rayAmount = Float.parseFloat(args[7].toString());
final String colorText=args[8].toString();
int color=FunctionConstants.ColorHexToDec(colorText);
if(color==-16888888){
return Primitive.ERROR_VALUE + "Color Value";
}
BufferedImage result = setFilter(src, pointX, pointY,radius,baseAmount,ringAmount,ringWidth,rayAmount,color);
return result;
}
//图像产生各种闪光效果
private BufferedImage setFilter(BufferedImage src, double pointX, double pointY,float radius,float baseAmount,float ringAmount,float ringWidth, float rayAmount,int color) {
BufferedImage result = new BufferedImage(src.getWidth(), src.getHeight(), BufferedImage.TYPE_4BYTE_ABGR);
Point2D point2D =new FlarePoint2D();
point2D.setLocation(pointX,pointY);
FlareFilter flareFilter = new FlareFilter();
flareFilter.setCentre(point2D);
flareFilter.setBaseAmount(baseAmount);
flareFilter.setRadius(radius);
flareFilter.setRayAmount(rayAmount);
flareFilter.setRingAmount(ringAmount);
flareFilter.setRingWidth(ringWidth);
flareFilter.setColor(color);
flareFilter.filter(src, result);
return result;
}
}

49
src/main/java/com/fr/plugin/image/process/FRImageFromText.java

@ -0,0 +1,49 @@
package com.fr.plugin.image.process;
import com.fr.intelli.record.Focus;
import com.fr.intelli.record.Original;
import com.fr.plugin.context.PluginContexts;
import com.fr.record.analyzer.EnableMetrics;
import com.fr.script.AbstractFunction;
import com.fr.stable.exception.FormulaException;
import com.fr.stable.fun.Authorize;
import java.awt.*;
import java.awt.geom.AffineTransform;
import java.awt.image.BufferedImage;
//将文本转换为图像
@EnableMetrics
@Authorize(callSignKey = FunctionConstants.PLUGIN_ID)
public class FRImageFromText extends AbstractFunction {
@Focus(id = FunctionConstants.PLUGIN_ID, text = "Plugin-Test_Function_FRImageFromText", source = Original.PLUGIN)
@Override
public Object run(Object[] args) throws FormulaException {
if (!PluginContexts.currentContext().isAvailable()) {
return FunctionConstants.AUTHOR_ERROR;
}
String text = args[0].toString();
int fontSize = Integer.parseInt(args[1].toString());
int width = Integer.parseInt(args[2].toString());
int height = Integer.parseInt(args[3].toString());
return ImageFromText(text, fontSize, width, height);
}
private BufferedImage ImageFromText(String text, int fontSize, int width, int height) {
BufferedImage img = new BufferedImage(width, height, BufferedImage.TYPE_4BYTE_ABGR);
Graphics2D g2 = img.createGraphics();
Font font = new Font("黑体", Font.BOLD, fontSize);
FontMetrics fm = g2.getFontMetrics(font);
int textWidth = fm.stringWidth(text);
int widthX = (width - textWidth) / 2;
int heightY = (height - fontSize) / 2;
AffineTransform affineTransform = new AffineTransform();
Font rotatedFont = font.deriveFont(affineTransform);
g2.setFont(rotatedFont);
g2.setColor(new Color(0, 0, 0));
g2.drawString(text, widthX, heightY);
g2.dispose();
return img;
}
}

41
src/main/java/com/fr/plugin/image/process/FRImageGamma.java

@ -0,0 +1,41 @@
package com.fr.plugin.image.process;
import com.fr.intelli.record.Focus;
import com.fr.intelli.record.Original;
import com.fr.plugin.context.PluginContexts;
import com.fr.record.analyzer.EnableMetrics;
import com.fr.script.AbstractFunction;
import com.fr.stable.Primitive;
import com.fr.stable.fun.Authorize;
import com.jhlabs.image.GammaFilter;
import java.awt.image.BufferedImage;
//设置图像伽玛线效果
@EnableMetrics
@Authorize(callSignKey = FunctionConstants.PLUGIN_ID)
public class FRImageGamma extends AbstractFunction {
@Focus(id = FunctionConstants.PLUGIN_ID, text = "Plugin-Test_Function_FRImageGamma", source = Original.PLUGIN)
public Object run(Object[] args) {
if (!PluginContexts.currentContext().isAvailable()) {
return FunctionConstants.AUTHOR_ERROR;
}
String checkRes = FunctionConstants.CheckArgs(args, 2);
if (!checkRes.equals(FunctionConstants.CHECK_PASS)) {
return Primitive.ERROR_VALUE + checkRes;
}
BufferedImage src = FunctionConstants.readImage(args[0]);
float gamma = Float.parseFloat(args[1].toString());
BufferedImage result = setFilter(src, gamma);
return result;
}
//设置图像伽玛线效果
private BufferedImage setFilter(BufferedImage src, float gamma) {
BufferedImage result = new BufferedImage(src.getWidth(), src.getHeight(), BufferedImage.TYPE_4BYTE_ABGR);
GammaFilter gammaFilter = new GammaFilter();
gammaFilter.setGamma(gamma);
gammaFilter.filter(src, result);
return result;
}
}

42
src/main/java/com/fr/plugin/image/process/FRImageGaussianBlur.java

@ -0,0 +1,42 @@
package com.fr.plugin.image.process;
import com.fr.intelli.record.Focus;
import com.fr.intelli.record.Original;
import com.fr.plugin.context.PluginContexts;
import com.fr.record.analyzer.EnableMetrics;
import com.fr.script.AbstractFunction;
import com.fr.stable.Primitive;
import com.fr.stable.fun.Authorize;
import com.jhlabs.image.GaussianFilter;
import java.awt.image.BufferedImage;
//图像上执行高斯模糊
@EnableMetrics
@Authorize(callSignKey = FunctionConstants.PLUGIN_ID)
public class FRImageGaussianBlur extends AbstractFunction {
@Focus(id = FunctionConstants.PLUGIN_ID, text = "Plugin-Test_Function_FRImageTritone", source = Original.PLUGIN)
public Object run(Object[] args) {
if (!PluginContexts.currentContext().isAvailable()) {
return FunctionConstants.AUTHOR_ERROR;
}
String checkRes = FunctionConstants.CheckArgs(args, 2);
if (!checkRes.equals(FunctionConstants.CHECK_PASS)) {
return Primitive.ERROR_VALUE + checkRes;
}
BufferedImage src = FunctionConstants.readImage(args[0]);
float radius=Float.parseFloat(args[1].toString());
BufferedImage result = setFilter(src,radius);
return result;
}
//图像上执行高斯模糊
private BufferedImage setFilter(BufferedImage src,float radius) {
BufferedImage result = new BufferedImage(src.getWidth(), src.getHeight(), BufferedImage.TYPE_4BYTE_ABGR);
GaussianFilter gaussianFilter = new GaussianFilter();
gaussianFilter.setRadius(radius);
gaussianFilter.filter(src, result);
return result;
}
}

45
src/main/java/com/fr/plugin/image/process/FRImageGlow.java

@ -0,0 +1,45 @@
package com.fr.plugin.image.process;
import com.fr.intelli.record.Focus;
import com.fr.intelli.record.Original;
import com.fr.plugin.context.PluginContexts;
import com.fr.record.analyzer.EnableMetrics;
import com.fr.script.AbstractFunction;
import com.fr.stable.Primitive;
import com.fr.stable.fun.Authorize;
import com.jhlabs.image.GlowFilter;
import java.awt.image.BufferedImage;
//图像产生发光效果
@EnableMetrics
@Authorize(callSignKey = FunctionConstants.PLUGIN_ID)
public class FRImageGlow extends AbstractFunction {
@Focus(id = FunctionConstants.PLUGIN_ID, text = "Plugin-Test_Function_FRImageGlow", source = Original.PLUGIN)
public Object run(Object[] args) {
if (!PluginContexts.currentContext().isAvailable()) {
return FunctionConstants.AUTHOR_ERROR;
}
String checkRes = FunctionConstants.CheckArgs(args, 3);
if (!checkRes.equals(FunctionConstants.CHECK_PASS)) {
return Primitive.ERROR_VALUE + checkRes;
}
BufferedImage src = FunctionConstants.readImage(args[0]);
float radius = Float.parseFloat(args[1].toString());
float amount = Float.parseFloat(args[2].toString());
BufferedImage result = setFilter(src, radius, amount);
return result;
}
//图像产生发光效果
private BufferedImage setFilter(BufferedImage src, float radius, float amount) {
BufferedImage result = new BufferedImage(src.getWidth(), src.getHeight(), BufferedImage.TYPE_4BYTE_ABGR);
GlowFilter glowFilter = new GlowFilter();
glowFilter.setRadius(radius);
glowFilter.setAmount(amount);
glowFilter.filter(src, result);
return result;
}
}

39
src/main/java/com/fr/plugin/image/process/FRImageGrayScale.java

@ -0,0 +1,39 @@
package com.fr.plugin.image.process;
import com.fr.intelli.record.Focus;
import com.fr.intelli.record.Original;
import com.fr.plugin.context.PluginContexts;
import com.fr.record.analyzer.EnableMetrics;
import com.fr.script.AbstractFunction;
import com.fr.stable.Primitive;
import com.fr.stable.fun.Authorize;
import com.jhlabs.image.GrayscaleFilter;
import java.awt.image.BufferedImage;
//设置灰度图像
@EnableMetrics
@Authorize(callSignKey = FunctionConstants.PLUGIN_ID)
public class FRImageGrayScale extends AbstractFunction {
@Focus(id =FunctionConstants.PLUGIN_ID, text = "Plugin-Test_Function_FRImageGrayScale", source = Original.PLUGIN)
public Object run(Object[] args) {
if (!PluginContexts.currentContext().isAvailable()) {
return FunctionConstants.AUTHOR_ERROR;
}
String checkRes = FunctionConstants.CheckArgs(args, 1);
if (!checkRes.equals(FunctionConstants.CHECK_PASS)) {
return Primitive.ERROR_VALUE + checkRes;
}
BufferedImage src = FunctionConstants.readImage(args[0]);
BufferedImage result = setFilter(src);
return result;
}
//设置灰度图像
private BufferedImage setFilter(BufferedImage src) {
BufferedImage result = new BufferedImage(src.getWidth(), src.getHeight(), BufferedImage.TYPE_4BYTE_ABGR);
GrayscaleFilter grayscaleFilter = new GrayscaleFilter();
grayscaleFilter.filter(src, result);
return result;
}
}

51
src/main/java/com/fr/plugin/image/process/FRImageMixChannel.java

@ -0,0 +1,51 @@
package com.fr.plugin.image.process;
import com.fr.intelli.record.Focus;
import com.fr.intelli.record.Original;
import com.fr.plugin.context.PluginContexts;
import com.fr.record.analyzer.EnableMetrics;
import com.fr.script.AbstractFunction;
import com.fr.stable.Primitive;
import com.fr.stable.fun.Authorize;
import com.jhlabs.image.ChannelMixFilter;
import java.awt.image.BufferedImage;
//混合图像RGB通道
@EnableMetrics
@Authorize(callSignKey = FunctionConstants.PLUGIN_ID)
public class FRImageMixChannel extends AbstractFunction {
@Focus(id = FunctionConstants.PLUGIN_ID, text = "Plugin-Test_Function_FRImageMixChannel", source = Original.PLUGIN)
public Object run(Object[] args) {
if (!PluginContexts.currentContext().isAvailable()) {
return FunctionConstants.AUTHOR_ERROR;
}
String checkRes = FunctionConstants.CheckArgs(args, 7);
if (!checkRes.equals(FunctionConstants.CHECK_PASS)) {
return Primitive.ERROR_VALUE + checkRes;
}
BufferedImage src = FunctionConstants.readImage(args[0]);
int blueGreen = Integer.parseInt(args[1].toString());
int intoR = Integer.parseInt(args[1].toString());
int redBlue = Integer.parseInt(args[1].toString());
int intoG = Integer.parseInt(args[1].toString());
int greenRed = Integer.parseInt(args[1].toString());
int intoB = Integer.parseInt(args[1].toString());
return setFilter(src,blueGreen,intoR,redBlue,intoG,greenRed,intoB);
}
//混合图像RGB通道
private BufferedImage setFilter(BufferedImage src,int blueGreen,int intoR, int redBlue,int intoG,int greenRed,int intoB) {
BufferedImage result = new BufferedImage(src.getWidth(), src.getHeight(), BufferedImage.TYPE_4BYTE_ABGR);
ChannelMixFilter channelMixFilter = new ChannelMixFilter();
channelMixFilter.setBlueGreen(blueGreen);
channelMixFilter.setIntoR(intoR);
channelMixFilter.setRedBlue(redBlue);
channelMixFilter.setIntoG(intoG);
channelMixFilter.setGreenRed(greenRed);
channelMixFilter.setIntoB(intoB);
channelMixFilter.filter(src, result);
return result;
}
}

42
src/main/java/com/fr/plugin/image/process/FRImageMosaic.java

@ -0,0 +1,42 @@
package com.fr.plugin.image.process;
import com.fr.intelli.record.Focus;
import com.fr.intelli.record.Original;
import com.fr.plugin.context.PluginContexts;
import com.fr.record.analyzer.EnableMetrics;
import com.fr.script.AbstractFunction;
import com.fr.stable.Primitive;
import com.fr.stable.fun.Authorize;
import com.jhlabs.image.BlockFilter;
import java.awt.image.BufferedImage;
//设置图像马赛克
@EnableMetrics
@Authorize(callSignKey = FunctionConstants.PLUGIN_ID)
public class FRImageMosaic extends AbstractFunction {
@Focus(id = FunctionConstants.PLUGIN_ID, text = "Plugin-Test_Function_FRImageMosaic", source = Original.PLUGIN)
public Object run(Object[] args) {
if (!PluginContexts.currentContext().isAvailable()) {
return FunctionConstants.AUTHOR_ERROR;
}
String checkRes = FunctionConstants.CheckArgs(args, 2);
if (!checkRes.equals(FunctionConstants.CHECK_PASS)) {
return Primitive.ERROR_VALUE + checkRes;
}
BufferedImage src = FunctionConstants.readImage(args[0]);
int blockSize = Integer.parseInt(args[1].toString());
BufferedImage result = setFilter(src, blockSize);
return result;
}
//设置图像马赛克
private BufferedImage setFilter(BufferedImage src, int blockSize) {
BufferedImage result = new BufferedImage(src.getWidth(), src.getHeight(), BufferedImage.TYPE_4BYTE_ABGR);
BlockFilter blockFilter = new BlockFilter();
blockFilter.setBlockSize(blockSize);
blockFilter.filter(src, result);
return result;
}
}

44
src/main/java/com/fr/plugin/image/process/FRImageOil.java

@ -0,0 +1,44 @@
package com.fr.plugin.image.process;
import com.fr.intelli.record.Focus;
import com.fr.intelli.record.Original;
import com.fr.plugin.context.PluginContexts;
import com.fr.record.analyzer.EnableMetrics;
import com.fr.script.AbstractFunction;
import com.fr.stable.Primitive;
import com.fr.stable.fun.Authorize;
import com.jhlabs.image.OilFilter;
import java.awt.image.BufferedImage;
//设置图像油画效果
@EnableMetrics
@Authorize(callSignKey = FunctionConstants.PLUGIN_ID)
public class FRImageOil extends AbstractFunction {
@Focus(id = FunctionConstants.PLUGIN_ID, text = "Plugin-Test_Function_FRImageOil", source = Original.PLUGIN)
public Object run(Object[] args) {
if (!PluginContexts.currentContext().isAvailable()) {
return FunctionConstants.AUTHOR_ERROR;
}
String checkRes = FunctionConstants.CheckArgs(args, 3);
if (!checkRes.equals(FunctionConstants.CHECK_PASS)) {
return Primitive.ERROR_VALUE + checkRes;
}
BufferedImage src = FunctionConstants.readImage(args[0]);
int level = Integer.parseInt(args[1].toString());
int range=Integer.parseInt(args[2].toString());
BufferedImage result = setFilter(src, level,range);
return result;
}
//设置图像油画效果
private BufferedImage setFilter(BufferedImage src, int level,int range) {
BufferedImage result = new BufferedImage(src.getWidth(), src.getHeight(), BufferedImage.TYPE_4BYTE_ABGR);
OilFilter oilFilter = new OilFilter();
oilFilter.setLevels(level);
oilFilter.setRange(range);
oilFilter.filter(src, result);
return result;
}
}

43
src/main/java/com/fr/plugin/image/process/FRImagePosterize.java

@ -0,0 +1,43 @@
package com.fr.plugin.image.process;
import com.fr.intelli.record.Focus;
import com.fr.intelli.record.Original;
import com.fr.plugin.context.PluginContexts;
import com.fr.record.analyzer.EnableMetrics;
import com.fr.script.AbstractFunction;
import com.fr.stable.Primitive;
import com.fr.stable.fun.Authorize;
import com.jhlabs.image.PosterizeFilter;
import java.awt.image.BufferedImage;
//设置图像招贴画
@EnableMetrics
@Authorize(callSignKey = FunctionConstants.PLUGIN_ID)
public class FRImagePosterize extends AbstractFunction {
@Focus(id =FunctionConstants.PLUGIN_ID, text = "Plugin-Test_Function_FRImagePosterize", source = Original.PLUGIN)
public Object run(Object[] args) {
if (!PluginContexts.currentContext().isAvailable()) {
return FunctionConstants.AUTHOR_ERROR;
}
String checkRes = FunctionConstants.CheckArgs(args, 2);
if (!checkRes.equals(FunctionConstants.CHECK_PASS)) {
return Primitive.ERROR_VALUE + checkRes;
}
BufferedImage src = FunctionConstants.readImage(args[0]);
int numLevels = Integer.parseInt(args[1].toString());
BufferedImage result = setFilter(src, numLevels);
return result;
}
//设置图像招贴画
private BufferedImage setFilter(BufferedImage src, int numLevels) {
BufferedImage result = new BufferedImage(src.getWidth(), src.getHeight(), BufferedImage.TYPE_4BYTE_ABGR);
PosterizeFilter posterizeFilter = new PosterizeFilter();
posterizeFilter.setNumLevels(numLevels);
posterizeFilter.filter(src, result);
return result;
}
}

43
src/main/java/com/fr/plugin/image/process/FRImageReScale.java

@ -0,0 +1,43 @@
package com.fr.plugin.image.process;
import com.fr.intelli.record.Focus;
import com.fr.intelli.record.Original;
import com.fr.plugin.context.PluginContexts;
import com.fr.record.analyzer.EnableMetrics;
import com.fr.script.AbstractFunction;
import com.fr.stable.Primitive;
import com.fr.stable.fun.Authorize;
import com.jhlabs.image.RescaleFilter;
import java.awt.image.BufferedImage;
//图像重新调节
@EnableMetrics
@Authorize(callSignKey = FunctionConstants.PLUGIN_ID)
public class FRImageReScale extends AbstractFunction {
@Focus(id = FunctionConstants.PLUGIN_ID, text = "Plugin-Test_Function_FRImageReScale", source = Original.PLUGIN)
public Object run(Object[] args) {
if (!PluginContexts.currentContext().isAvailable()) {
return FunctionConstants.AUTHOR_ERROR;
}
String checkRes = FunctionConstants.CheckArgs(args, 2);
if (!checkRes.equals(FunctionConstants.CHECK_PASS)) {
return Primitive.ERROR_VALUE + checkRes;
}
BufferedImage src = FunctionConstants.readImage(args[0]);
float reScale = Float.parseFloat(args[1].toString());
BufferedImage result = setFilter(src, reScale);
return result;
}
//图像重新调节
private BufferedImage setFilter(BufferedImage src, float reScale) {
BufferedImage result = new BufferedImage(src.getWidth(), src.getHeight(), BufferedImage.TYPE_4BYTE_ABGR);
RescaleFilter rescaleFilter = new RescaleFilter();
rescaleFilter.setScale(reScale);
rescaleFilter.filter(src, result);
return result;
}
}

49
src/main/java/com/fr/plugin/image/process/FRImageScaleRotate.java

@ -0,0 +1,49 @@
package com.fr.plugin.image.process;
import com.fr.intelli.record.Focus;
import com.fr.intelli.record.Original;
import com.fr.plugin.context.PluginContexts;
import com.fr.record.analyzer.EnableMetrics;
import com.fr.script.AbstractFunction;
import com.fr.stable.Primitive;
import com.fr.stable.exception.FormulaException;
import com.fr.stable.fun.Authorize;
import net.coobird.thumbnailator.Thumbnails;
import java.awt.image.BufferedImage;
import java.io.IOException;
//设置图像旋转缩放
@EnableMetrics
@Authorize(callSignKey = FunctionConstants.PLUGIN_ID)
public class FRImageScaleRotate extends AbstractFunction {
@Override
@Focus(id = FunctionConstants.PLUGIN_ID, text = "Plugin-Test_Function_FRImageScaleRotate", source = Original.PLUGIN)
public Object run(Object[] args) throws FormulaException {
if (!PluginContexts.currentContext().isAvailable()) {
return FunctionConstants.AUTHOR_ERROR;
}
String checkRes = FunctionConstants.CheckArgs(args, 3);
if (!checkRes.equals(FunctionConstants.CHECK_PASS)) {
return Primitive.ERROR_VALUE + checkRes;
}
BufferedImage src = FunctionConstants.readImage(args[0]);
float scale = Float.parseFloat((args[1].toString()));
float rotate = Float.parseFloat((args[2].toString()));
BufferedImage result = null;
try {
result = setFilter(src, scale, rotate);
} catch (IOException e) {
e.printStackTrace();
}
return result;
}
//设置图像旋转缩放
private BufferedImage setFilter(BufferedImage src, float scale, float rotate) throws IOException {
BufferedImage result = Thumbnails.of(src).scale(scale).rotate(rotate).asBufferedImage();
return result;
}
}

48
src/main/java/com/fr/plugin/image/process/FRImageSize.java

@ -0,0 +1,48 @@
package com.fr.plugin.image.process;
import com.fr.intelli.record.Focus;
import com.fr.intelli.record.Original;
import com.fr.plugin.context.PluginContexts;
import com.fr.record.analyzer.EnableMetrics;
import com.fr.script.AbstractFunction;
import com.fr.stable.Primitive;
import com.fr.stable.exception.FormulaException;
import com.fr.stable.fun.Authorize;
import net.coobird.thumbnailator.Thumbnails;
import java.awt.image.BufferedImage;
import java.io.IOException;
//调整图像大小
@EnableMetrics
@Authorize(callSignKey = FunctionConstants.PLUGIN_ID)
public class FRImageSize extends AbstractFunction {
@Override
@Focus(id = FunctionConstants.PLUGIN_ID, text = "Plugin-Test_Function_FRImageSize", source = Original.PLUGIN)
public Object run(Object[] args) throws FormulaException {
if (!PluginContexts.currentContext().isAvailable()) {
return FunctionConstants.AUTHOR_ERROR;
}
String checkRes=FunctionConstants.CheckArgs(args,4);
if(!checkRes.equals(FunctionConstants.CHECK_PASS)){
return Primitive.ERROR_VALUE+checkRes;
}
int width = Integer.parseInt((args[1].toString()));
int height = Integer.parseInt((args[2].toString()));
boolean rateScale = Boolean.parseBoolean(args[3].toString());
BufferedImage src = FunctionConstants.readImage(args[0]);
BufferedImage result=null;
try {
result= setFilter(src,width,height,rateScale);
} catch (IOException e) {
e.printStackTrace();
}
return result;
}
//调整图像大小
private BufferedImage setFilter(BufferedImage src, int width, int height,boolean rateScale) throws IOException {
BufferedImage result= Thumbnails.of(src).size(width,height).keepAspectRatio(rateScale).asBufferedImage();
return result;
}
}

39
src/main/java/com/fr/plugin/image/process/FRImageSolar.java

@ -0,0 +1,39 @@
package com.fr.plugin.image.process;
import com.fr.intelli.record.Focus;
import com.fr.intelli.record.Original;
import com.fr.plugin.context.PluginContexts;
import com.fr.record.analyzer.EnableMetrics;
import com.fr.script.AbstractFunction;
import com.fr.stable.Primitive;
import com.fr.stable.fun.Authorize;
import com.jhlabs.image.SolarizeFilter;
import java.awt.image.BufferedImage;
//图像过度曝光
@EnableMetrics
@Authorize(callSignKey = FunctionConstants.PLUGIN_ID)
public class FRImageSolar extends AbstractFunction {
@Focus(id = FunctionConstants.PLUGIN_ID, text = "Plugin-Test_Function_FRImageSolar", source = Original.PLUGIN)
public Object run(Object[] args) {
if (!PluginContexts.currentContext().isAvailable()) {
return FunctionConstants.AUTHOR_ERROR;
}
String checkRes = FunctionConstants.CheckArgs(args, 1);
if (!checkRes.equals(FunctionConstants.CHECK_PASS)) {
return Primitive.ERROR_VALUE + checkRes;
}
BufferedImage src = FunctionConstants.readImage(args[0]);
BufferedImage result = setFilter(src);
return result;
}
//图像过度曝光
private BufferedImage setFilter(BufferedImage src) {
BufferedImage result = new BufferedImage(src.getWidth(), src.getHeight(), BufferedImage.TYPE_4BYTE_ABGR);
SolarizeFilter solarizeFilter = new SolarizeFilter();
solarizeFilter.filter(src, result);
return result;
}
}

46
src/main/java/com/fr/plugin/image/process/FRImageSparkle.java

@ -0,0 +1,46 @@
package com.fr.plugin.image.process;
import com.fr.intelli.record.Focus;
import com.fr.intelli.record.Original;
import com.fr.plugin.context.PluginContexts;
import com.fr.record.analyzer.EnableMetrics;
import com.fr.script.AbstractFunction;
import com.fr.stable.Primitive;
import com.fr.stable.fun.Authorize;
import com.jhlabs.image.SparkleFilter;
import java.awt.image.BufferedImage;
//生成图像闪耀效果
@EnableMetrics
@Authorize(callSignKey = FunctionConstants.PLUGIN_ID)
public class FRImageSparkle extends AbstractFunction {
@Focus(id = FunctionConstants.PLUGIN_ID, text = "Plugin-Test_Function_FRImageSparkle", source = Original.PLUGIN)
public Object run(Object[] args) {
if (!PluginContexts.currentContext().isAvailable()) {
return FunctionConstants.AUTHOR_ERROR;
}
String checkRes = FunctionConstants.CheckArgs(args, 4);
if (!checkRes.equals(FunctionConstants.CHECK_PASS)) {
return Primitive.ERROR_VALUE + checkRes;
}
BufferedImage src = FunctionConstants.readImage(args[0]);
int radius =Integer.parseInt(args[1].toString());
int randomness =Integer.parseInt(args[2].toString());
int rays =Integer.parseInt(args[3].toString());
BufferedImage result = setFilter(src, radius,randomness,rays);
return result;
}
//生成图像闪耀效果
private BufferedImage setFilter(BufferedImage src,int radius,int randomness,int rays) {
BufferedImage result = new BufferedImage(src.getWidth(), src.getHeight(), BufferedImage.TYPE_4BYTE_ABGR);
SparkleFilter sparkleFilter = new SparkleFilter();
sparkleFilter.setRadius(radius);
sparkleFilter.setRandomness(randomness);
sparkleFilter.setRays(rays);
sparkleFilter.filter(src, result);
return result;
}
}

46
src/main/java/com/fr/plugin/image/process/FRImageStamp.java

@ -0,0 +1,46 @@
package com.fr.plugin.image.process;
import com.fr.intelli.record.Focus;
import com.fr.intelli.record.Original;
import com.fr.plugin.context.PluginContexts;
import com.fr.record.analyzer.EnableMetrics;
import com.fr.script.AbstractFunction;
import com.fr.stable.Primitive;
import com.fr.stable.fun.Authorize;
import com.jhlabs.image.StampFilter;
import java.awt.image.BufferedImage;
//生成图像黑白图章效果
@EnableMetrics
@Authorize(callSignKey = FunctionConstants.PLUGIN_ID)
public class FRImageStamp extends AbstractFunction {
@Focus(id = FunctionConstants.PLUGIN_ID, text = "Plugin-Test_Function_FRImageStamp", source = Original.PLUGIN)
public Object run(Object[] args) {
if (!PluginContexts.currentContext().isAvailable()) {
return FunctionConstants.AUTHOR_ERROR;
}
String checkRes = FunctionConstants.CheckArgs(args, 4);
if (!checkRes.equals(FunctionConstants.CHECK_PASS)) {
return Primitive.ERROR_VALUE + checkRes;
}
BufferedImage src = FunctionConstants.readImage(args[0]);
float radius = Float.parseFloat(args[1].toString());
float softness = Float.parseFloat(args[2].toString());
float threshold = Float.parseFloat(args[3].toString());
BufferedImage result = setFilter(src, radius,softness,threshold);
return result;
}
//生成图像黑白图章效果
private BufferedImage setFilter(BufferedImage src,float radius,float softness,float threshold) {
BufferedImage result = new BufferedImage(src.getWidth(), src.getHeight(), BufferedImage.TYPE_4BYTE_ABGR);
StampFilter stampFilter = new StampFilter();
stampFilter.setRadius(radius);
stampFilter.setThreshold(threshold);
stampFilter.setSoftness(softness);
stampFilter.filter(src, result);
return result;
}
}

42
src/main/java/com/fr/plugin/image/process/FRImageTransparency.java

@ -0,0 +1,42 @@
package com.fr.plugin.image.process;
import com.fr.intelli.record.Focus;
import com.fr.intelli.record.Original;
import com.fr.plugin.context.PluginContexts;
import com.fr.record.analyzer.EnableMetrics;
import com.fr.script.AbstractFunction;
import com.fr.stable.Primitive;
import com.fr.stable.fun.Authorize;
import com.jhlabs.image.OpacityFilter;
import java.awt.image.BufferedImage;
//设置图像不透明级别
@EnableMetrics
@Authorize(callSignKey = FunctionConstants.PLUGIN_ID)
public class FRImageTransparency extends AbstractFunction {
@Focus(id = FunctionConstants.PLUGIN_ID, text = "Plugin-Test_Function_FRImageTransparency", source = Original.PLUGIN)
public Object run(Object[] args) {
if (!PluginContexts.currentContext().isAvailable()) {
return FunctionConstants.AUTHOR_ERROR;
}
String checkRes = FunctionConstants.CheckArgs(args, 2);
if (!checkRes.equals(FunctionConstants.CHECK_PASS)) {
return Primitive.ERROR_VALUE + checkRes;
}
BufferedImage src = FunctionConstants.readImage(args[0]);
int opacity = Integer.parseInt(args[1].toString());
BufferedImage result = setFilter(src, opacity);
return result;
}
//设置图像不透明级别
private BufferedImage setFilter(BufferedImage src, int opacity) {
BufferedImage result = new BufferedImage(src.getWidth(), src.getHeight(), BufferedImage.TYPE_4BYTE_ABGR);
OpacityFilter opacityFilter = new OpacityFilter();
opacityFilter.setOpacity(opacity);
opacityFilter.filter(src, result);
return result;
}
}

51
src/main/java/com/fr/plugin/image/process/FRImageWaterMark.java

@ -0,0 +1,51 @@
package com.fr.plugin.image.process;
import com.fr.plugin.image.process.Utils.PositionNew;
import com.fr.intelli.record.Focus;
import com.fr.intelli.record.Original;
import com.fr.plugin.context.PluginContexts;
import com.fr.record.analyzer.EnableMetrics;
import com.fr.script.AbstractFunction;
import com.fr.stable.Primitive;
import com.fr.stable.exception.FormulaException;
import com.fr.stable.fun.Authorize;
import net.coobird.thumbnailator.Thumbnails;
import java.awt.image.BufferedImage;
import java.io.IOException;
//给图像增加水印
@EnableMetrics
@Authorize(callSignKey = FunctionConstants.PLUGIN_ID)
public class FRImageWaterMark extends AbstractFunction {
@Override
@Focus(id = FunctionConstants.PLUGIN_ID, text = "Plugin-Test_Function_FRImageWaterMark", source = Original.PLUGIN)
public Object run(Object[] args) throws FormulaException {
if (!PluginContexts.currentContext().isAvailable()) {
return FunctionConstants.AUTHOR_ERROR;
}
String checkRes=FunctionConstants.CheckArgs(args,5);
if(!checkRes.equals(FunctionConstants.CHECK_PASS)){
return Primitive.ERROR_VALUE+checkRes;
}
BufferedImage src = FunctionConstants.readImage(args[0]);
int left = Integer.parseInt((args[1].toString()));
int right = Integer.parseInt((args[2].toString()));
BufferedImage waterMark = FunctionConstants.readImage(args[3]);
float opacity = Float.parseFloat(args[4].toString());
BufferedImage result=null;
try {
result= setFilter(src,left,right,waterMark,opacity);
} catch (IOException e) {
e.printStackTrace();
}
return result;
}
//给图像增加水印
private BufferedImage setFilter(BufferedImage src, int left, int right,BufferedImage waterMark,float opacity) throws IOException {
PositionNew positionNew=new PositionNew(left,right);
BufferedImage result= Thumbnails.of(src).watermark(positionNew,waterMark,opacity).scale(1).asBufferedImage();
return result;
}
}

48
src/main/java/com/fr/plugin/image/process/FRImageWeave.java

@ -0,0 +1,48 @@
package com.fr.plugin.image.process;
import com.fr.intelli.record.Focus;
import com.fr.intelli.record.Original;
import com.fr.plugin.context.PluginContexts;
import com.fr.record.analyzer.EnableMetrics;
import com.fr.script.AbstractFunction;
import com.fr.stable.Primitive;
import com.fr.stable.fun.Authorize;
import com.jhlabs.image.WeaveFilter;
import java.awt.image.BufferedImage;
//图像编织化
@EnableMetrics
@Authorize(callSignKey = FunctionConstants.PLUGIN_ID)
public class FRImageWeave extends AbstractFunction {
@Focus(id = FunctionConstants.PLUGIN_ID, text = "Plugin-Test_Function_FRImageWeave", source = Original.PLUGIN)
public Object run(Object[] args) {
if (!PluginContexts.currentContext().isAvailable()) {
return FunctionConstants.AUTHOR_ERROR;
}
String checkRes = FunctionConstants.CheckArgs(args, 5);
if (!checkRes.equals(FunctionConstants.CHECK_PASS)) {
return Primitive.ERROR_VALUE + checkRes;
}
BufferedImage src = FunctionConstants.readImage(args[0]);
float XWidth = Float.parseFloat(args[1].toString());
float YWidth = Float.parseFloat(args[2].toString());
float XGap = Float.parseFloat(args[3].toString());
float YGap = Float.parseFloat(args[4].toString());
BufferedImage result = setFilter(src, XWidth, YWidth,XGap,YGap);
return result;
}
//图像编织化
private BufferedImage setFilter(BufferedImage src, float XWidth, float YWidth,float XGap,float YGap) {
BufferedImage result = new BufferedImage(src.getWidth(), src.getHeight(), BufferedImage.TYPE_4BYTE_ABGR);
WeaveFilter weaveFilter = new WeaveFilter();
weaveFilter.setXWidth(XWidth);
weaveFilter.setYWidth(YWidth);
weaveFilter.setXGap(XGap);
weaveFilter.setXGap(YGap);
weaveFilter.filter(src, result);
return result;
}
}

72
src/main/java/com/fr/plugin/image/process/FunctionConstants.java

@ -0,0 +1,72 @@
package com.fr.plugin.image.process;
import com.fr.stable.ArrayUtils;
import javax.imageio.ImageIO;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import static com.fr.design.i18n.Toolkit.i18nText;
//定义常用方法变量
public class FunctionConstants {
static final String PLUGIN_ID = "com.fr.plugin.function.image.process";
static final String AUTHOR_ERROR=i18nText("Plugin.Function.ImagProcess_AUTHOR_ERROR");
static final String CHECK_PASS=i18nText("Plugin.Function.ImagProcess_CHECK_PASS");
static BufferedImage readImage(Object file) {
BufferedImage res;
if(file instanceof BufferedImage){
return (BufferedImage)file;
}
String filename=file.toString();
File fn = new File(filename);
try {
ImageIO.setUseCache(false);
res = ImageIO.read(fn);
} catch (IOException e) {
throw new Error(filename + i18nText("Plugin.Function.ImagProcess_ReadImageError"));
}
return res;
}
static String CheckArgs(Object[] args,int num){
String res=FunctionConstants.CHECK_PASS;
int len = ArrayUtils.getLength(args);
if (len != num) {
return i18nText("Plugin.Function.ImagProcess_ArgsCountError");
}
if(!(args[0] instanceof BufferedImage)){
String filename=args[0].toString();
File fn = new File(filename);
if (!(fn.exists())) {
return filename + i18nText("Plugin.Function.ImagProcess_FileNotFind");
}
}
return res;
}
static int ColorHexToDec(String ColorText){
if(ColorText.length()!=6){
return -16888888;
}
final int red = Integer.parseInt(ColorText.substring(0, 2), 16);
final int blue = Integer.parseInt(ColorText.substring(2, 4), 16);
final int green = Integer.parseInt(ColorText.substring(4, 6), 16);
if(red>255||red<0){
return -16888888;
}
if(blue>255||blue<0){
return -16888888;
}
if(green>255||green<0){
return -16888888;
}
Color color=new Color(red,blue,green);
int c=color.getRGB();
return c;
}
}

59
src/main/java/com/fr/plugin/image/process/ImageProcessFunction.java

@ -0,0 +1,59 @@
package com.fr.plugin.image.process;
import com.fr.intelli.record.Focus;
import com.fr.record.analyzer.EnableMetrics;
import com.fr.stable.fun.impl.AbstractFunctionDefContainer;
import com.fr.stable.script.FunctionDef;
/**
* @author all100
* @version 10.0
* Created by all100 on 2021-02-20
**/
@EnableMetrics
public class ImageProcessFunction extends AbstractFunctionDefContainer {
@Override
@Focus(id=FunctionConstants.PLUGIN_ID, text="图像处理函数")
public FunctionDef[] getFunctionDefs() {
return new FunctionDef[]{
new FunctionDef( "FRImageFromText","功能:\n文本生成图像,可以让其它函数再次处理。 \n参数说明:\n参数1:文本内容。\n参数2:文本字号,整数。\n参数3:图像宽度,整数。\n参数4:图像高度,整数。",FRImageFromText.class.getName()),
new FunctionDef( "FRImageContrast","功能:\n设置图像亮度、对比度。 \n参数说明:\n参数1:图像文件路径,如:c:\\1.png,或包含图像、图像文件路径的单元格。\n参数2:图像对比度,取值范围:0-2。\n参数3:图像亮度,取值范围:0-2。",FRImageContrast.class.getName()),
new FunctionDef( "FRImageAdjustRGB","功能:\n设置图像RGB通道。 \n参数说明:\n参数1:图像文件路径,如:c:\\1.png,或包含图像、图像文件路径的单元格。\n参数2:图像Red通道,取值范围:0-2。\n参数3:图像Green通道 ,取值范围:0-2,\n参数4:图像Blue通道 ,取值范围:0-2。",FRImageAdjustRGB.class.getName()),
new FunctionDef( "FRImageDiffusionDither","功能:\n设置图像发散抖动。 \n参数说明:\n参数1:图像文件路径,如:c:\\1.png,或包含图像、图像文件路径的单元格。\n参数2:图像抖动层级,取值范围:2、4、5、6、8、16。\n参数3:图像是否花纹抖动 ,取值范围:true或false,\n参数4:图像是否颜色抖动 ,取值范围:true或false。",FRImageDiffusionDither.class.getName()),
new FunctionDef( "FRImageExposure","功能:\n设置图像胶片曝光。 \n参数说明:\n参数1:图像文件路径,如:c:\\1.png,或包含图像、图像文件路径的单元格。\n参数2:调整胶片曝光层级,取值范围:0-5。",FRImageExposure.class.getName()),
new FunctionDef( "FRImageSize","功能:\n设置图像大小。 \n参数说明:\n参数1:图像文件路径,如:c:\\1.png,或包含图像、图像文件路径的单元格。\n参数2:调整宽度。\n参数3:调整高度。\n参数4:是否遵循原图比例调整大小 。",FRImageSize.class.getName()),
new FunctionDef( "FRImageWaterMark","功能:\n给图像增加水印。 \n参数说明:\n参数1:图像文件路径,如:c:\\1.png,或包含图像、图像文件路径的单元格。\n参数2:水印左边距。\n参数3:水印顶边距。\n参数4:水印内容。\n参数5:水印不透明级别,取值范围:0-1。",FRImageWaterMark.class.getName()),
new FunctionDef( "FRImageScaleRotate","功能:\n设置图像旋转缩放。\n参数说明:\n参数1:图像文件路径,如:c:\\1.png,或包含图像、图像文件路径的单元格。\n参数2:缩放比例,取值范围:0-1。\n参数3:旋转度数,取值范围:0-360。",FRImageScaleRotate.class.getName()),
new FunctionDef( "FRImageColorGain","功能:\n图像增益效果。\n参数说明:\n参数1:图像文件路径,如:c:\\1.png,或包含图像、图像文件路径的单元格。\n参数2:增益值,取值范围:0-1。\n参数3:偏置值,取值范围:0-1。",FRImageColorGain.class.getName()),
new FunctionDef( "FRImageGamma","功能:\n设置图像伽玛。\n参数说明:\n参数1:图像文件路径,如:c:\\1.png,或包含图像、图像文件路径的单元格。\n参数2:伽玛值,取值范围:0-3。",FRImageGamma.class.getName()),
new FunctionDef( "FRImageGrayScale","功能:\n设置图像灰度化。\n参数说明:\n参数1:图像文件路径,如:c:\\1.png,或包含图像、图像文件路径的单元格。",FRImageGrayScale.class.getName()),
new FunctionDef( "FRImageColorInvert","功能:\n设置图像颜色反转。\n参数说明:\n参数1:图像文件路径,如:c:\\1.png,或包含图像、图像文件路径的单元格。",FRImageColorInvert.class.getName()),
new FunctionDef( "FRImageColorLevel","功能:\n设置图像颜色Level。\n参数说明:\n参数1:图像文件路径,如:c:\\1.png,或包含图像、图像文件路径的单元格。\n参数2:highLevel,取值范围:0-1。\n参数3:highOutputLevel,取值范围:0-1。\n参数4:lowLevel,取值范围:0-1。\n参数5:lowOutputLevel,取值范围:0-1。",FRImageColorLevel.class.getName()),
new FunctionDef( "FRImageMixChannel","功能:\n混合图像RGB通道。\n参数说明:\n参数1:图像文件路径,如:c:\\1.png,或包含图像、图像文件路径的单元格。\n参数2:blueGreen,取值范围:0-255。\n参数3:intoRed,取值范围:0-255。\n参数4:redBlue,取值范围:0-255。\n参数5:intoGreen,取值范围:0-255。\n参数6:greenRed,取值范围:0-255。\n参数7:intoBlue,取值范围:0-255。",FRImageMixChannel.class.getName()),
new FunctionDef( "FRImagePosterize","功能:\n设置图像招贴画。\n参数说明:\n参数1:图像文件路径,如:c:\\1.png,或包含图像、图像文件路径的单元格。\n参数2:招贴画层级,取值范围:1-30。",FRImagePosterize.class.getName()),
new FunctionDef( "FRImageReScale","功能:\n图像重新调节。\n参数说明:\n参数1:图像文件路径,如:c:\\1.png,或包含图像、图像文件路径的单元格。\n参数2:图像重新调节因子,取值范围:0-5。",FRImageReScale.class.getName()),
new FunctionDef( "FRImageSolar","功能:\n设置图像过度曝光。\n参数说明:\n参数1:图像文件路径,如:c:\\1.png,或包含图像、图像文件路径的单元格。",FRImageSolar.class.getName()),
new FunctionDef( "FRImageTransparency","功能:\n设置图像不透明级别。\n参数说明:\n参数1:图像文件路径,如:c:\\1.png,或包含图像、图像文件路径的单元格。\n参数2:图像不透明级别,取值范围(整数):0-255。",FRImageTransparency.class.getName()),
new FunctionDef( "FRImageGaussianBlur","功能:\n设置图像高斯模糊。\n参数说明:\n参数1:图像文件路径,如:c:\\1.png,或包含图像、图像文件路径的单元格。\n参数2:图像高斯模糊半径,取值范围(浮点):0-100。",FRImageGaussianBlur.class.getName()),
new FunctionDef( "FRImageEmboss","功能:\n设置浮雕图像。\n参数说明:\n参数1:图像文件路径,如:c:\\1.png,或包含图像、图像文件路径的单元格。\n参数2:azimuth,取值范围(浮点):0-6.28。\n参数3:bumpHeight,取值范围(浮点):0-1。\n参数4:elevation,取值范围(浮点):0-1.57。\n参数5:emboss,取值范围(布尔):true或false。",FRImageEmboss.class.getName()),
new FunctionDef( "FRImageMosaic","功能:\n设置图像马赛克。\n参数说明:\n参数1:图像文件路径,如:c:\\1.png,或包含图像、图像文件路径的单元格。\n参数2:设置图像马赛克大小,取值范围(整数):0-100。",FRImageMosaic.class.getName()),
new FunctionDef( "FRImageWeave","功能:\n设置图像编织化。\n参数说明:\n参数1:图像文件路径,如:c:\\1.png,或包含图像、图像文件路径的单元格。\n参数2:XWidth,编织带横向宽度,取值范围(浮点):1-256。\n参数3:YWidth,编织带纵向宽度,取值范围(浮点):1-256。\n参数4:XGap,编织空横向宽度,取值范围(浮点):1-256。\n参数5:YGap,编织空纵向宽度,取值范围(浮点):1-256。",FRImageWeave.class.getName()),
new FunctionDef( "FRImageGlow","功能:\n设置图像产生发光效果。\n参数说明:\n参数1:图像文件路径,如:c:\\1.png,或包含图像、图像文件路径的单元格。\n参数2:发光半径,取值范围(浮点):0-100。\n参数3:amount,发光数值,取值范围(浮点):0-100。",FRImageGlow.class.getName()),
new FunctionDef( "FRImageDissolve","功能:\n设置图像溶解效果。\n参数说明:\n参数1:图像文件路径,如:c:\\1.png,或包含图像、图像文件路径的单元格。\n参数2:图像溶解密度,取值范围(浮点):0-100。\n参数3:图像溶解柔软度,取值范围(浮点):0-100。",FRImageDissolve.class.getName()),
new FunctionDef( "FRImageChrome","功能:\n图像产生各种金属效果和更广泛的非常沉闷的效果。\n参数说明:\n参数1:图像文件路径,如:c:\\1.png,或包含图像、图像文件路径的单元格。\n参数2:柔软度bumpSoftness,取值范围:0-50(浮点)。\n参数3:bumpHeight高度,取值范围(浮点):0-5。\n参数4:amount,取值范围(浮点):0-100。\n参数5:exposure,取值范围(浮点):0-5。\n参数6:diffuseColor,取值范围(16进制6位颜色范围,文本用引号括起来):000000-FFFFFF。",FRImageChrome.class.getName()),
new FunctionDef( "FRImageFlare","功能:\n图像产生各种闪光效果。\n参数说明:\n参数1:图像文件路径,如:c:\\1.png,或包含图像、图像文件路径的单元格。\n参数2:光源横坐标,取值范围(浮点):0-1。\n参数3:光源纵坐标,取值范围(浮点):0-1。\n参数4:光源半径,取值范围(浮点):0-400。\n参数5:光源数量,取值范围(浮点):0-100。\n参数6:光源环数量,取值范围(浮点):0-100。\n参数7:光源环宽度,取值范围(浮点):0-10。\n参数8:光源数量,取值范围(浮点):0-100。\n参数9:光源颜色,取值范围(16进制6位颜色范围,文本用引号括起来):000000-FFFFFF。",FRImageFlare.class.getName()),
new FunctionDef( "FRImageOil","功能:\n设置图像油画效果。 \n参数说明:\n参数1:图像文件路径,如:c:\\1.png,或包含图像、图像文件路径的单元格。\n参数2:设置层级,取值范围(整数):1-256。\n参数3:设置油画半径,取值范围(整数):1-5。",FRImageOil.class.getName()),
new FunctionDef( "FRImageCrystallize","功能:\n设置图像结晶化效果。 \n参数说明:\n参数1:图像文件路径,如:c:\\1.png,或包含图像、图像文件路径的单元格。\n参数2:设置结晶化颗粒大小,取值范围(浮点):1-10。\n参数3:设置结晶化随机性,取值范围(浮点):0-1。\n参数4:设置边界,取值范围(浮点):0-1。\n参数5:设置结晶化类型,取值范围(整数):1-4。\n参数9:结晶化边界颜色,取值范围(16进制6位颜色范围,文本用引号括起来):000000-FFFFFF。",FRImageCrystallize.class.getName()),
new FunctionDef( "FRImageStamp","功能:\n生成图像黑白图章效果。\n参数说明:\n参数1:图像文件路径,如:c:\\1.png,或包含图像、图像文件路径的单元格。\n参数2:效果半径,取值范围(浮点):0-100。\n参数3:图像溶解柔软度,取值范围(浮点):0-1。\n参数4:图像阈,取值范围(浮点):0-1。",FRImageStamp.class.getName()),
new FunctionDef( "FRImageSparkle","功能:\n生成图像闪耀效果。\n参数说明:\n参数1:图像文件路径,如:c:\\1.png,或包含图像、图像文件路径的单元格。\n参数2:闪耀效果半径,取值范围(整数):0-300。\n参数3:图像闪耀随机性,取值范围(整数):0-50。\n参数4:光线数量,取值范围(整数):0-300。",FRImageSparkle.class.getName()),
};
}
@Override
public String getGroupName() {
return "ImageProcessFunction";
}
}

10
src/main/java/com/fr/plugin/image/process/MyLocaleFinder.java

@ -0,0 +1,10 @@
package com.fr.plugin.image.process;
import com.fr.stable.fun.impl.AbstractLocaleFinder;
public class MyLocaleFinder extends AbstractLocaleFinder {
@Override
public String find() {
return "com/fr/plugin/image/process";
}
}

33
src/main/java/com/fr/plugin/image/process/Utils/FlarePoint2D.java

@ -0,0 +1,33 @@
package com.fr.plugin.image.process.Utils;
import java.awt.geom.Point2D;
//生成闪光点
public class FlarePoint2D extends Point2D {
double x;
double y;
public FlarePoint2D() {
}
public FlarePoint2D(double x, double y) {
this.x = x;
this.y = y;
}
@Override
public double getX() {
return this.x;
}
@Override
public double getY() {
return this.y;
}
@Override
public void setLocation(double x, double y) {
this.x=x;
this.y=y;
}
}

19
src/main/java/com/fr/plugin/image/process/Utils/PositionNew.java

@ -0,0 +1,19 @@
package com.fr.plugin.image.process.Utils;
import net.coobird.thumbnailator.geometry.Position;
import java.awt.*;
//生成坐标点
public final class PositionNew implements Position {
private int x;
private int y;
public PositionNew(int x, int y) {
this.x=x;
this.y=y;
}
@Override
public Point calculate(int i, int i1, int i2, int i3, int i4, int i5, int i6, int i7) {
return new Point(this.x,this.y);
}
}

6
src/main/resources/com/fr/com.fr.plugin.imageProcess/imageProcess.properties

@ -0,0 +1,6 @@
Plugin.Function.ImagProcess_ID=com.fr.plugin.function.imagProcess
Plugin.Function.ImagProcess_AUTHOR_ERROR=Error:authorization is expired
Plugin.Function.ImagProcess_CHECK_PASS=checkPass
Plugin.Function.ImagProcess_ReadImageError=Read Image Error!
Plugin.Function.ImagProcess_ArgsCountError=Args Count Error!
Plugin.Function.ImagProcess_FileNotFind=File not Find!

1
src/main/resources/com/fr/com.fr.plugin.imageProcess/imageProcess_zh_CN.properties

@ -0,0 +1 @@
Plugin-Test_Function_Abs=测试ABS函数
Loading…
Cancel
Save