Java开发网 Java开发网
注册 | 登录 | 帮助 | 搜索 | 排行榜 | 发帖统计  

您没有登录

» Java开发网 » Java SE 综合讨论区  

按打印兼容模式打印这个话题 打印话题    把这个话题寄给朋友 寄给朋友    该主题的所有更新都将Email到你的邮箱 订阅主题
flat modethreaded modego to previous topicgo to next topicgo to back
作者 求助关于Java的抗锯齿实现
widewindow





发贴: 9
积分: 0
于 2008-06-05 16:03 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
我发现在Java中通过如下设定可以实现完美的抗锯齿:
graphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
graphics.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_PURE);
graphics.setRenderingHint(RenderingHints.KEY_COLOR_RENDERING, RenderingHints.VALUE_COLOR_RENDER_QUALITY);
shadowGraphics.setRenderingHint(RenderingHints.KEY_ALPHA_INTERPOLATION, RenderingHints.VALUE_ALPHA_INTERPOLATION_QUALITY);
进一步实验发现,Java使用的是全局抗锯齿技术,也就是画完图的时候Java会在显示它之前对它作抗锯齿处理。

我现在的问题是,Java公开的源代码中有没有抗锯齿的实现,如果有的话,是在什么模块里,我去找过,没找到。如果没有的话,是不是会在某个DLL中还是在哪里。请告知。谢谢。



作者 Re:求助关于Java的抗锯齿实现 [Re:widewindow]
JiafanZhou



版主


发贴: 736
积分: 61
于 2008-06-05 17:47 user profilesend a private message to usersend email to JiafanZhousearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
widewindow wrote:
我现在的问题是,Java公开的源代码中有没有抗锯齿的实现,如果有的话,是在什么模块里,我去找过,没找到。如果没有的话,是不是会在某个DLL中还是在哪里。请告知。谢谢。

I don't think you will get the answers from us in the Forum here, unless a JVM expert comes CJSDN for a visit. The only place I will recommend you to go is Sun's community or Sun's official mail group.

Let those JVM experts address your issue. But whenever you fix your issue, could you post your answer back here for further reference. Because it is a very interesting topic and I'd like to know as well.

Thanks,
Jiafan



When I was a kid I used to pray every night for a new bike. Then I realized that The Lord doesn't work that way, so I stole one and asked him to forgive me.
作者 Re:求助关于Java的抗锯齿实现 [Re:widewindow]
widewindow





发贴: 9
积分: 0
于 2008-06-05 18:35 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
Thanks for the reply.

I'm not sure if the experts will address my problem. If they did release the implementation of Java's anti-aliase, then OK, if they implemented it in a certain DLL or a class file, I'll disassembly it and get the algorithm if possible. The real problem is, for me now, where the CODE resides, in whatever form.



作者 Re:求助关于Java的抗锯齿实现 [Re:widewindow]
JiafanZhou



版主


发贴: 736
积分: 61
于 2008-06-06 16:34 user profilesend a private message to usersend email to JiafanZhousearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
Based on your comment 1 here, I thought that JAVA *does* release the implementation of Java's anti-aliase. (not sure about if it is the correct name). That is why I propose you to write an email to one of the those experts in JVM or DLL (wherever they are, I don't guess where it is).

Another good place to try is the javaranch (http://www.javaranch.com/), there are lots of talented people sharing their knowledge on a daily basis. But you need a very good English to describe your circumstances otherwise people will not understand you.

So two things you can try. If you really want, you can put your question in English here first and I will review them for you to check if you asked the right question.

Let me know if you have any questions.

Thanks,
Jiafan



When I was a kid I used to pray every night for a new bike. Then I realized that The Lord doesn't work that way, so I stole one and asked him to forgive me.
作者 Re:求助关于Java的抗锯齿实现 [Re:widewindow]
widewindow





发贴: 9
积分: 0
于 2008-06-06 17:01 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
Thank you very much for your suggestion.

Just before 1 minute, I was reading the TexturePaintContext.java released in the src.zip, It seems to contain the implementation that I'm interesting in. If I cannot find what I want, I surely will do as you suggested.

By the way, I'm a layman about Java, I'm writing a small game on Windows platform, and very serious about anti-alias. A java game implemented the same feature I'm implementing with perfect anti-alias. So I made some study about it and knew the Java environment did the job.



作者 Re:求助关于Java的抗锯齿实现 [Re:widewindow]
widewindow





发贴: 9
积分: 0
于 2008-06-09 12:01 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
I followed your advice and posted the question on javaranch. I got some useful infomation there. The URL is:
http://saloon.javaranch.com/cgi-bin/ubb/ultimatebb.cgi?ubb=get_topic&f=2&t=017410
There, it was said the algorighm is released in JDK 7. I'll study the source package and try to find the algorithm.

Thank you!



作者 Re:求助关于Java的抗锯齿实现 [Re:widewindow]
JiafanZhou



版主


发贴: 736
积分: 61
于 2008-06-09 19:24 user profilesend a private message to usersend email to JiafanZhousearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
Having read the thread you posted in Javaranch, I have some new suggestions for you to follow if you think they are possible and worth trying.

Basically, we have an example of some other games which deals with anti-aliasing perfectly using the following JAVA awt code:


stoneImage[i] = new BufferedImage(a + d, a + d, BufferedImage.TYPE_INT_ARGB/* 2 */);
Graphics2D stoneGraphics = stoneImage[i].createGraphics();
stoneGraphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
stoneGraphics.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_PURE);
stoneGraphics.setRenderingHint(RenderingHints.KEY_COLOR_RENDERING, RenderingHints.VALUE_COLOR_RENDER_QUALITY);
stoneGraphics.setRenderingHint(RenderingHints.KEY_ALPHA_INTERPOLATION, RenderingHints.VALUE_ALPHA_INTERPOLATION_QUALITY);


- What does Javadoc tell you about these code?
- Have you looked at the source code for this implementation? (especially you mentioned the JDK7)?
most importantly, the RendingHints class
- Debugging the code (there might be some problems debugging the JDK code, you can raise another thread here if necessary)

Regards,
Jiafan



When I was a kid I used to pray every night for a new bike. Then I realized that The Lord doesn't work that way, so I stole one and asked him to forgive me.
作者 Re:求助关于Java的抗锯齿实现 [Re:widewindow]
widewindow





发贴: 9
积分: 0
于 2008-06-11 10:50 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
I use following simple but completely runnable java program to test anti-aliasing:

/*
* Copyright Coffee 2000 David Flanagan. All rights reserved.
* This code is from the book Java Examples in a Nutshell, 2nd Edition.
* It is provided AS-IS, WITHOUT ANY WARRANTY either expressed or implied.
* You may study, use, and modify it for any non-commercial purpose.
* You may distribute it non-commercially as long as you retain this notice.
* For a commercial use license, or to purchase the book (recommended),
* visit http://www.davidflanagan.com/javaexamples2.
*/

import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.awt.BasicStroke;
import java.awt.Color;
import java.awt.Font;
import java.awt.GradientPaint;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.RenderingHints;
import java.awt.geom.AffineTransform;
import java.awt.image.BufferedImage;

import javax.swing.JFrame;
import javax.swing.JPanel;

/** A demonstration of anti-aliasing */
class AntiAlias extends JPanel{
static final int WIDTH = 650, HEIGHT = 350; // Size of our example

public String getName() {
return "AntiAliasing";
}

public int getWidth() {
return WIDTH;
}

public int getHeight() {
return HEIGHT;
}

/** Draw the example */
public void paint(Graphics g1) {
Graphics2D g = (Graphics2D) g1;
BufferedImage image = // Create an off-screen image
new BufferedImage(65, 35, BufferedImage.TYPE_INT_ARGBlack Eye;
Graphics2D ig = image.createGraphics(); // Get its Graphics for drawing

// Set the background to a gradient fill. The varying color of
// the background helps to demonstrate the anti-aliasing effect
ig.setPaint(new GradientPaint(0, 0, Color.black, 65, 35, Color.white));
ig.fillRect(0, 0, 65, 35);

// Set drawing attributes for the foreground.
// Most importantly, turn on anti-aliasing.
ig.setStroke(new BasicStroke(2.0f)); // 2-pixel lines
ig.setFont(new Font("Serif", Font.BOLD, 18)); // 18-point font
ig.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
/*ig.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_PURE);
ig.setRenderingHint(RenderingHints.KEY_COLOR_RENDERING, RenderingHints.VALUE_COLOR_RENDER_QUALITY);*/
ig.setRenderingHint(RenderingHints.KEY_ALPHA_INTERPOLATION, RenderingHints.VALUE_ALPHA_INTERPOLATION_QUALITY);

// Now draw pure blue text and a pure red oval
ig.setColor(Color.blue);
//ig.drawString("Java", 9, 22);
//ig.setColor(Color.red);
//ig.drawOval(1, 1, 32, 32);
ig.drawLine(13, 0, 19, 0);
ig.drawLine(10, 1, 22, 1);
ig.drawLine(8, 2, 24, 2);
ig.drawLine(7, 3, 25, 3);
ig.drawLine(6, 4, 26, 4);
ig.drawLine(5, 5, 27, 5);
ig.drawLine(4, 6, 28, 6);
ig.drawLine(3, 7, 29, 7);
ig.drawLine(3, 8, 29, 8);
ig.drawLine(2, 9, 30, 9);
ig.drawLine(2, 10, 30, 10);
ig.drawLine(2, 11, 30, 11);
ig.drawLine(1, 12, 31, 12);
ig.drawLine(1, 13, 31, 13);
ig.drawLine(1, 14, 31, 14);
ig.drawLine(1, 15, 31, 15);
ig.drawLine(1, 16, 31, 16);
ig.drawLine(1, 17, 31, 17);
ig.drawLine(1, 18, 31, 18);
ig.drawLine(2, 19, 30, 19);
ig.drawLine(2, 20, 30, 20);
ig.drawLine(2, 21, 30, 21);
ig.drawLine(3, 22, 29, 22);
ig.drawLine(3, 23, 29, 23);
ig.drawLine(4, 24, 28, 24);
ig.drawLine(5, 25, 27, 25);
ig.drawLine(6, 26, 26, 26);
ig.drawLine(7, 27, 25, 27);
ig.drawLine(8, 28, 24, 28);
ig.drawLine(10, 29, 22, 29);
ig.drawLine(13, 30, 19, 30);

// Finally, scale the image by a factor of 10 and display it
// in the window. This will allow us to see the anti-aliased pixels
g.drawImage(image, AffineTransform.getScaleInstance(10, 10), this);

// Draw the image one more time at its original size, for comparison
g.drawImage(image, 0, 0, this);
}

public static void main(String[] a) {
JFrame f = new JFrame();
f.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
System.exit(0);
}
});
f.setContentPane(new AntiAlias());
f.setSize(400,400);
f.setVisible(true);
}

}

My question is, is there any debugging tool that can trace into the system code after f.setVisible(true); ? From there, I think the anti-aliasing job is down by the java system modules.



作者 Re:求助关于Java的抗锯齿实现 [Re:widewindow]
JiafanZhou



版主


发贴: 736
积分: 61
于 2008-06-13 15:50 user profilesend a private message to usersend email to JiafanZhousearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
Sorry I replied you late. I am kind of busy these days.

Now to answer your previous questions, of course there are lots of debugging tools for Java programs in the market place. The one I use is the embedded debugger in Eclipse IDE. And it is very easy to learn and use, followings are the steps:

1. Download the latest Eclipse IDE, available at http://www.eclipse.org/.
2. Create a new Java project in Eclipse.
3. Create a new Java class called "AntiAlias".
4. Set a breakpoint at the line you want the debugger to stop.
4. Run debugging.

Any problems, let me know.

Regards,
Jiafan



When I was a kid I used to pray every night for a new bike. Then I realized that The Lord doesn't work that way, so I stole one and asked him to forgive me.
作者 Re:求助关于Java的抗锯齿实现 [Re:widewindow]
widewindow





发贴: 9
积分: 0
于 2008-06-13 16:32 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
Thank you for your reply.

I used quite a bit time to read some of JRE7's source code, I think MOST likely, the anti-alias code should be in Pisces modules. Later, I visited http://openjdk.java.net/groups/2d to find the full source code is in https://phoneme.dev.java.net/svn/phoneme/components/pisces/trunk, for your conveniences, please use Subversion to check out the source code, it's profound and not easy to understand. I don't know how much time I should spend to understand it.

Surely I'll follow your guide to debug the java example. Thank you!



作者 Re:求助关于Java的抗锯齿实现 [Re:widewindow]
JiafanZhou



版主


发贴: 736
积分: 61
于 2008-06-27 16:22 user profilesend a private message to usersend email to JiafanZhousearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
Link this thread to the following thread.
http://www.cjsdn.net/post/view?bid=46&id=194763&tpg=1&ppg=1&sty=1#194826

looks very similar issue to me.



When I was a kid I used to pray every night for a new bike. Then I realized that The Lord doesn't work that way, so I stole one and asked him to forgive me.
作者 Re:求助关于Java的抗锯齿实现 [Re:widewindow]
jancyu2008





发贴: 36
积分: 0
于 2008-07-01 23:29 user profilesend a private message to usersend email to jancyu2008search all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
I don't understand !!!!!!!!!!


Every day thinking about JAVA, because I like to
Welcome to My pagehttp://jeakylau.51.com
My E-mail:jeakylau@126.com
My QQ : 529163539

flat modethreaded modego to previous topicgo to next topicgo to back
  已读帖子
  新的帖子
  被删除的帖子
Jump to the top of page

   Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent
Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1
客服电话 18559299278    客服信箱 714923@qq.com    客服QQ 714923