Unverified Commit a1697c32 authored by Exr0n's avatar Exr0n
Browse files

truncate if too long

parent 088ec1ac
No related merge requests found
Pipeline #94816 failed with stage
in 0 seconds
Showing with 6 additions and 2 deletions
+6 -2
......@@ -69,9 +69,12 @@ public class Image {
int ctr = 0;
for (char c : text.toCharArray()) { // https://stackoverflow.com/a/2451660
for (int j=0; j<8; j++) {
// bits_to_write[ctr] = (c >> (7-j)) & 1;
if (ctr >= height*width) break;
bits_to_write[ctr] = (c >> j) & 1;
ctr ++;
}
if (ctr >= height*width) break;
}
Pixel[][] new_pix = new Pixel[height][width];
......@@ -79,8 +82,9 @@ public class Image {
ctr = 0;
for (int i=0; i<height; i++) {
for (int j=0; j<width; j++) {
new_pix[i][j] = this.pixels[i][j];
new_pix[i][j].fixLowestBitOfR(bits_to_write[ctr]);
// new_pix[i][j] = this.pixels[i][j];
// new_pix[i][j].fixLowestBitOfR(bits_to_write[ctr]);
new_pix[i][j] = this.pixels[i][j].fixLowestBitOfR(bits_to_write[ctr]);
ctr ++;
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment