我想看看里面是怎么对图片的颜色进行像素处理的,可是jdk的源代码中只有这样的声明内容: /**
* Sets the paint mode of this graphics context to overwrite the
* destination with this graphics context's current color.
* This sets the logical pixel operation function to the paint or
* overwrite mode. All subsequent rendering operations will
* overwrite the destination with the current color.
*/
public abstract void setPaintMode(); /**
* Sets the paint mode of this graphics context to alternate between
* this graphics context's current color and the new specified color.
* This specifies that logical pixel operations are performed in the
* XOR mode, which alternates pixels between the current color and
* a specified XOR color.
* <p>
* When drawing operations are performed, pixels which are the
* current color are changed to the specified color, and vice versa.
* <p>
* Pixels that are of colors other than those two colors are changed
* in an unpredictable but reversible manner; if the same figure is
* drawn twice, then all pixels are restored to their original values.
* @param c1 the XOR alternation color
*/
public abstract void setXORMode(Color c1);因为Graphics只是个虚类,没有实现,他的另个子类我也看了,同样没有实现内容,这部分代码是怎么写的呢?
或者哪位有能实现这种类似功能的开源包或者代码的,请提示一下!
* Sets the paint mode of this graphics context to overwrite the
* destination with this graphics context's current color.
* This sets the logical pixel operation function to the paint or
* overwrite mode. All subsequent rendering operations will
* overwrite the destination with the current color.
*/
public abstract void setPaintMode(); /**
* Sets the paint mode of this graphics context to alternate between
* this graphics context's current color and the new specified color.
* This specifies that logical pixel operations are performed in the
* XOR mode, which alternates pixels between the current color and
* a specified XOR color.
* <p>
* When drawing operations are performed, pixels which are the
* current color are changed to the specified color, and vice versa.
* <p>
* Pixels that are of colors other than those two colors are changed
* in an unpredictable but reversible manner; if the same figure is
* drawn twice, then all pixels are restored to their original values.
* @param c1 the XOR alternation color
*/
public abstract void setXORMode(Color c1);因为Graphics只是个虚类,没有实现,他的另个子类我也看了,同样没有实现内容,这部分代码是怎么写的呢?
或者哪位有能实现这种类似功能的开源包或者代码的,请提示一下!
解决方案 »
- 如果通过java往一个word文件中插入文字内容
- 关于return的问题,帮我看看代码这样写有没有问题,谢谢
- 一般的应用软件,点击菜单栏的帮助菜单的帮主项,都会弹出一帮助文本,,我想要让其弹出一文本文档,,该怎样做???
- 高手进(JAVA下能否调用VB编译的动态链接库)
- C++写的函数在JAVA中可以调用吗?
- java程序能不能生成*.exe文件
- 类构造器问题求教。
- 如何把word文档转换为pdf格式,请问该用到什么工具?
- Jave 真的什么都能做吗?它有没有Delphi 方便,我说的是搞数据库方面
- jublider5中的import问题????
- java如何生成这样的xml文件
- 一道奇怪的面试题
Graphics graphics;
public void setPaintMode() {
if (debugLog()) {
info().log(toShortString() + " Setting paint mode");
}
graphics.setPaintMode();
}
public void setXORMode(Color aColor) {
if (debugLog()) {
info().log(toShortString() + " Setting XOR mode: " + aColor);
}
graphics.setXORMode(aColor);
}
/**
* Creates a graphics context for this component. This method will
* return <code>null</code> if this component is currently not
* displayable.
* @return a graphics context for this component, or <code>null</code>
* if it has none
* @see #paint
* @since JDK1.0
*/
public Graphics getGraphics() {
if (peer instanceof LightweightPeer) {
// This is for a lightweight component, need to
// translate coordinate spaces and clip relative
// to the parent.
if (parent == null) return null;
Graphics g = parent.getGraphics();
if (g == null) return null;
if (g instanceof ConstrainableGraphics) {
((ConstrainableGraphics) g).constrain(x, y, width, height);
} else {
g.translate(x,y);
g.setClip(0, 0, width, height);
}
g.setFont(getFont());
return g;
} else {
ComponentPeer peer = this.peer;
return (peer != null) ? peer.getGraphics() : null;
}
}
这里面调用的是父类的setPaintMode()方法,我想看的正是父类的setPaintMode()是怎么实现的,所以这段代码没有帮助。
http://www.google.com/codesearch/p?hl=en#Vph8Harfcw0/src/share/classes/sun/java2d/SunGraphics2D.java&q=sun.java2d.SunGraphics2D&sa=N&cd=3&ct=rc public void setPaintMode() {
setComposite(AlphaComposite.SrcOver);
} public void setXORMode(Color c) {
if (c == null) {
throw new IllegalArgumentException("null XORColor");
}
setComposite(new XORComposite(c, surfaceData));
}