Skip to content

Commit 0a699bd

Browse files
committed
tR remove byte shifting magic
1 parent 77c3305 commit 0a699bd

File tree

3 files changed

+22
-4
lines changed

3 files changed

+22
-4
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[1, 0, 0]
2+
[1, 1, 0]
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package org.approvaltests.awt;
2+
3+
import java.util.Arrays;
4+
import org.approvaltests.Approvals;
5+
import org.junit.jupiter.api.Test;
6+
7+
class GifSequenceWriterTest
8+
{
9+
@Test
10+
void applesauce()
11+
{
12+
Approvals.verifyAll("", new Boolean[]{true, false},
13+
b -> Arrays.toString(GifSequenceWriter.getBytesForLoopContinuously(b)));
14+
}
15+
}

approvaltests/src/main/java/org/approvaltests/awt/GifSequenceWriter.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,15 +76,16 @@ private IIOMetadata getMetadata(int imageType, Duration timeBetweenFramesMS, boo
7676
IIOMetadataNode child = new IIOMetadataNode("ApplicationExtension");
7777
child.setAttribute("applicationID", "NETSCAPE");
7878
child.setAttribute("authenticationCode", "2.0");
79-
child.setUserObject(getBytesForUseContinuously(loopContinuously));
79+
child.setUserObject(getBytesForLoopContinuously(loopContinuously));
8080
appEntensionsNode.appendChild(child);
8181
imageMetaData2.setFromTree(metaFormatName, root);
8282
return imageMetaData2;
8383
}
84-
public static byte[] getBytesForUseContinuously(boolean loopContinuously)
84+
public static byte[] getBytesForLoopContinuously(boolean loopContinuously)
8585
{
86-
int loop = loopContinuously ? 0 : 1;
87-
return new byte[]{0x1, (byte) (loop & 0xFF), (byte) ((loop >> 8) & 0xFF)};
86+
byte[] loop = {1, 0, 0};
87+
byte[] once = {1, 1, 0};
88+
return loopContinuously ? loop : once;
8889
}
8990
static File writeAnimatedGif(File imageFile, ArrayList<BufferedImage> images, Duration timeBetweenFramesMS)
9091
{

0 commit comments

Comments
 (0)