-
Notifications
You must be signed in to change notification settings - Fork 83
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
30 changed files
with
788 additions
and
372 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{ | ||
|
||
"type": "GIF", | ||
"avatar": "DOUBLE", | ||
"pos": [ | ||
[ | ||
[90, 60, 70, 70],[88, 58, 70, 70],[80, 56, 70, 70],[70, 65, 70, 70], | ||
[90, 98, 70, 70],[70, 102, 70, 70],[65, 120, 70, 70],[85, 85, 70, 70] | ||
],[ | ||
[260, 5, 70, 70],[257, 0, 70, 70],[250, -10, 70, 70],[257, 0, 70, 70], | ||
[260, 5, 70, 70],[257, 0, 70, 70],[260, 10, 70, 70],[270, 10, 70, 70] | ||
] | ||
], | ||
"text": "", | ||
"round": true, | ||
"rotate": false, | ||
"avatarOnTop": true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
"type": "GIF", | ||
"avatar": "SINGLE", | ||
"pos": [ | ||
[90, 90, 105, 150], [90, 83, 96, 172], [90, 90, 106, 148], | ||
[88, 88, 97, 167], [90, 85, 89, 179], [90, 90, 106, 151], | ||
[0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], | ||
[0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0] | ||
], | ||
"text": "", | ||
"round": true, | ||
"rotate": false, | ||
"avatarOnTop": false | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"type": "GIF", | ||
"avatar": "SINGLE", | ||
"pos": [ | ||
[62, 143, 158, 113], [52, 177, 173, 105], [42, 192, 192, 92], [46, 182, 184, 100], | ||
[54, 169, 174, 110], [69, 128, 144, 135], [65, 130, 152, 124] | ||
], | ||
"text": "", | ||
"round": true, | ||
"rotate": false, | ||
"avatarOnTop": false | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{ | ||
"type": "GIF", | ||
"avatar": "DOUBLE", | ||
"pos": [ | ||
[ [92, 64, 40, 40], [135, 40, 40, 40], [84, 105, 40, 40], [80, 110, 40, 40], | ||
[155, 82, 40, 40], [60, 96, 40, 40], [50, 80, 40, 40], [98, 55, 40, 40], | ||
[35, 65, 40, 40], [38, 100, 40, 40], [70, 80, 40, 40], [84, 65, 40, 40], | ||
[75, 65, 40, 40]], | ||
[[58, 90, 50, 50], [62, 95, 50, 50], [42, 100, 50, 50], [50, 100, 50, 50], | ||
[56, 100, 50, 50], [18, 120, 50, 50], [28, 110, 50, 50], [54, 100, 50, 50], | ||
[46, 100, 50, 50], [60, 100, 50, 50], [35, 115, 50, 50], [20, 120, 50, 50], | ||
[40, 96, 50, 50]] | ||
], | ||
"text": "", | ||
"round": true, | ||
"rotate": false, | ||
"avatarOnTop": true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"type": "GIF", | ||
"avatar": "SINGLE", | ||
"pos": [ | ||
[60, 308, 210, 195], [60, 308, 210, 198], [45, 330, 250, 172], [58, 320, 218, 180], | ||
[60, 310, 215, 193], [40, 320, 250, 285], [48, 308, 226, 192], [51, 301, 223, 200] | ||
], | ||
"text": "", | ||
"round": true, | ||
"rotate": false, | ||
"avatarOnTop": false | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
|
||
"type": "GIF", | ||
"avatar": "SINGLE", | ||
"pos": [ | ||
[14, 20, 98, 98], [12, 33, 101, 85], [8, 40, 110, 76], [10, 33, 102, 84], [12, 20, 98, 98] | ||
], | ||
"text": "", | ||
"round": true, | ||
"rotate": false, | ||
"avatarOnTop": false | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{ | ||
|
||
"type": "GIF", | ||
"avatar": "SINGLE", | ||
"pos": [ | ||
[180, 60, 100, 100], [184, 75, 100, 100], [183, 98, 100, 100], | ||
[179, 118, 110, 100], [156, 194, 150, 48], [178, 136, 122, 69], | ||
[175, 66, 122, 85], [170, 42, 130, 96], [175, 34, 118, 95], | ||
[179, 35, 110, 93], [180, 54, 102, 93], [183, 58, 97, 92], | ||
[174, 35, 120, 94], [179, 35, 109, 93], [181, 54, 101, 92], | ||
[182, 59, 98, 92], [183, 71, 90, 96], [180, 131, 92, 101], | ||
[0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0] | ||
], | ||
"text": "", | ||
"round": true, | ||
"rotate": false, | ||
"avatarOnTop": false | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
|
||
"type": "GIF", | ||
"avatar": "SINGLE", | ||
"pos": [ | ||
[135, 240, 138, 47], [135, 240, 138, 47], [150, 190, 105, 95], [150, 190, 105, 95], | ||
[148, 188, 106, 98], [146, 196, 110, 88], [145, 223, 112, 61], [145, 223, 112, 61] | ||
], | ||
"text": "", | ||
"round": true, | ||
"rotate": false, | ||
"avatarOnTop": false | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
|
||
"type": "GIF", | ||
"avatar": "SINGLE", | ||
"pos": [ | ||
[87, 77, 220, 220], [96, 85, 220, 220], [92, 79, 220, 220], [92, 78, 220, 220], | ||
[92, 75, 220, 220], [92, 75, 220, 220], [93, 76, 220, 220], [90, 80, 220, 220] | ||
], | ||
"text": "", | ||
"round": true, | ||
"rotate": true, | ||
"avatarOnTop": false | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
|
||
"type": "GIF", | ||
"avatar": "DOUBLE", | ||
"pos": [ | ||
[[102, 95, 70, 80], [108, 60, 50, 100], [97, 18, 65, 95], | ||
[65, 5, 75, 75], [95, 57, 100, 55], [109, 107, 65, 75]], | ||
[[39, 91, 75, 75], [49, 101, 75, 75], [67, 98, 75, 75], | ||
[55, 86, 75, 75], [61, 109, 75, 75], [65, 101, 75, 75]] | ||
], | ||
"text": "", | ||
"round": true, | ||
"rotate": false, | ||
"avatarOnTop": true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
|
||
"type": "GIF", | ||
"avatar": "SINGLE", | ||
"pos": [ | ||
[82, 100, 130, 119], [82, 94, 126, 125], [82, 120, 128, 99], [81, 164, 132, 55], | ||
[79, 163, 132, 55], [82, 140, 127, 79], [83, 152, 125, 67], [75, 157, 140, 62], | ||
[72, 165, 144, 54], [80, 132, 128, 87], [81, 127, 127, 92], [79, 111, 132, 108] | ||
], | ||
"text": "", | ||
"round": true, | ||
"rotate": false, | ||
"avatarOnTop": false | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
|
||
"type": "GIF", | ||
"avatar": "DOUBLE", | ||
"pos": [ | ||
[[0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], | ||
[289, 70, 33, 33], [280, 73, 32, 32], [259, 31, 35, 35], [-50, 220, 175, 175]], | ||
[[108, 36, 32, 32], [122, 36, 32, 32], [0, 0, 0, 0], [19, 129, 123, 123], | ||
[-50, 200, 185, 185], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]] | ||
], | ||
"text": "", | ||
"round": true, | ||
"rotate": false, | ||
"avatarOnTop": true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"type": "GIF", | ||
"avatar": "SINGLE", | ||
"pos": [ | ||
[65, 128, 77, 72], [67, 128, 73, 72], [54, 139, 94, 61], [57, 135, 86, 65] | ||
], | ||
"text": "", | ||
"round": true, | ||
"rotate": false, | ||
"avatarOnTop": false | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
"type": "GIF", | ||
"avatar": "SINGLE", | ||
"pos": [ | ||
[39, 169, 267, 141], [40, 167, 264, 143], [38, 174, 270, 135], [40, 167, 264, 143], [38, 174, 270, 135], | ||
[40, 167, 264, 143], [38, 174, 270, 135], [40, 167, 264, 143], [38, 174, 270, 135], [28, 176, 293, 134], | ||
[5, 215, 333, 96], [10, 210, 321, 102], [3, 210, 330, 104], [4, 210, 328, 102], [4, 212, 328, 100], | ||
[4, 212, 328, 100], [4, 212, 328, 100], [4, 212, 328, 100], [4, 212, 328, 100], [29, 195, 285, 120] | ||
], | ||
"text": "", | ||
"round": true, | ||
"rotate": false, | ||
"avatarOnTop": false | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"type": "GIF", | ||
"avatar": "SINGLE", | ||
"pos": [ | ||
[25, 66, 80, 80], [25, 66, 80, 80], [23, 68, 80, 80], | ||
[20, 69, 80, 80], [22, 68, 80, 80] | ||
], | ||
"text": "", | ||
"round": true, | ||
"rotate": true, | ||
"avatarOnTop": false | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
package xmmt.dituon; | ||
|
||
import javax.imageio.*; | ||
import javax.imageio.metadata.IIOInvalidTreeException; | ||
import javax.imageio.metadata.IIOMetadata; | ||
import javax.imageio.metadata.IIOMetadataNode; | ||
import javax.imageio.stream.ImageOutputStream; | ||
import java.awt.image.RenderedImage; | ||
import java.io.*; | ||
|
||
public class GifBuilder { | ||
|
||
protected ImageWriter writer; | ||
protected ImageWriteParam params; | ||
protected IIOMetadata metadata; | ||
protected ImageOutputStream image; | ||
protected InputStream output; | ||
|
||
public GifBuilder(int imageType, int delay, boolean loop) throws IOException { | ||
writer = ImageIO.getImageWritersBySuffix("gif").next(); | ||
params = writer.getDefaultWriteParam(); | ||
|
||
ImageTypeSpecifier imageTypeSpecifier = ImageTypeSpecifier.createFromBufferedImageType(imageType); | ||
metadata = writer.getDefaultImageMetadata(imageTypeSpecifier, params); | ||
|
||
configureRootMetadata(delay, loop); | ||
|
||
ByteArrayOutputStream os = new ByteArrayOutputStream(); | ||
image = ImageIO.createImageOutputStream(os); | ||
writer.setOutput(image); | ||
writer.prepareWriteSequence(null); | ||
} | ||
|
||
public byte[] getBytes(ImageOutputStream ios) { | ||
ByteArrayOutputStream bos = new ByteArrayOutputStream(255); | ||
try { | ||
ios.seek(0); | ||
} catch (IOException e1) { | ||
e1.printStackTrace(); | ||
} | ||
|
||
while (true) { | ||
try { | ||
bos.write(ios.readByte()); | ||
} catch (EOFException e) { | ||
break; | ||
} catch (IOException e) { | ||
System.out.println("Error processing the Image Stream"); | ||
break; | ||
} | ||
} | ||
return bos.toByteArray(); | ||
} | ||
|
||
private void configureRootMetadata(int delay, boolean loop) throws IIOInvalidTreeException { | ||
String metaFormatName = metadata.getNativeMetadataFormatName(); | ||
IIOMetadataNode root = (IIOMetadataNode) metadata.getAsTree(metaFormatName); | ||
|
||
IIOMetadataNode graphicsControlExtensionNode = getNode(root, "GraphicControlExtension"); | ||
graphicsControlExtensionNode.setAttribute("disposalMethod", "none"); | ||
graphicsControlExtensionNode.setAttribute("userInputFlag", "FALSE"); | ||
graphicsControlExtensionNode.setAttribute("transparentColorFlag", "FALSE"); | ||
graphicsControlExtensionNode.setAttribute("delayTime", Integer.toString(delay / 10)); | ||
graphicsControlExtensionNode.setAttribute("transparentColorIndex", "0"); | ||
|
||
IIOMetadataNode appExtensionsNode = getNode(root, "ApplicationExtensions"); | ||
IIOMetadataNode child = new IIOMetadataNode("ApplicationExtension"); | ||
child.setAttribute("applicationID", "NETSCAPE"); | ||
child.setAttribute("authenticationCode", "2.0"); | ||
|
||
int loopContinuously = loop ? 0 : 1; | ||
child.setUserObject(new byte[]{ 0x1, (byte) (loopContinuously & 0xFF), (byte) (0)}); | ||
appExtensionsNode.appendChild(child); | ||
metadata.setFromTree(metaFormatName, root); | ||
} | ||
|
||
private static IIOMetadataNode getNode(IIOMetadataNode rootNode, String nodeName){ | ||
int nNodes = rootNode.getLength(); | ||
for (int i = 0; i < nNodes; i++){ | ||
if (rootNode.item(i).getNodeName().equalsIgnoreCase(nodeName)){ | ||
return (IIOMetadataNode) rootNode.item(i); | ||
} | ||
} | ||
IIOMetadataNode node = new IIOMetadataNode(nodeName); | ||
rootNode.appendChild(node); | ||
return(node); | ||
} | ||
|
||
public void writeToSequence(RenderedImage img) throws IOException { | ||
writer.writeToSequence(new IIOImage(img, null, metadata), params); | ||
} | ||
|
||
public InputStream getOutput(){ | ||
return output; | ||
} | ||
|
||
public void close() throws IOException { | ||
writer.endWriteSequence(); | ||
output = new ByteArrayInputStream(getBytes(image)); | ||
} | ||
} |
Oops, something went wrong.