1 | // m = cols, n = rows |
2 | static L<BufferedImage> imageToTiles(BufferedImage img, int m, int n) { |
3 | new L<BufferedImage> tiles; |
4 | int w = img.getWidth(), h = img.getHeight(); |
5 | if (m > w || n > h) |
6 | fail("Too many tiles (" + m + "/" + n + ") for image of size " + w + "*" + h); |
7 | |
8 | for y to n: { |
9 | int y1 = y*h/n, y2 = (y+1)*h/n; |
10 | for x to m: { |
11 | int x1 = x*w/m, x2 = (x+1)*w/m; |
12 | Rect r = /*rectMinSize(1, 1,*/ rectFromPoints(x1, y1, x2, y2)/*)*/; |
13 | tiles.add(clipBufferedImage(img, r)); |
14 | } |
15 | } |
16 | ret tiles; |
17 | } |
download show line numbers debug dex old transpilations
Travelled to 13 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1016032 |
Snippet name: | imageToTiles |
Eternal ID of this version: | #1016032/5 |
Text MD5: | 984094cd82c08af342d372eb58a79c00 |
Author: | stefan |
Category: | javax / a.i. |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2018-06-03 02:26:48 |
Source code size: | 547 bytes / 17 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 402 / 422 |
Version history: | 4 change(s) |
Referenced in: | [show references] |