?? imagetourexample.java
字號:
import com.gif4j.light.GifEncoder;
import com.gif4j.light.GifFrame;
import com.gif4j.light.GifImage;
import java.awt.*;
import java.io.File;
import java.io.IOException;
/**
* This example demostrates how to create a simple image tour.
*/
public class ImageTourExample {
public static void main(String[] args) {
// change out directory if it is necessary
File outputDir = new File("." + File.separator + "result");
if (!outputDir.exists())
outputDir.mkdirs();
try {
// read images. Here we read from files but it can be any source (internet, database etc.)
Image[] images = new Image[4];
for (int i = 1; i <= 4; i++)
images[i - 1] = Toolkit.getDefaultToolkit().createImage("house_"+i+".jpg");
// create gif image
GifImage gifImage = new GifImage(160, 120, GifImage.RESIZE_STRATEGY_SCALE_TO_FIT_IMAGE_SIZE);
// set indefinite looping
gifImage.setLoopNumber(0);
// create and add GifFrames in loop
for (int i = 0; i < images.length; i++) {
GifFrame nextFrame = new GifFrame(images[i]);
gifImage.addGifFrame(nextFrame);
}
// set longer delay (5 seconds) for the last frame
gifImage.getLastFrame().setDelay(500);
// encode gif image
GifEncoder.encode(gifImage, new File(outputDir, "ImageTourExample.gif"), true);
} catch (IOException e) {
e.printStackTrace();
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -