旋转 tiff 图像时出现问题
我找到了一个代码来顺时针旋转 tiff 图像,但是它花费了很多时间,甚至在 jscrollpanel 中滚动图像也非常慢。
1.有没有简单的方法来旋转 tiff 图像,或者
2.下面的代码需要进行任何调整才能快速旋转它。
ReadableByteChannel rBytChnl = Channels.newChannel(url);
ByteBuffer buffer = ByteBuffer.allocate(4096 * 1024);
rBytChnl.read(buffer);
byte[] data = buffer.array();
SeekableStream stream = new ByteArraySeekableStream(data);
ParameterBlock pb = new ParameterBlock();
pb.add(stream);
RenderedOp op = JAI.create("tiff", pb);
TransposeType type = TransposeDescriptor.ROTATE_90;
ParameterBlock pb1 = new ParameterBlock();
pb1.addSource(op);
pb1.add(type);
pb1.add(new InterpolationBilinear());
image = JAI.create("transpose", pb1, null);
I have found a code to rotate a tiff image clockwise but its taking so much time and even scrolling the image in jscrollpanel is also very slow.
1.So is there any easy method to rotate a tiff image or
2.Any tweaking is needed in the below code to rotate it quickly.
ReadableByteChannel rBytChnl = Channels.newChannel(url);
ByteBuffer buffer = ByteBuffer.allocate(4096 * 1024);
rBytChnl.read(buffer);
byte[] data = buffer.array();
SeekableStream stream = new ByteArraySeekableStream(data);
ParameterBlock pb = new ParameterBlock();
pb.add(stream);
RenderedOp op = JAI.create("tiff", pb);
TransposeType type = TransposeDescriptor.ROTATE_90;
ParameterBlock pb1 = new ParameterBlock();
pb1.addSource(op);
pb1.add(type);
pb1.add(new InterpolationBilinear());
image = JAI.create("transpose", pb1, null);
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我已经调整了仿射变换以满足我的需要并且它工作正常。这仅适用于顺时针旋转 90 度,其他需要相应更改代码。
I have adjusted the affine transform to meet my needs and its working fine. This is only for 90 degree clockwise rotation and for other needs change the code accordingly.