/* */ package com.jhlabs.image;
/* */
/* */ import com.jhlabs.math.Function2D;
/* */ import com.jhlabs.math.ImageFunction2D;
/* */ import com.jhlabs.vecmath.Color4f;
/* */ import com.jhlabs.vecmath.Vector3f;
/* */ import java.awt.Color;
/* */ import java.awt.Image;
/* */ import java.awt.Rectangle;
/* */ import java.awt.image.BufferedImage;
/* */ import java.awt.image.Kernel;
/* */ import java.util.Vector;
/* */
/* */ public class LightFilter extends WholeImageFilter
/* */ {
/* */ public static final int COLORS_FROM_IMAGE = 0;
/* */ public static final int COLORS_CONSTANT = 1;
/* */ public static final int BUMPS_FROM_IMAGE = 0;
/* */ public static final int BUMPS_FROM_IMAGE_ALPHA = 1;
/* */ public static final int BUMPS_FROM_MAP = 2;
/* */ public static final int BUMPS_FROM_BEVEL = 3;
/* */ private float bumpHeight;
/* */ private float bumpSoftness;
/* */ private int bumpShape;
/* 64 */ private float viewDistance = 10000.0F;
/* */ Material material;
/* */ private Vector lights;
/* 67 */ private int colorSource = 0;
/* 68 */ private int bumpSource = 0;
/* */ private Function2D bumpFunction;
/* */ private Image environmentMap;
/* */ private int[] envPixels;
/* 72 */ private int envWidth = 1; private int envHeight = 1;
/* */ private Vector3f l;
/* */ private Vector3f v;
/* */ private Vector3f n;
/* */ private Color4f shadedColor;
/* */ private Color4f diffuse_color;
/* */ private Color4f specular_color;
/* */ private Vector3f tmpv;
/* */ private Vector3f tmpv2;
/* */ protected static final float r255 = 0.003921569F;
/* */ public static final int AMBIENT = 0;
/* */ public static final int DISTANT = 1;
/* */ public static final int POINT = 2;
/* */ public static final int SPOT = 3;
/* */
/* */ public LightFilter()
/* */ {
/* 84 */ this.lights = new Vector();
/* 85 */ addLight(new DistantLight());
/* 86 */ this.bumpHeight = 1.0F;
/* 87 */ this.bumpSoftness = 5.0F;
/* 88 */ this.bumpShape = 0;
/* 89 */ this.material = new Material();
/* 90 */ this.l = new Vector3f();
/* 91 */ this.v = new Vector3f();
/* 92 */ this.n = new Vector3f();
/* 93 */ this.shadedColor = new Color4f();
/* 94 */ this.diffuse_color = new Color4f();
/* 95 */ this.specular_color = new Color4f();
/* 96 */ this.tmpv = new Vector3f();
/* 97 */ this.tmpv2 = new Vector3f();
/* */ }
/* */
/* */ public void setMaterial(Material material) {
/* 101 */ this.material = material;
/* */ }
/* */
/* */ public Material getMaterial() {
/* 105 */ return this.material;
/* */ }
/* */
/* */ public void setBumpFunction(Function2D bumpFunction) {
/* 109 */ this.bumpFunction = bumpFunction;
/* */ }
/* */
/* */ public Function2D getBumpFunction() {
/* 113 */ return this.bumpFunction;
/* */ }
/* */
/* */ public void setBumpHeight(float bumpHeight) {
/* 117 */ this.bumpHeight = bumpHeight;
/* */ }
/* */
/* */ public float getBumpHeight() {
/* 121 */ return this.bumpHeight;
/* */ }
/* */
/* */ public void setBumpSoftness(float bumpSoftness) {
/* 125 */ this.bumpSoftness = bumpSoftness;
/* */ }
/* */
/* */ public float getBumpSoftness() {
/* 129 */ return this.bumpSoftness;
/* */ }
/* */
/* */ public void setBumpShape(int bumpShape) {
/* 133 */ this.bumpShape = bumpShape;
/* */ }
/* */
/* */ public int getBumpShape() {
/* 137 */ return this.bumpShape;
/* */ }
/* */
/* */ public void setViewDistance(float viewDistance) {
/* 141 */ this.viewDistance = viewDistance;
/* */ }
/* */
/* */ public float getViewDistance() {
/* 145 */ return this.viewDistance;
/* */ }
/* */
/* */ public void setEnvironmentMap(BufferedImage environmentMap) {
/* 149 */ this.environmentMap = environmentMap;
/* 150 */ if (environmentMap != null) {
/* 151 */ this.envWidth = environmentMap.getWidth();
/* 152 */ this.envHeight = environmentMap.getHeight();
/* 153 */ this.envPixels = getRGB(environmentMap, 0, 0, this.envWidth, this.envHeight, null);
/* */ } else {
/* 155 */ this.envWidth = (this.envHeight = 1);
/* 156 */ this.envPixels = null;
/* */ }
/* */ }
/* */
/* */ public Image getEnvironmentMap() {
/* 161 */ return this.environmentMap;
/* */ }
/* */
/* */ public void setColorSource(int colorSource) {
/* 165 */ this.colorSource = colorSource;
/* */ }
/* */
/* */ public int getColorSource() {
/* 169 */ return this.colorSource;
/* */ }
/* */
/* */ public void setBumpSource(int bumpSource) {
/* 173 */ this.bumpSource = bumpSource;
/* */ }
/* */
/* */ public int getBumpSource() {
/* 177 */ return this.bumpSource;
/* */ }
/* */
/* */ public void setDiffuseColor(int diffuseColor) {
/* 181 */ this.material.diffuseColor = diffuseColor;
/* */ }
/* */
/* */ public int getDiffuseColor() {
/* 185 */ return this.material.diffuseColor;
/* */ }
/* */
/* */ public void addLight(Light light) {
/* 189 */ this.lights.addElement(light);
/* */ }
/* */
/* */ public void removeLight(Light light) {
/* 193 */ this.lights.removeElement(light);
/* */ }
/* */
/* */ public Vector getLights() {
/* 197 */ return this.lights;
/* */ }
/* */
/* */ protected void setFromRGB(Color4f c, int argb)
/* */ {
/* 203 */ c.set((argb >> 16 & 0xFF) * 0.003921569F, (argb >> 8 & 0xFF) * 0.003921569F, (argb & 0xFF) * 0.003921569F, (argb >> 24 & 0xFF) * 0.003921569F);
/* */ }
/* */
/* */ protected int[] filterPixels(int width, int height, int[] inPixels, Rectangle transformedSpace) {
/* 207 */ int index = 0;
/* 208 */ int[] outPixels = new int[width * height];
/* 209 */ float width45 = Math.abs(6.0F * this.bumpHeight);
/* 210 */ boolean invertBumps = this.bumpHeight < 0.0F;
/* 211 */ Vector3f position = new Vector3f(0.0F, 0.0F, 0.0F);
/* 212 */ Vector3f viewpoint = new Vector3f(width / 2.0F, height / 2.0F, this.viewDistance);
/* 213 */ Vector3f normal = new Vector3f();
/* 214 */ Color4f envColor = new Color4f();
/* 215 */ Color4f diffuseColor = new Color4f(new Color(this.material.diffuseColor));
/* 216 */ Color4f specularColor = new Color4f(new Color(this.material.specularColor));
/* 217 */ Function2D bump = this.bumpFunction;
/* */
/* 220 */ if ((this.bumpSource == 0) || (this.bumpSource == 1) || (this.bumpSource == 2) || (bump == null)) {
/* 221 */ if (this.bumpSoftness != 0.0F) {
/* 222 */ int bumpWidth = width;
/* 223 */ int bumpHeight = height;
/* 224 */ int[] bumpPixels = inPixels;
/* 225 */ if ((this.bumpSource == 2) && ((this.bumpFunction instanceof ImageFunction2D))) {
/* 226 */ ImageFunction2D if2d = (ImageFunction2D)this.bumpFunction;
/* 227 */ bumpWidth = if2d.getWidth();
/* 228 */ bumpHeight = if2d.getHeight();
/* 229 */ bumpPixels = if2d.getPixels();
/* */ }
/* 231 */ int[] tmpPixels = new int[bumpWidth * bumpHeight];
/* 232 */ int[] softPixels = new int[bumpWidth * bumpHeight];
/* */
/* 239 */ Kernel kernel = GaussianFilter.makeKernel(this.bumpSoftness);
/* 240 */ GaussianFilter.convolveAndTranspose(kernel, bumpPixels, tmpPix
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
java 图像滤镜库 (224个子文件)
LightFilter.java 27KB
ImageMath.java 17KB
CellularFilter.java 17KB
SkyFilter.java 13KB
Gradient.java 13KB
MiscCompositeContext.java 13KB
ConvolveFilter.java 13KB
WarpGrid.java 12KB
ShapeFilter.java 12KB
GradientFilter.java 12KB
ShadeFilter.java 11KB
Matrix4f.java 11KB
CurlFilter.java 10KB
LensBlurFilter.java 10KB
SmearFilter.java 10KB
PerspectiveFilter.java 9KB
CausticsFilter.java 9KB
Noise.java 9KB
ImageUtils.java 9KB
OctTreeQuantizer.java 9KB
GlintFilter.java 8KB
PlasmaFilter.java 8KB
DitherFilter.java 8KB
VariableBlurFilter.java 8KB
TransformFilter.java 8KB
BrushedMetalFilter.java 8KB
PixelUtils.java 8KB
FBMFilter.java 7KB
ShatterFilter.java 7KB
BoxBlurFilter.java 7KB
HSBAdjustFilter.java 7KB
ShadowFilter.java 7KB
PolarFilter.java 7KB
SCNoise.java 6KB
MotionBlurFilter.java 6KB
MiscComposite.java 6KB
Histogram.java 6KB
WeaveFilter.java 6KB
FieldWarpFilter.java 6KB
GaussianFilter.java 6KB
QuiltFilter.java 6KB
FeedbackFilter.java 6KB
MotionBlurOp.java 6KB
SmartBlurFilter.java 5KB
ColorHalftoneFilter.java 5KB
DiffusionFilter.java 5KB
QuantizeFilter.java 5KB
FlareFilter.java 5KB
FlipFilter.java 5KB
CellularFunction2D.java 5KB
Tuple4f.java 5KB
FFT.java 5KB
RaysFilter.java 5KB
EdgeFilter.java 5KB
MarbleTexFilter.java 5KB
EmbossFilter.java 5KB
Tuple3f.java 4KB
ImageFunction2D.java 4KB
ShineFilter.java 4KB
SkeletonFilter.java 4KB
WarpFilter.java 4KB
TextureFilter.java 4KB
SphereFilter.java 4KB
WaterFilter.java 4KB
WoodFilter.java 4KB
TransitionFilter.java 4KB
ContourFilter.java 4KB
KeyFilter.java 4KB
PinchFilter.java 4KB
HalftoneFilter.java 4KB
LaplaceFilter.java 4KB
KaleidoscopeFilter.java 4KB
ScratchFilter.java 4KB
CircleFilter.java 4KB
DoGFilter.java 4KB
BorderFilter.java 4KB
DespeckleFilter.java 4KB
Quat4f.java 4KB
RippleFilter.java 4KB
ApplyMaskFilter.java 4KB
OilFilter.java 4KB
Spectrum.java 4KB
DisplaceFilter.java 4KB
FourColorFilter.java 4KB
Curve.java 4KB
SparkleFilter.java 4KB
MirrorFilter.java 3KB
TwirlFilter.java 3KB
UnsharpFilter.java 3KB
SplineColormap.java 3KB
LevelsFilter.java 3KB
RenderTextFilter.java 3KB
FadeFilter.java 3KB
SwimFilter.java 3KB
ChromaKeyFilter.java 3KB
CheckFilter.java 3KB
MedianFilter.java 3KB
RGBComposite.java 3KB
GradientWipeFilter.java 3KB
InterpolateFilter.java 3KB
共 224 条
- 1
- 2
- 3
资源评论
房回
- 粉丝: 3
- 资源: 8
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功