如何模糊图像?

发布于 2024-08-08 03:49:59 字数 42 浏览 2 评论 0原文

我正在尝试在 java 游戏上实现模糊机制。如何在运行时创建模糊效果?

I'm trying to implement a blurring mechanic on a java game. How do I create a blur effect on runtime?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

喜你已久 2024-08-15 03:49:59

谷歌“高斯模糊”,试试这个:http://www.jhlabs.com/ip/blurring.html

Google "Gaussian Blur", try this: http://www.jhlabs.com/ip/blurring.html

梦回旧景 2024-08-15 03:49:59

阅读/谷歌“卷积过滤器”,它是一种根据周围像素值更改像素值的方法。因此,除了模糊之外,您还可以进行图像锐化和寻线。

Read about/Google "Convolution Filters", it's a method of changing a pixels value based on the values of pixels around it. So apart from blurring, you can also do image sharpening and line-finding.

淤浪 2024-08-15 03:49:59

如果您正在从事 java 游戏开发,我敢打赌您正在使用 java2d。

您想要像这样创建一个卷积过滤器:

 // Create the kernel.
 kernel = new KernelJAI
 float[] = {  0.0F, -1.0F,  0.0F,
             -1.0F,  5.0F, -1.0F,
              0.0F, -1.0F,  0.0F };

 // Create the convolve operation.
 blurredImage = JAI.create("convolve", originalImage, kernel);

您可以在以下位置找到更多信息:http://java.sun.com/products/java-media/jai/forDevelopers/jai1_0_1guide-unc/Image-enhance.doc.html#51172 (这也是代码的来源)

If you are doing java game development, I'm willing to bet you are using java2d.

You want to create a convolution filter like so:

 // Create the kernel.
 kernel = new KernelJAI
 float[] = {  0.0F, -1.0F,  0.0F,
             -1.0F,  5.0F, -1.0F,
              0.0F, -1.0F,  0.0F };

 // Create the convolve operation.
 blurredImage = JAI.create("convolve", originalImage, kernel);

You can find more information at: http://java.sun.com/products/java-media/jai/forDevelopers/jai1_0_1guide-unc/Image-enhance.doc.html#51172 (which is where the code is from too)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文