Skip to content

Commit 58452f3

Browse files
committed
Add ImageTiler
1 parent 257e31c commit 58452f3

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
package evhh.common.imagemanipulation;
2+
3+
import java.awt.*;
4+
import java.awt.image.BufferedImage;
5+
6+
/***********************************************************************************************************************
7+
* @project: MainProject
8+
* @package: evhh.common.imagemanipulation
9+
* ---------------------------------------------------------------------------------------------------------------------
10+
* @authors: Hamed Haghjo & Elias Vahlberg
11+
* @date: 2021-05-16
12+
* @time: 13:55
13+
**********************************************************************************************************************/
14+
public class ImageTiler
15+
{
16+
public static BufferedImage tileImage(BufferedImage image, int cols, int rows)
17+
{
18+
int width = image.getWidth()*cols;
19+
int height = image.getWidth()*rows;
20+
BufferedImage tiledImage = new BufferedImage(width,height, BufferedImage.TYPE_INT_ARGB);
21+
Graphics2D graphics2D = tiledImage.createGraphics();
22+
for (int i = 0; i < cols; i++)
23+
{
24+
for (int j = 0; j < rows; j++)
25+
{
26+
graphics2D.drawImage(image,null,image.getWidth()*cols,image.getHeight()*cols);
27+
}
28+
}
29+
graphics2D.dispose();
30+
return tiledImage;
31+
32+
33+
}
34+
}

0 commit comments

Comments
 (0)