summaryrefslogtreecommitdiff
path: root/Year_2/IandM/replication2x
diff options
context:
space:
mode:
authorSanto Cariotti <santo@dcariotti.me>2021-02-16 21:51:54 +0100
committerSanto Cariotti <santo@dcariotti.me>2021-02-16 21:51:54 +0100
commit321b268bb74512289f9eb361560e8ceb9d30fe59 (patch)
treeb5ddb9ab187a952891fc2f988fb47088fc03a5f9 /Year_2/IandM/replication2x
parent67438312a69f7b7aa1fdbc27610438897791ceef (diff)
i&m: add operations
Diffstat (limited to 'Year_2/IandM/replication2x')
-rw-r--r--Year_2/IandM/replication2x/data/lena.pngbin0 -> 473831 bytes
-rw-r--r--Year_2/IandM/replication2x/replication2x.pde22
2 files changed, 22 insertions, 0 deletions
diff --git a/Year_2/IandM/replication2x/data/lena.png b/Year_2/IandM/replication2x/data/lena.png
new file mode 100644
index 0000000..59ef68a
--- /dev/null
+++ b/Year_2/IandM/replication2x/data/lena.png
Binary files differ
diff --git a/Year_2/IandM/replication2x/replication2x.pde b/Year_2/IandM/replication2x/replication2x.pde
new file mode 100644
index 0000000..dc1d162
--- /dev/null
+++ b/Year_2/IandM/replication2x/replication2x.pde
@@ -0,0 +1,22 @@
+void setup() {
+ size(768, 512);
+ PImage img = loadImage("lena.png");
+ img.resize(256, 256);
+ image(img, 0, 0);
+ image(replication2x(img), 256, 0);
+}
+
+PImage replication2x(PImage I) {
+ PImage out = createImage(I.width*2, I.height*2, RGB);
+
+ for(int x = 0; x < I.width; ++x) {
+ for(int y = 0; y < I.height; ++y) {
+ out.set(2*x, 2*y, I.get(x, y));
+ out.set(2*x+1, 2*y, I.get(x, y));
+ out.set(2*x, 2*y+1, I.get(x, y));
+ out.set(2*x+1, 2*y+1, I.get(x, y));
+ }
+ }
+
+ return out;
+}