栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

使用AffineTransform的Java图像旋转输出黑色图像,但是在调整大小时效果很好

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

使用AffineTransform的Java图像旋转输出黑色图像,但是在调整大小时效果很好

将新的BufferedImage传递到filter()方法中,而不是让它创建自己的作品(不是完全黑色)。

同样,变换似乎无法正常工作,图像最终在目标中偏移了。我能够通过手动应用必要的转换来解决它,以相反的顺序记录这些工作,并且在目标图像中,width
=旧高度,而height =旧宽度。

AffineTransform tx = new AffineTransform();// last, width = height and height = width :)tx.translate(originalImage.getHeight() / 2,originalImage.getWidth() / 2);tx.rotate(Math.PI / 2);// first - center image at the origin so rotate works OKtx.translate(-originalImage.getWidth() / 2,-originalImage.getHeight() / 2);AffineTransformOp op = new AffineTransformOp(tx, AffineTransformOp.TYPE_BILINEAR);// new destination image where height = width and width = height.BufferedImage newImage =new BufferedImage(originalImage.getHeight(), originalImage.getWidth(), originalImage.getType());op.filter(originalImage, newImage);

filter()的javadoc声明它将为您创建BufferedImage,我仍然不确定为什么它不起作用,这里肯定有问题。

 If the destination image is null, a BufferedImage is created with the source ColorModel.


转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/438007.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号