如何从缓冲图像中获取子图像 [英] How to get sub image from buffered image

查看:99
本文介绍了如何从缓冲图像中获取子图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们可以使用 getSubimage(int,int,int,int)
从BufferedImage获取子图像但是我的问题是我想获得精确的子图像(矩形图像)通过将双值传递为 width height 。那有什么选择吗?

We can get a sub image from BufferedImage using getSubimage(int,int,int,int), but my problem is I want to get exact subimage(rectangle image) by passing double values as width and height. Is there any alternative for that ?

推荐答案

将双值转换为int。

getSubImage((int)x, (int)y, (int)width, (int)height);

并且@camickr提到内部单元格仍将由整数表示像素值。如果每个单元格是5像素的正方形。第一个单元格从(0,0)开始,第二个单元格从(5,0)开始等...

and as @camickr mentioned The internal cells will still be represented by integer pixel values. If each cell is 5 pixels square. The first cell starts at (0, 0), the second cell starts at (5, 0) etc...

这篇关于如何从缓冲图像中获取子图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆