Skip to content

Commit

Permalink
Fixed bug on ratio 1 case
Browse files Browse the repository at this point in the history
  • Loading branch information
LuisBoto committed Nov 2, 2021
1 parent 40f5322 commit 521cea2
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/hider/imageHandling/ImageHiderHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@ private void merge() {
int secretPixel, canvasPixel, counter = 0, nextPixelPair = 0;
while (canvasHandler.hasNextInt()) {
if (counter == nextPixelPair && secretHandler.hasNextInt()) {
nextPixelPair = counter + 2 + ratio;
counter++;
nextPixelPair = counter + ratio;
secretPixel = secretHandler.getNextInt();
resultHandler.setNextInt(this.binaryConverter.mergeFirstHalfs(canvasHandler.getNextInt(), secretPixel));
resultHandler.setNextInt(this.binaryConverter.mergeSecondHalfs(canvasHandler.getNextInt(), secretPixel));
counter++;
} else {
canvasPixel = canvasHandler.getNextInt();
resultHandler.setNextInt(canvasPixel);
Expand Down
4 changes: 2 additions & 2 deletions src/hider/imageHandling/ImageRevealHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ private void unmerge() {
int canvasPixel1, canvasPixel2, canvasCounter = 0, nextPixelPair = 0, secretPixelCount = 0;
while (canvasHandler.hasNextInt() && secretPixelCount < this.totalSecretPixels) {
if (canvasCounter == nextPixelPair) {
nextPixelPair = canvasCounter + 2 + ratio;
canvasCounter++;
nextPixelPair = canvasCounter + ratio;
canvasPixel1 = canvasHandler.getNextInt();
canvasPixel2 = canvasHandler.getNextInt();
secretHandler.setNextInt(this.binaryConverter.unmergeSecretPixel(canvasPixel1, canvasPixel2));
canvasCounter++;
secretPixelCount++;
} else {
canvasHandler.getNextInt();
Expand Down

0 comments on commit 521cea2

Please sign in to comment.