Author:
Porlus (posted
2013-04-18 15:14:02 , viewed 476 times)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
private void pixelate (BufferedImage im , int x , int y , int w , int h , int block ) {
int width = im .getWidth ();
int height = im .getHeight ();
int hw = w >> 1 ;
int hh = h >> 1 ;
int [] pixels = im .getRGB (0 , 0 , width , height , null , 0 , width );
int [] temp = pixels .clone ();
for (int yy = -hh ; yy < hh ; yy ++) {
for (int xx = -hw ; xx < hw ; xx ++) {
int col = 0 ;
for (int i = 0 ; i < block ; i ++) {
int yd = yy / block + y + i ;
if (yd < 0 || yd >= height ) continue ;
for (int j = 0 ; j < block ; j ++) {
int xd = xx / block + x + j ;
if (xd < 0 || xd >= width ) continue ;
col += pixels [yd * width + xd ];
}
}
if (yy + y < 0 || yy + y >= height || xx + x < 0 || xx + x >= width ) continue ;
temp [(yy + y ) * width + (xx + x )] = col / (block * block );
}
}
im .setRGB (0 , 0 , width , height , temp , 0 , width );
}
Special syntax:
To highlight a line (yellow background), prefix it with '@@'
To indicate that a line should be removed (red background), prefix it with '-'
To indicate that a line should be added (green background), prefix it with '+'
To post multiple snippets, seperate them by '~~~~'
ivj94
(586 views)
2018-03-24 14:47:39
ivj94
(49 views)
2018-03-24 14:46:31
ivj94
(383 views)
2018-03-24 14:43:53
Solater
(63 views)
2018-03-17 05:04:08
nelsongames
(110 views)
2018-03-05 17:56:34
Gornova
(159 views)
2018-03-02 22:15:33
buddyBro
(704 views)
2018-02-28 16:59:18
buddyBro
(93 views)
2018-02-28 16:45:17
xxMrPHDxx
(494 views)
2017-12-31 17:17:51
xxMrPHDxx
(734 views)
2017-12-31 17:15:51
java-gaming.org is not responsible for the content posted by its members, including references to external websites,
and other references that may or may not have a relation with our primarily
gaming and game production oriented community.
inquiries and complaints can be sent via email to the info‑account of the
company managing the website of java‑gaming.org