?? tutorial.html
字號:
<html>
<header>
<title>Gif4J LIGHT for Java - Tutorial</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" href="style.css" type="text/css">
</header>
<body bgcolor="#ffffff" >
<center>
<img src="images/gif4j_software_logotype.gif"><br><br>
<h4>Gif4J LIGHT v 1.0 Tutorial</h4>
<br>
</center>
<a name="content"></a><table align="center" width="400" border="0" cellspacing="1" bgcolor="#FFFFFF" cellpadding="0">
<tr><td bgcolor="#324697" align="center" class="white_medium"><b>Creating GIF Images</b></td></tr>
<tr><td bgcolor="#F0F0F0" align="center" class="white_small"><a href="#gifimagecreate" class="blue">Construct a GIF Image</a></td></tr>
<tr><td bgcolor="#F0F0F0" align="center" class="white_small"><a href="#gifimageresizestrategies" class="blue">Resize Strategies</a></td></tr>
<tr><td bgcolor="#F0F0F0" align="center" class="white_small"><a href="#gifimagecomments" class="blue">Add GIF Image Comments</a></td></tr>
<tr><td bgcolor="#F0F0F0" align="center" style="font-size: 5px"> </td></tr>
<tr><td bgcolor="#324697" align="center" class="white_medium"><b>Creating GIF Frames</b></td></tr>
<tr><td bgcolor="#F0F0F0" align="center" class="white_small"><a href="#gifframecreate" class="blue">Construct a GIFFrame</a></td></tr>
<tr><td bgcolor="#F0F0F0" align="center" class="white_small"><a href="#absrelpos" class="blue">Absolute and Relative Internal GIF Frame Positioning</a></td></tr>
<tr><td bgcolor="#F0F0F0" align="center" class="white_small"><a href="#gifframedisposalmethoddelaytime" class="blue">Disposal Methods & Delay Time</a></td></tr>
<tr><td bgcolor="#F0F0F0" align="center" class="white_small"><a href="#gifframeadd" class="blue">Adding GIF Frames to a GIF Image</a></td></tr>
<tr><td bgcolor="#F0F0F0" align="center" style="font-size: 5px"> </td></tr>
<tr><td bgcolor="#324697" align="center" class="white_medium">Saving GIF Images</td></tr>
<tr><td bgcolor="#F0F0F0" align="center" class="white_small"><a href="#gifimagewrite" class="blue">Encode and Save a GIF Image</a></td></tr>
</table>
<br><br>
<br>
<table cellspacing="1" cellpadding="5" border="0" align="center" bgcolor="#324697">
<tr>
<td bgcolor="#324697" align="center"class="white_large">Construct GIF Images. Resize Strategies & Looping. Add GIF Image comments</td>
</tr>
<tr>
<td bgcolor="#FFFFFF" class="dark_gray">
<br class="small">
<br class="small">
<a name="gifimagecreate"></a><h1 align="center">Construct a GIF Image</h1>
<p>
The <a href="java-api-light/com/gif4j/light/GifImage.html" target="_blank">GifImage</a> java class
is used to represent a gif image as a sequence of one or more <a href="java-api-light/com/gif4j/light/GifFrame.html" target="_blank">frames</a>
and to aggregate and encode some general gif image specific parameters including GIF image logic screen size, GIF file format version,
loop information and ASCII textual comments.
</p>
<p style="margin-top: 10px;">
The GifImage class has the next constructors:<br><br>
<span class="code">
<font color="#ffffff"> </font><font color="#7f0055"><b>public </b></font><font color="#000000">GifImage</font><font color="#000000">()</font>;<br/>
<font color="#ffffff"> </font><font color="#7f0055"><b>public </b></font><font color="#000000">GifImage</font><font color="#000000">(</font><font color="#7f0055"><b>int </b></font><font color="#000000">resizeStrategy</font><font color="#000000">)</font>;<br/>
<font color="#ffffff"> </font><font color="#7f0055"><b>public </b></font><font color="#000000">GifImage</font><font color="#000000">(</font><font color="#7f0055"><b>int </b></font><font color="#000000">width, </font><font color="#7f0055"><b>int </b></font><font color="#000000">height</font><font color="#000000">)</font>;<br/>
<font color="#ffffff"> </font><font color="#7f0055"><b>public </b></font><font color="#000000">GifImage</font><font color="#000000">(</font><font color="#7f0055"><b>int </b></font><font color="#000000">width, </font><font color="#7f0055"><b>int </b></font><font color="#000000">height, </font><font color="#7f0055"><b>int </b></font><font color="#000000">resizeStrategy</font><font color="#000000">)</font>;<br/>
</span>
<br>
The first two constructors create <span class="code">GifImage</span> with indefinite general gif image width and height -
these parameters will be taken from the first added frame.
<br><br>
<span class="text_red">Hint</span>: You can always get the current gif image width/height using the next methods:<br><br>
<span class="code">
<font color="#ffffff"> </font><font color="#7f0055"><b>public </b></font><font color="#7f0055"><b>int </b></font><font color="#000000">getCurrentLogicWidth</font><font color="#000000">()</font><br/>
<font color="#ffffff"> </font><font color="#7f0055"><b>public </b></font><font color="#7f0055"><b>int </b></font><font color="#000000">getCurrentLogicHeight</font><font color="#000000">()</font><br/>
</span>
<br><br class="small">
</p>
<a name="gifimageresizestrategies"></a><h1 align="center">Resize Strategies</h1>
<p>Gif4J PRO undertakes to control general image size (take into consideration all internal frames' size and their positions) using one of the predefined resize strategies:
<a target="_blank" href="java-api-light/com/gif4j/light/GifImage.html#RESIZE_STRATEGY_CROP_TO_FIT_IMAGE_SIZE">Crop to Fit Image Size</a>,
<a target="_blank" href="java-api-light/com/gif4j/light/GifImage.html#RESIZE_STRATEGY_SCALE_TO_FIT_IMAGE_SIZE">Scale to Fit Image Size</a> and
<a target="_blank" href="java-api-light/com/gif4j/light/GifImage.html#RESIZE_STRATEGY_EXTEND_TO_CURRENT">Extend to Current</a>.
First two strategies allows to fix the general gif image size (logical screen size).
The last extends logical screen size to fit all added gif frames.<br>
Below examples demostrate all strategies (see <i>examples/ResizeStrategies</i>):<br><br>
<center>
<img border="1" src="images/tutorial/ResizeStrategiesExample_crop_to_fit.gif"><br>
crop to fit image size (predefined size: 150x150)<br><br>
<img border="1" src="images/tutorial/ResizeStrategiesExample_scale_to_fit.gif"><br>
scale to fit image size (predefined size: 150x150)<br><br>
<img border="1" src="images/tutorial/ResizeStrategiesExample_extend_to_current.gif"><br>
extend to current (extended size: 200x200)<br><br>
</center>
</p>
<a name="gifimagelooping"></a><h1 align="center">GIF Image Looping</h1>
<p>Animated gif images can have a Looping Application Extension Block that tells Encoder to loop the entire GIF file.
Based on the Gif89a specification you can set number of iterations between 0 and 65535 where 0 means indefinite (infinite) looping.
The next method should be used:<br><br>
<span class="code">
<font color="#ffffff"> </font><font color="#7f0055"><b>public </b></font><font color="#7f0055"><b>void </b></font><font color="#000000">setLoopNumber</font><font color="#000000">(</font><font color="#7f0055"><b>int </b></font><font color="#000000">number</font><font color="#000000">) </font><br/><br/>
</span>
<span class="text_red">Note</span>: By default a new <code>GifImage</code> doesn't contain a Looping Application Extension Block at all which is equal to 1 iteration.
To set, for example, infinite looping you should call <code>gifImage.setLoopNumber(0)</code>.<br><br class="small">
<span class="text_red">Note</span>: A lot of gif encoders and viewers (including Microsoft IE browser) ignore number of iterations more than 1
and iterate an animated gif image indefinitely.<br><br class="small">
<span class="text_red">Hint</span>: You can set default delay time between frames. This delay is automatically applied to adding frames without delay parameter set.
The next method should be used:<br><br class="small">
<span class="code">
<font color="#ffffff"> </font><font color="#7f0055"><b>public </b></font><font color="#7f0055"><b>void </b></font><font color="#000000">setDefaultDelay</font><font color="#000000">(</font><font color="#7f0055"><b>int </b></font><font color="#000000">delay</font><font color="#000000">) </font><br/>
</span><br class="small">
<span class="text_red">Note</span>: Any delay parameter is set in 1/100 (centiseconds) - value 100 means delay in 1 second.
Default delay between frames is set to 200 (2 seconds).
</p>
<br class="small"><a name="gifimagecomments"></a><h1 align="center">Add ASCII textual Comments to a GIF Image</h1>
<p>The GIF Image Comment Extension contains textual information which
is not part of the actual graphics in the GIF Data Stream. It is suitable
for including comments about the graphics, credits, descriptions or any
other type of non-control and non-graphic data.<br><br class="small">
The next method should be used to add comments (please consult <a href="java-api-light/com/gif4j/light/GifImage.html" target="_blank">GifImage API</a> for more info):<br><br>
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -