【发布时间】:2015-05-06 18:12:30
【问题描述】:
我有图像的字节数组,我想通过这个数组旋转图像, 这是我的代码:
BufferedImage img = ImageUtil.load(inputImagePath);
WritableRaster raster = img .getRaster();
DataBufferByte data = (DataBufferByte) raster.getDataBuffer();
byte [] pixel = data.getData();
我怎么能做到这一点? , 谢谢
【问题讨论】:
-
为什么需要旋转字节数组?你能用This吗?
-
@JAtkin ,我的目标是通过仅使用数组创建旋转图像的新算法,如何至少获取像素位置?
-
如果你想创建一个新算法,那么到底要问什么?我们为您创建它?如果你想实现一些算法,那么试着去做,如果你遇到问题,再问更具体的问题。
-
通过字节数组处理像素也是无效的,更多信息请参见this答案。
-
@NikolayKondratyev 我的问题是我没有对像素的任何引用,但现在我通过使用这个: int w = img.getWidth(null); int h = img.getHeight(null); int[] rgbs = new int[w*h]; img.getRGB(0, 0, w, h, rgbs, 0, w); _ 我创建了自己的旋转和翻转图像算法 - 感谢您的评论
标签: java arrays byte raster image-rotation