关于jdk 1.6的一个bug。。

wavebbs 2010-04-07 12:41:42
/**
* Draws as much of the specified area of the specified image as is
* currently available, scaling it on the fly to fit inside the
* specified area of the destination drawable surface. Transparent pixels
* do not affect whatever pixels are already there.
* <p>
* This method returns immediately in all cases, even if the
* image area to be drawn has not yet been scaled, dithered, and converted
* for the current output device.
* If the current output representation is not yet complete then
* <code>drawImage</code> returns <code>false</code>. As more of
* the image becomes available, the process that loads the image notifies
* the specified image observer.
* <p>
* This method always uses the unscaled version of the image
* to render the scaled rectangle and performs the required
* scaling on the fly. It does not use a cached, scaled version
* of the image for this operation. Scaling of the image from source
* to destination is performed such that the first coordinate
* of the source rectangle is mapped to the first coordinate of
* the destination rectangle, and the second source coordinate is
* mapped to the second destination coordinate. The subimage is
* scaled and flipped as needed to preserve those mappings.
* @param img the specified image to be drawn. This method does
* nothing if <code>img</code> is null.
* @param dx1 the <i>x</i> coordinate of the first corner of the
* destination rectangle.
* @param dy1 the <i>y</i> coordinate of the first corner of the
* destination rectangle.
* @param dx2 the <i>x</i> coordinate of the second corner of the
* destination rectangle.
* @param dy2 the <i>y</i> coordinate of the second corner of the
* destination rectangle.
* @param sx1 the <i>x</i> coordinate of the first corner of the
* source rectangle.
* @param sy1 the <i>y</i> coordinate of the first corner of the
* source rectangle.
* @param sx2 the <i>x</i> coordinate of the second corner of the
* source rectangle.
* @param sy2 the <i>y</i> coordinate of the second corner of the
* source rectangle.
* @param observer object to be notified as more of the image is
* scaled and converted.
* @return <code>false</code> if the image pixels are still changing;
* <code>true</code> otherwise.
* @see java.awt.Image
* @see java.awt.image.ImageObserver
* @see java.awt.image.ImageObserver#imageUpdate(java.awt.Image, int, int, int, int, int)
* @since JDK1.1
*/
public abstract boolean drawImage(Image img,
int dx1, int dy1, int dx2, int dy2,
int sx1, int sy1, int sx2, int sy2,
ImageObserver observer);




方法报
java.lang.ClassCastException: [S cannot be cast to [I
at java.awt.image.DirectColorModel.getRGB(DirectColorModel.java:697)
at sun.java2d.loops.OpaqueCopyAnyToArgb.Blit(CustomComponent.java:127)
at sun.java2d.loops.GraphicsPrimitive.convertFrom(GraphicsPrimitive.java:540)
at sun.java2d.loops.GraphicsPrimitive.convertFrom(GraphicsPrimitive.java:521)
at sun.java2d.loops.Blit$GeneralXorBlit.Blit(Blit.java:244)
at sun.java2d.pipe.DrawImage.blitSurfaceData(DrawImage.java:927)
at sun.java2d.pipe.DrawImage.renderImageCopy(DrawImage.java:550)
at sun.java2d.pipe.DrawImage.copyImage(DrawImage.java:73)
at sun.java2d.pipe.DrawImage.copyImage(DrawImage.java:998)
at sun.java2d.SunGraphics2D.copyImage(SunGraphics2D.java:2909)
at sun.java2d.SunGraphics2D.drawImage(SunGraphics2D.java:3047)

异常。。崩溃了。换成1.5 jdk就没问题。。。

有人知道原因么。。。
...全文
265 7 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
izard999 2010-05-26
  • 打赏
  • 举报
回复
像一般运行期异常都是你自己程序本身的bug.!
JAVA_JUNIOR 2010-05-25
  • 打赏
  • 举报
回复
affinetransform这个类,1.6与1.5不同了。。。
yugong2009 2010-04-07
  • 打赏
  • 举报
回复
学习…………
qqbz 2010-04-07
  • 打赏
  • 举报
回复
只是简单切换JDK就报异常?
xiaohuanjie 2010-04-07
  • 打赏
  • 举报
回复
有没有代码的,贴上来看看
zhouxingyu896 2010-04-07
  • 打赏
  • 举报
回复
学习

学习
wavebbs 2010-04-07
  • 打赏
  • 举报
回复
代码 平时运行没有异常 一旦我按下鼠标 就会出 无语了=。=

Graphics2D g2d = (Graphics2D) g;

AffineTransform origXform = g2d.getTransform();
AffineTransform newXform = (AffineTransform) (origXform.clone());
newXform.scale(1.0 * scale_factor / (1 << scale_shift),
1.0 * scale_factor / (1 << scale_shift));
newXform.translate(x, y);
if ( (flag & FLAG_FLIPX) != 0) {
newXform.scale( -1, 1);
}
if ( (flag & FLAG_FLIPY) != 0) {
newXform.scale(1, -1);
}
newXform.concatenate(spt.trans);
g2d.setTransform(newXform);
try {
g2d.drawImage(image, 0, 0, mod.w, mod.h, mod.x, mod.y,
mod.x + mod.w,
mod.y + mod.h, null);
}
catch (Exception ex) {
//ex.printStackTrace();
}

62,635

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧