Skip to content

Commit 475303f

Browse files
committed
R use Duration instead of int
1 parent 65c7c30 commit 475303f

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import java.awt.image.RenderedImage;
1313
import java.io.File;
1414
import java.io.IOException;
15+
import java.time.Duration;
1516
import java.util.ArrayList;
1617
import java.util.Iterator;
1718

@@ -44,7 +45,7 @@ public class GifSequenceWriter implements AutoCloseable
4445
*
4546
* @author Elliot Kroo (elliot[at]kroo[dot]net)
4647
*/
47-
public GifSequenceWriter(ImageOutputStream outputStream, int imageType, int timeBetweenFramesMS,
48+
public GifSequenceWriter(ImageOutputStream outputStream, int imageType, Duration timeBetweenFramesMS,
4849
boolean loopContinuously) throws IIOException, IOException
4950
{
5051
// my method to create a writer
@@ -58,7 +59,7 @@ public GifSequenceWriter(ImageOutputStream outputStream, int imageType, int time
5859
graphicsControlExtensionNode.setAttribute("disposalMethod", "none");
5960
graphicsControlExtensionNode.setAttribute("userInputFlag", "FALSE");
6061
graphicsControlExtensionNode.setAttribute("transparentColorFlag", "FALSE");
61-
graphicsControlExtensionNode.setAttribute("delayTime", Integer.toString(timeBetweenFramesMS / 10));
62+
graphicsControlExtensionNode.setAttribute("delayTime", "" + timeBetweenFramesMS.toMillis() / 10);
6263
graphicsControlExtensionNode.setAttribute("transparentColorIndex", "0");
6364
IIOMetadataNode commentsNode = getNode(root, "CommentExtensions");
6465
commentsNode.setAttribute("CommentExtension", "Created by MAH");
@@ -73,7 +74,7 @@ public GifSequenceWriter(ImageOutputStream outputStream, int imageType, int time
7374
gifWriter.setOutput(outputStream);
7475
gifWriter.prepareWriteSequence(null);
7576
}
76-
static File writeAnimatedGif(File imageFile, ArrayList<BufferedImage> images, int timeBetweenFramesMS)
77+
static File writeAnimatedGif(File imageFile, ArrayList<BufferedImage> images, Duration timeBetweenFramesMS)
7778
{
7879
try (ImageOutputStream output = new FileImageOutputStream(imageFile))
7980
{

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import java.awt.image.BufferedImage;
44
import java.io.File;
5+
import java.time.Duration;
56
import java.util.ArrayList;
67

78
import org.approvaltests.core.ApprovalWriter;
@@ -22,7 +23,7 @@ public PaintableMultiframeWriter(int numberOfFrames, Function1<Integer, Paintabl
2223
@Override
2324
public File writeReceivedFile(File received)
2425
{
25-
return GifSequenceWriter.writeAnimatedGif(received, getBufferedImages(), 500);
26+
return GifSequenceWriter.writeAnimatedGif(received, getBufferedImages(), Duration.ofMillis(500));
2627
}
2728
private ArrayList<BufferedImage> getBufferedImages()
2829
{

0 commit comments

Comments
 (0)