-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPicResize.java
More file actions
22 lines (21 loc) · 823 Bytes
/
Copy pathPicResize.java
File metadata and controls
22 lines (21 loc) · 823 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
/* *****************************************************************************
* Name: Ada Lovelace
* Coursera User ID: 123456
* Last modified: October 16, 1842
**************************************************************************** */
public class PicResize {
public static void main(String[] args) {
Picture pic = new Picture(args[0]);
int w = Integer.parseInt(args[1]);
int h = Integer.parseInt(args[2]);
Picture picture = new Picture(w, h);
for (int col = 0; col < w; col++) {
for (int row = 0; row < h; row++) {
int COL = col * (pic.width()) / w;
int ROW = row * (pic.height()) / h;
picture.set(col, row, pic.get(COL, ROW));
}
}
picture.show();
}
}