public HeapView() {
// Configure structures needed for rendering drop shadow.
int kw = KERNEL_SIZE, kh = KERNEL_SIZE;
float blurFactor = BLUR_FACTOR;
float[] kernelData = new float[kw * kh];
for (int i = 0; i < kernelData.length; i++) {
kernelData[i] = blurFactor;
}
blur = new ConvolveOp(new Kernel(kw, kh, kernelData));
format = new MessageFormat("{0,choice,0#{0,number,0.0}|999<{0,number,0}}/{1,choice,0#{1,number,0.0}|999<{1,number,0}}MB");
heapSizeText = "";
// Enable mouse events. This is the equivalent to adding a mouse
// listener.
enableEvents(AWTEvent.MOUSE_EVENT_MASK);
setToolTipText(NbBundle.getMessage(GarbageCollectAction.class, "CTL_GC"));
updateUI();
}
java类java.awt.image.ConvolveOp的实例源码
HeapView.java 文件源码
项目:incubator-netbeans
阅读 20
收藏 0
点赞 0
评论 0
ConvolutionFilter.java 文件源码
项目:GIFKR
阅读 20
收藏 0
点赞 0
评论 0
@Override
public final BufferedImage apply(BufferedImage img) {
float[][] matrix = getMatrix();
float[] data = getKernelData(matrix);
if(normalize)
normalize(data);
scale(data);
if(isZero(data))
return new BufferedImage(img.getWidth(), img.getHeight(), BufferedImage.TYPE_INT_RGB);
Kernel k = new Kernel(matrix[0].length, matrix.length, data);
ConvolveOp op = new ConvolveOp(k, ConvolveOp.EDGE_NO_OP, null);
BufferedImage img2 = new BufferedImage(img.getWidth(), img.getHeight(), BufferedImage.TYPE_INT_RGB);
img2.getGraphics().drawImage(img, 0, 0, null);
return op.filter(img2, null);
}
BufferedBufImgOps.java 文件源码
项目:OpenJSharp
阅读 25
收藏 0
点赞 0
评论 0
private static void enableConvolveOp(RenderQueue rq,
SurfaceData srcData,
ConvolveOp cop)
{
// assert rq.lock.isHeldByCurrentThread();
boolean edgeZero =
cop.getEdgeCondition() == ConvolveOp.EDGE_ZERO_FILL;
Kernel kernel = cop.getKernel();
int kernelWidth = kernel.getWidth();
int kernelHeight = kernel.getHeight();
int kernelSize = kernelWidth * kernelHeight;
int sizeofFloat = 4;
int totalBytesRequired = 4 + 8 + 12 + (kernelSize * sizeofFloat);
RenderBuffer buf = rq.getBuffer();
rq.ensureCapacityAndAlignment(totalBytesRequired, 4);
buf.putInt(ENABLE_CONVOLVE_OP);
buf.putLong(srcData.getNativeOps());
buf.putInt(edgeZero ? 1 : 0);
buf.putInt(kernelWidth);
buf.putInt(kernelHeight);
buf.put(kernel.getKernelData(null));
}
ChessBoardUtils.java 文件源码
项目:ChessBot
阅读 23
收藏 0
点赞 0
评论 0
public static BufferedImage blur(BufferedImage src) {
BufferedImage bufferedImage = new BufferedImage(src.getWidth(), src.getHeight(), BufferedImage.TYPE_BYTE_INDEXED);
int s1 = 7;
int s2 = 7;
float level = .1f / 9f;
float[] filter = new float[s1 * s2];
for (int i = 0; i < s1 * s2; i++) {
filter[i] = level;
}
Kernel kernel = new Kernel(s1, s2, filter);
BufferedImageOp op = new ConvolveOp(kernel);
bufferedImage = op.filter(src, null);
return bufferedImage;
}
BufferedBufImgOps.java 文件源码
项目:jdk8u-jdk
阅读 22
收藏 0
点赞 0
评论 0
private static void enableConvolveOp(RenderQueue rq,
SurfaceData srcData,
ConvolveOp cop)
{
// assert rq.lock.isHeldByCurrentThread();
boolean edgeZero =
cop.getEdgeCondition() == ConvolveOp.EDGE_ZERO_FILL;
Kernel kernel = cop.getKernel();
int kernelWidth = kernel.getWidth();
int kernelHeight = kernel.getHeight();
int kernelSize = kernelWidth * kernelHeight;
int sizeofFloat = 4;
int totalBytesRequired = 4 + 8 + 12 + (kernelSize * sizeofFloat);
RenderBuffer buf = rq.getBuffer();
rq.ensureCapacityAndAlignment(totalBytesRequired, 4);
buf.putInt(ENABLE_CONVOLVE_OP);
buf.putLong(srcData.getNativeOps());
buf.putInt(edgeZero ? 1 : 0);
buf.putInt(kernelWidth);
buf.putInt(kernelHeight);
buf.put(kernel.getKernelData(null));
}
EdgeNoOpCrash.java 文件源码
项目:jdk8u-jdk
阅读 18
收藏 0
点赞 0
评论 0
private static void crashTest() {
Raster src = createSrcRaster();
WritableRaster dst = createDstRaster();
ConvolveOp op = createConvolveOp(ConvolveOp.EDGE_NO_OP);
try {
op.filter(src, dst);
} catch (ImagingOpException e) {
/*
* The test pair of source and destination rasters
* may cause failure of the medialib convolution routine,
* so this exception is expected.
*
* The JVM crash is the only manifestation of this
* test failure.
*/
}
System.out.println("Test PASSED.");
}
BufferedBufImgOps.java 文件源码
项目:openjdk-jdk10
阅读 20
收藏 0
点赞 0
评论 0
private static void enableConvolveOp(RenderQueue rq,
SurfaceData srcData,
ConvolveOp cop)
{
// assert rq.lock.isHeldByCurrentThread();
boolean edgeZero =
cop.getEdgeCondition() == ConvolveOp.EDGE_ZERO_FILL;
Kernel kernel = cop.getKernel();
int kernelWidth = kernel.getWidth();
int kernelHeight = kernel.getHeight();
int kernelSize = kernelWidth * kernelHeight;
int sizeofFloat = 4;
int totalBytesRequired = 4 + 8 + 12 + (kernelSize * sizeofFloat);
RenderBuffer buf = rq.getBuffer();
rq.ensureCapacityAndAlignment(totalBytesRequired, 4);
buf.putInt(ENABLE_CONVOLVE_OP);
buf.putLong(srcData.getNativeOps());
buf.putInt(edgeZero ? 1 : 0);
buf.putInt(kernelWidth);
buf.putInt(kernelHeight);
buf.put(kernel.getKernelData(null));
}
BufferedBufImgOps.java 文件源码
项目:openjdk9
阅读 24
收藏 0
点赞 0
评论 0
private static void enableConvolveOp(RenderQueue rq,
SurfaceData srcData,
ConvolveOp cop)
{
// assert rq.lock.isHeldByCurrentThread();
boolean edgeZero =
cop.getEdgeCondition() == ConvolveOp.EDGE_ZERO_FILL;
Kernel kernel = cop.getKernel();
int kernelWidth = kernel.getWidth();
int kernelHeight = kernel.getHeight();
int kernelSize = kernelWidth * kernelHeight;
int sizeofFloat = 4;
int totalBytesRequired = 4 + 8 + 12 + (kernelSize * sizeofFloat);
RenderBuffer buf = rq.getBuffer();
rq.ensureCapacityAndAlignment(totalBytesRequired, 4);
buf.putInt(ENABLE_CONVOLVE_OP);
buf.putLong(srcData.getNativeOps());
buf.putInt(edgeZero ? 1 : 0);
buf.putInt(kernelWidth);
buf.putInt(kernelHeight);
buf.put(kernel.getKernelData(null));
}
EdgeNoOpCrash.java 文件源码
项目:openjdk9
阅读 16
收藏 0
点赞 0
评论 0
private static void crashTest() {
Raster src = createSrcRaster();
WritableRaster dst = createDstRaster();
ConvolveOp op = createConvolveOp(ConvolveOp.EDGE_NO_OP);
try {
op.filter(src, dst);
} catch (ImagingOpException e) {
/*
* The test pair of source and destination rasters
* may cause failure of the medialib convolution routine,
* so this exception is expected.
*
* The JVM crash is the only manifestation of this
* test failure.
*/
}
System.out.println("Test PASSED.");
}
Sprite.java 文件源码
项目:LibZ
阅读 24
收藏 0
点赞 0
评论 0
/**
* Blur the image
* @param amount
*/
public void effect_blur(int amount) { // TODO
int radius = amount;
int size = radius * 2 + 1;
float weight = 1.0f / (size * size);
float[] data = new float[size * size];
for (int i = 0; i < data.length; i++) {
data[i] = weight;
}
Kernel kernel = new Kernel(size, size, data);
ConvolveOp op = new ConvolveOp(kernel, ConvolveOp.EDGE_NO_OP, null);
image = op.filter(image, null);
}
GaussianBlur.java 文件源码
项目:vortex
阅读 27
收藏 0
点赞 0
评论 0
public static Image getBlurredImg(BufferedImage img) {
final int kernel_size = 15;
float[] blurKernel = new float[kernel_size * kernel_size];
final float blurPeakHeight = 0.35f;
double[][] sigma = new double[2][2];
sigma[0] = new double[]{1.2, 0.0};
sigma[1] = new double[]{0.0, 1.2};
double mid = (kernel_size / 2.0);
float cent = (float) MultiNormalDist.density(new double[]{mid, mid}, sigma, new double[]{mid, mid});
for (int i = 0; i < blurKernel.length; i++) {
int x = i / kernel_size;
int y = i % kernel_size;
blurKernel[i] = blurPeakHeight * (float) MultiNormalDist.density(new double[]{mid, mid}, sigma, new double[]{x, y}) / cent;
}
ConvolveOp op = new ConvolveOp(new Kernel(kernel_size, kernel_size, blurKernel));
return op.filter(img, null);
}
GaussianBlur.java 文件源码
项目:vortex
阅读 23
收藏 0
点赞 0
评论 0
public static Image getBlurredImg(BufferedImage img) {
final int kernel_size = 15;
float[] blurKernel = new float[kernel_size * kernel_size];
final float blurPeakHeight = 0.35f;
double[][] sigma = new double[2][2];
sigma[0] = new double[]{1.2, 0.0};
sigma[1] = new double[]{0.0, 1.2};
double mid = (kernel_size / 2.0);
float cent = (float) MultiNormalDist.density(new double[]{mid, mid}, sigma, new double[]{mid, mid});
for (int i = 0; i < blurKernel.length; i++) {
int x = i / kernel_size;
int y = i % kernel_size;
blurKernel[i] = blurPeakHeight * (float) MultiNormalDist.density(new double[]{mid, mid}, sigma, new double[]{x, y}) / cent;
}
ConvolveOp op = new ConvolveOp(new Kernel(kernel_size, kernel_size, blurKernel));
return op.filter(img, null);
}
SVGBufferedImageOp.java 文件源码
项目:Push2Display
阅读 18
收藏 0
点赞 0
评论 0
/**
* @param op BufferedImageOp to be converted to SVG
* @param filterRect Rectangle, in device space, that defines the area
* to which filtering applies. May be null, meaning that the
* area is undefined.
* @return an SVGFilterDescriptor representing the SVG filter
* equivalent of the input BufferedImageOp
*/
public SVGFilterDescriptor toSVG(BufferedImageOp op,
Rectangle filterRect){
SVGFilterDescriptor filterDesc =
svgCustomBufferedImageOp.toSVG(op, filterRect);
if(filterDesc == null){
if(op instanceof LookupOp)
filterDesc = svgLookupOp.toSVG(op, filterRect);
else if(op instanceof RescaleOp)
filterDesc = svgRescaleOp.toSVG(op, filterRect);
else if(op instanceof ConvolveOp)
filterDesc = svgConvolveOp.toSVG(op, filterRect);
}
return filterDesc;
}
BufferedBufImgOps.java 文件源码
项目:jdk8u_jdk
阅读 24
收藏 0
点赞 0
评论 0
private static void enableConvolveOp(RenderQueue rq,
SurfaceData srcData,
ConvolveOp cop)
{
// assert rq.lock.isHeldByCurrentThread();
boolean edgeZero =
cop.getEdgeCondition() == ConvolveOp.EDGE_ZERO_FILL;
Kernel kernel = cop.getKernel();
int kernelWidth = kernel.getWidth();
int kernelHeight = kernel.getHeight();
int kernelSize = kernelWidth * kernelHeight;
int sizeofFloat = 4;
int totalBytesRequired = 4 + 8 + 12 + (kernelSize * sizeofFloat);
RenderBuffer buf = rq.getBuffer();
rq.ensureCapacityAndAlignment(totalBytesRequired, 4);
buf.putInt(ENABLE_CONVOLVE_OP);
buf.putLong(srcData.getNativeOps());
buf.putInt(edgeZero ? 1 : 0);
buf.putInt(kernelWidth);
buf.putInt(kernelHeight);
buf.put(kernel.getKernelData(null));
}
EdgeNoOpCrash.java 文件源码
项目:jdk8u_jdk
阅读 21
收藏 0
点赞 0
评论 0
private static void crashTest() {
Raster src = createSrcRaster();
WritableRaster dst = createDstRaster();
ConvolveOp op = createConvolveOp(ConvolveOp.EDGE_NO_OP);
try {
op.filter(src, dst);
} catch (ImagingOpException e) {
/*
* The test pair of source and destination rasters
* may cause failure of the medialib convolution routine,
* so this exception is expected.
*
* The JVM crash is the only manifestation of this
* test failure.
*/
}
System.out.println("Test PASSED.");
}
BufferedBufImgOps.java 文件源码
项目:lookaside_java-1.8.0-openjdk
阅读 29
收藏 0
点赞 0
评论 0
private static void enableConvolveOp(RenderQueue rq,
SurfaceData srcData,
ConvolveOp cop)
{
// assert rq.lock.isHeldByCurrentThread();
boolean edgeZero =
cop.getEdgeCondition() == ConvolveOp.EDGE_ZERO_FILL;
Kernel kernel = cop.getKernel();
int kernelWidth = kernel.getWidth();
int kernelHeight = kernel.getHeight();
int kernelSize = kernelWidth * kernelHeight;
int sizeofFloat = 4;
int totalBytesRequired = 4 + 8 + 12 + (kernelSize * sizeofFloat);
RenderBuffer buf = rq.getBuffer();
rq.ensureCapacityAndAlignment(totalBytesRequired, 4);
buf.putInt(ENABLE_CONVOLVE_OP);
buf.putLong(srcData.getNativeOps());
buf.putInt(edgeZero ? 1 : 0);
buf.putInt(kernelWidth);
buf.putInt(kernelHeight);
buf.put(kernel.getKernelData(null));
}
EdgeNoOpCrash.java 文件源码
项目:lookaside_java-1.8.0-openjdk
阅读 22
收藏 0
点赞 0
评论 0
private static void crashTest() {
Raster src = createSrcRaster();
WritableRaster dst = createDstRaster();
ConvolveOp op = createConvolveOp(ConvolveOp.EDGE_NO_OP);
try {
op.filter(src, dst);
} catch (ImagingOpException e) {
/*
* The test pair of source and destination rasters
* may cause failure of the medialib convolution routine,
* so this exception is expected.
*
* The JVM crash is the only manifestation of this
* test failure.
*/
}
System.out.println("Test PASSED.");
}
PureJavaSolution.java 文件源码
项目:aparapi-examples
阅读 19
收藏 0
点赞 0
评论 0
public static void main(final String[] _args) {
String fileName = _args.length == 1 ? _args[0] : "Leo720p.wmv";
float[] convMatrix3x3 = new float[] {
0f,
-10f,
0f,
-10f,
41f,
-10f,
0f,
-10f,
0f
};
new JJMPEGPlayer("lab_6.alternate", fileName, convMatrix3x3){
@Override protected void processFrame(Graphics2D _gc, float[] _convMatrix3x3, BufferedImage _in, BufferedImage _out) {
java.awt.image.Kernel conv = new java.awt.image.Kernel(3, 3, _convMatrix3x3);
ConvolveOp convOp = new ConvolveOp(conv, ConvolveOp.EDGE_NO_OP, null);
convOp.filter(_in, _out);
}
};
}
Logic.java 文件源码
项目:AvoinApotti
阅读 22
收藏 0
点赞 0
评论 0
public static BufferedImage blurImage(BufferedImage image)
{
float ninth = 1.0f/9.0f;
float[] blurKernel = {
ninth, ninth, ninth,
ninth, ninth, ninth,
ninth, ninth, ninth
};
Map<RenderingHints.Key, Object> map = new HashMap<RenderingHints.Key, Object>();
map.put(RenderingHints.KEY_INTERPOLATION,RenderingHints.VALUE_INTERPOLATION_BILINEAR);
map.put(RenderingHints.KEY_RENDERING,RenderingHints.VALUE_RENDER_QUALITY);
map.put(RenderingHints.KEY_ANTIALIASING,RenderingHints.VALUE_ANTIALIAS_ON);
RenderingHints hints = new RenderingHints(map);
BufferedImageOp op = new ConvolveOp(new Kernel(3, 3, blurKernel), ConvolveOp.EDGE_NO_OP, hints);
return op.filter(image, null);
}
LockPanel.java 文件源码
项目:AppWoksUtils
阅读 20
收藏 0
点赞 0
评论 0
/**
* @param time
*/
public void lock(final int time) {
frame.getGlassPane().setVisible(false);
screen = createScreenShot();
frame.getGlassPane().setVisible(true);
if (screen != null) {
gray = ImageProvider.convertToGrayScale(screen);
final float data[] = { 0.0625f, 0.125f, 0.0625f, 0.125f, 0.25f, 0.125f, 0.0625f, 0.125f, 0.0625f };
final Kernel kernel = new Kernel(3, 3, data);
final ConvolveOp convolve = new ConvolveOp(kernel, ConvolveOp.EDGE_NO_OP, null);
final BufferedImage dest = new BufferedImage(gray.getWidth(), gray.getHeight(), BufferedImage.TYPE_BYTE_GRAY);
gray = convolve.filter(gray, dest);
frame.setGlassPane(this);
frame.getGlassPane().setVisible(true);
fadeIn(time);
}
}
BoxBlurDemo.java 文件源码
项目:filthy-rich-clients
阅读 21
收藏 0
点赞 0
评论 0
public static ConvolveOp getBlurFilter(int radius) {
if (radius < 1) {
throw new IllegalArgumentException("Radius must be >= 1");
}
int size = radius * 2 + 1;
float weight = 1.0f / (size * size);
float[] data = new float[size * size];
for (int i = 0; i < data.length; i++) {
data[i] = weight;
}
Kernel kernel = new Kernel(size, size, data);
return new ConvolveOp(kernel, ConvolveOp.EDGE_NO_OP, null);
}
SVGBufferedImageOp.java 文件源码
项目:Push2Display
阅读 20
收藏 0
点赞 0
评论 0
/**
* @param op BufferedImageOp to be converted to SVG
* @param filterRect Rectangle, in device space, that defines the area
* to which filtering applies. May be null, meaning that the
* area is undefined.
* @return an SVGFilterDescriptor representing the SVG filter
* equivalent of the input BufferedImageOp
*/
public SVGFilterDescriptor toSVG(BufferedImageOp op,
Rectangle filterRect){
SVGFilterDescriptor filterDesc =
svgCustomBufferedImageOp.toSVG(op, filterRect);
if(filterDesc == null){
if(op instanceof LookupOp)
filterDesc = svgLookupOp.toSVG(op, filterRect);
else if(op instanceof RescaleOp)
filterDesc = svgRescaleOp.toSVG(op, filterRect);
else if(op instanceof ConvolveOp)
filterDesc = svgConvolveOp.toSVG(op, filterRect);
}
return filterDesc;
}
QRDecoder.java 文件源码
项目:qr-code-reader
阅读 27
收藏 0
点赞 0
评论 0
/**
* Uses a blur filter on an image in an attempt to make it readable by the
* QRCodeReader.
*
* @param image
* the page in a BufferedImage object
* @return another BufferedImage object with the filters applied to it
*/
private BufferedImage processImage(BufferedImage image) {
// default: 3x3 filter for a 72 DPI image
double DEFAULT_SIZE = 9.0;
// calculate filtering matrix size based on the image resolution
int dimension = (int) Math.sqrt(DEFAULT_SIZE
/ (double) DEFAULT_RESOLUTION * RETAKE_RESOLUTION);
int size = dimension * dimension;
float[] matrix = new float[size];
for (int i = 0; i < size; i++)
matrix[i] = 1.0f / (float) size;
BufferedImageOp op = new ConvolveOp(new Kernel(dimension, dimension,
matrix), ConvolveOp.EDGE_NO_OP, null);
return op.filter(image, null);
}
BufferedBufImgOps.java 文件源码
项目:infobip-open-jdk-8
阅读 26
收藏 0
点赞 0
评论 0
private static void enableConvolveOp(RenderQueue rq,
SurfaceData srcData,
ConvolveOp cop)
{
// assert rq.lock.isHeldByCurrentThread();
boolean edgeZero =
cop.getEdgeCondition() == ConvolveOp.EDGE_ZERO_FILL;
Kernel kernel = cop.getKernel();
int kernelWidth = kernel.getWidth();
int kernelHeight = kernel.getHeight();
int kernelSize = kernelWidth * kernelHeight;
int sizeofFloat = 4;
int totalBytesRequired = 4 + 8 + 12 + (kernelSize * sizeofFloat);
RenderBuffer buf = rq.getBuffer();
rq.ensureCapacityAndAlignment(totalBytesRequired, 4);
buf.putInt(ENABLE_CONVOLVE_OP);
buf.putLong(srcData.getNativeOps());
buf.putInt(edgeZero ? 1 : 0);
buf.putInt(kernelWidth);
buf.putInt(kernelHeight);
buf.put(kernel.getKernelData(null));
}
EdgeNoOpCrash.java 文件源码
项目:infobip-open-jdk-8
阅读 20
收藏 0
点赞 0
评论 0
private static void crashTest() {
Raster src = createSrcRaster();
WritableRaster dst = createDstRaster();
ConvolveOp op = createConvolveOp(ConvolveOp.EDGE_NO_OP);
try {
op.filter(src, dst);
} catch (ImagingOpException e) {
/*
* The test pair of source and destination rasters
* may cause failure of the medialib convolution routine,
* so this exception is expected.
*
* The JVM crash is the only manifestation of this
* test failure.
*/
}
System.out.println("Test PASSED.");
}
BufferedBufImgOps.java 文件源码
项目:jdk8u-dev-jdk
阅读 18
收藏 0
点赞 0
评论 0
private static void enableConvolveOp(RenderQueue rq,
SurfaceData srcData,
ConvolveOp cop)
{
// assert rq.lock.isHeldByCurrentThread();
boolean edgeZero =
cop.getEdgeCondition() == ConvolveOp.EDGE_ZERO_FILL;
Kernel kernel = cop.getKernel();
int kernelWidth = kernel.getWidth();
int kernelHeight = kernel.getHeight();
int kernelSize = kernelWidth * kernelHeight;
int sizeofFloat = 4;
int totalBytesRequired = 4 + 8 + 12 + (kernelSize * sizeofFloat);
RenderBuffer buf = rq.getBuffer();
rq.ensureCapacityAndAlignment(totalBytesRequired, 4);
buf.putInt(ENABLE_CONVOLVE_OP);
buf.putLong(srcData.getNativeOps());
buf.putInt(edgeZero ? 1 : 0);
buf.putInt(kernelWidth);
buf.putInt(kernelHeight);
buf.put(kernel.getKernelData(null));
}
EdgeNoOpCrash.java 文件源码
项目:jdk8u-dev-jdk
阅读 18
收藏 0
点赞 0
评论 0
private static void crashTest() {
Raster src = createSrcRaster();
WritableRaster dst = createDstRaster();
ConvolveOp op = createConvolveOp(ConvolveOp.EDGE_NO_OP);
try {
op.filter(src, dst);
} catch (ImagingOpException e) {
/*
* The test pair of source and destination rasters
* may cause failure of the medialib convolution routine,
* so this exception is expected.
*
* The JVM crash is the only manifestation of this
* test failure.
*/
}
System.out.println("Test PASSED.");
}
ImageUtilities.java 文件源码
项目:praisenter
阅读 22
收藏 0
点赞 0
评论 0
/**
* Returns a drop shadow for the given rectangle specified by the given width and height.
* @param gc the graphics configuration
* @param w the rectangle width
* @param h the rectangle height
* @param sw the
* @param color the shadow color
* @return BufferedImage
*/
public static final BufferedImage getDropShadowImage(GraphicsConfiguration gc, int w, int h, int sw, Color color) {
// create a new image of the right size
BufferedImage image = gc.createCompatibleImage(w + 2 * sw, h + 2 * sw, Transparency.TRANSLUCENT);
Graphics2D ig2d = image.createGraphics();
ig2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
ig2d.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
// render the shadow rectangle
ig2d.setColor(color);
ig2d.fillRect(sw, sw, w, h);
ig2d.dispose();
// perform the linear blur
ConvolveOp op = ImageUtilities.getLinearBlurOp(sw);
return op.filter(image, null);
}
DriverShadowedG2d.java 文件源码
项目:sbt-plantuml-plugin
阅读 20
收藏 0
点赞 0
评论 0
private ConvolveOp getConvolveOp(int blurRadius, double dpiFactor) {
blurRadius = (int) (blurRadius * dpiFactor);
final int blurRadius2 = blurRadius * blurRadius;
final float blurRadius2F = blurRadius2;
// final float weight = (float) (1.0 / blurRadius2F / dpiFactor);
final float weight = (float) (1.0 / blurRadius2F);
final float[] elements = new float[blurRadius2];
for (int k = 0; k < blurRadius2; k++) {
elements[k] = weight;
}
final Kernel myKernel = new Kernel(blurRadius, blurRadius, elements);
// if EDGE_NO_OP is not selected, EDGE_ZERO_FILL is the default which
// creates a black border
return new ConvolveOp(myKernel, ConvolveOp.EDGE_NO_OP, null);
}
SVGBufferedImageOp.java 文件源码
项目:feathers-sdk
阅读 22
收藏 0
点赞 0
评论 0
/**
* @param op BufferedImageOp to be converted to SVG
* @param filterRect Rectangle, in device space, that defines the area
* to which filtering applies. May be null, meaning that the
* area is undefined.
* @return an SVGFilterDescriptor representing the SVG filter
* equivalent of the input BufferedImageOp
*/
public SVGFilterDescriptor toSVG(BufferedImageOp op,
Rectangle filterRect){
SVGFilterDescriptor filterDesc =
svgCustomBufferedImageOp.toSVG(op, filterRect);
if(filterDesc == null){
if(op instanceof LookupOp)
filterDesc = svgLookupOp.toSVG(op, filterRect);
else if(op instanceof RescaleOp)
filterDesc = svgRescaleOp.toSVG(op, filterRect);
else if(op instanceof ConvolveOp)
filterDesc = svgConvolveOp.toSVG(op, filterRect);
}
return filterDesc;
}