---
title: "学习图形处理的一些破事"
author: "FeiXing2008"
date: "2009-05-15T10:53:14Z"
tags: []
slug: "untitled"
draft: false
lastmod: "2009-05-15T10:55:11Z"
id: 387267
url: "https://feixing2008.iteye.com/blog/387267"
---

这应是关于图形处理的一些东西。  
我是想做像Vista的玻璃模糊效果。  
由于图形处理不是很会，所以我的模糊便使了高斯模糊。

程序思路是用Robot得到屏幕的截图  
然后用Kernel与ConvolveOp两个类进行得理~~  
最后将截图进行模糊。  
我在下边展示一些图形处理的代码：

```
Robot rb = new Robot();
JLabel jlb = new JLabel();
JButton jbtn = new JButton();
BufferedImage im = rb.createScreenCapture(new Rectangle(200,200));
float[] data = {0.0625f, 0.125f, 0.0625f,    0.125f, 0.125f, 0.125f,    0.0625f, 0.125f, 0.0625f     };
Kernel kernel = new Kernel(3, 3, data);
ConvolveOp co = new ConvolveOp(kernel, ConvolveOp.EDGE_NO_OP, null);
BufferedImage im2 = null;
im2 = co.filter(im, im2);
this.setLayout(new FlowLayout());
ImageIcon imIcon = new ImageIcon(im2);
jlb.setIcon(imIcon);
this.getContentPane().add(jlb);
ImageIcon imIcon2 = new ImageIcon(im);
jbtn.setPreferredSize(new Dimension(200,200));
jbtn.setIcon(imIcon2);
this.getContentPane().add(jbtn);
```

   
上边的代码上JFrame子类构造器里，这里不写出来了。  
感觉使用这种模糊的效果与Vista的效果差好远~\`不过也只好凑着用了。  
效果如下  
![](/upload/attachment/103738/3de9c2fa-b3d8-3656-8985-289594c2454e.jpg)

想找个更像Vista的，可惜未发现。

现在的原理就是先截图，模糊，把其放在背景，让人感到好像是透明那样。这个代码就不写出了