Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get sub image from buffered image

Tags:

java

image

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 ?

like image 220
Jagan Avatar asked Apr 28 '11 05:04

Jagan


1 Answers

cast the double values to int.

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

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...

like image 133
camickr Avatar answered Nov 15 '22 16:11

camickr