You can subscribe to this list here.
| 2002 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
(134) |
Sep
(52) |
Oct
(13) |
Nov
(342) |
Dec
(163) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2003 |
Jan
(44) |
Feb
(62) |
Mar
(158) |
Apr
(38) |
May
(70) |
Jun
(58) |
Jul
(104) |
Aug
(207) |
Sep
(83) |
Oct
(122) |
Nov
(23) |
Dec
(49) |
| 2004 |
Jan
(119) |
Feb
(132) |
Mar
(192) |
Apr
(140) |
May
(77) |
Jun
(74) |
Jul
(201) |
Aug
(63) |
Sep
(102) |
Oct
(70) |
Nov
(173) |
Dec
(78) |
| 2005 |
Jan
(174) |
Feb
(197) |
Mar
(105) |
Apr
(59) |
May
(77) |
Jun
(43) |
Jul
(21) |
Aug
(18) |
Sep
(47) |
Oct
(37) |
Nov
(74) |
Dec
(50) |
| 2006 |
Jan
(44) |
Feb
(19) |
Mar
(32) |
Apr
(24) |
May
(31) |
Jun
(55) |
Jul
(138) |
Aug
(28) |
Sep
(12) |
Oct
(41) |
Nov
(58) |
Dec
(24) |
| 2007 |
Jan
(28) |
Feb
(14) |
Mar
(10) |
Apr
(68) |
May
(30) |
Jun
(26) |
Jul
(18) |
Aug
(63) |
Sep
(19) |
Oct
(29) |
Nov
(20) |
Dec
(10) |
| 2008 |
Jan
(38) |
Feb
(7) |
Mar
(37) |
Apr
(120) |
May
(41) |
Jun
(36) |
Jul
(39) |
Aug
(24) |
Sep
(28) |
Oct
(30) |
Nov
(36) |
Dec
(75) |
| 2009 |
Jan
(46) |
Feb
(22) |
Mar
(50) |
Apr
(70) |
May
(134) |
Jun
(105) |
Jul
(75) |
Aug
(34) |
Sep
(38) |
Oct
(34) |
Nov
(19) |
Dec
(20) |
| 2010 |
Jan
(11) |
Feb
(20) |
Mar
(65) |
Apr
(83) |
May
(104) |
Jun
(73) |
Jul
(78) |
Aug
(57) |
Sep
(43) |
Oct
(35) |
Nov
(9) |
Dec
(4) |
| 2011 |
Jan
(21) |
Feb
(11) |
Mar
(18) |
Apr
(10) |
May
(18) |
Jun
(15) |
Jul
(48) |
Aug
(25) |
Sep
(17) |
Oct
(45) |
Nov
(15) |
Dec
(12) |
| 2012 |
Jan
(21) |
Feb
(9) |
Mar
(12) |
Apr
(9) |
May
(9) |
Jun
(5) |
Jul
(1) |
Aug
(10) |
Sep
(12) |
Oct
(1) |
Nov
(28) |
Dec
(5) |
| 2013 |
Jan
(4) |
Feb
(1) |
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| 2014 |
Jan
|
Feb
(1) |
Mar
(1) |
Apr
|
May
(2) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(1) |
Nov
|
Dec
|
| 2015 |
Jan
(1) |
Feb
|
Mar
|
Apr
|
May
|
Jun
(1) |
Jul
|
Aug
|
Sep
|
Oct
(2) |
Nov
|
Dec
|
| 2016 |
Jan
(2) |
Feb
(1) |
Mar
(1) |
Apr
(1) |
May
(2) |
Jun
|
Jul
(1) |
Aug
(2) |
Sep
|
Oct
|
Nov
(1) |
Dec
|
| 2017 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
(1) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| S | M | T | W | T | F | S |
|---|---|---|---|---|---|---|
|
|
|
|
1
|
2
|
3
|
4
|
|
5
|
6
|
7
|
8
(2) |
9
|
10
(1) |
11
|
|
12
|
13
|
14
|
15
|
16
|
17
|
18
|
|
19
|
20
|
21
|
22
|
23
(25) |
24
|
25
|
|
26
|
27
|
28
(1) |
29
|
30
(3) |
31
|
|
|
From: Brian M. <ma...@us...> - 2006-03-10 18:49:41
|
Update of /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/util In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30204/src/java/org/lwjgl/util Modified Files: XPMFile.java Log Message: new, improved and shiny version, courtesy of Jos Hirth Index: XPMFile.java =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/util/XPMFile.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- XPMFile.java 18 Aug 2005 13:55:10 -0000 1.3 +++ XPMFile.java 10 Mar 2006 18:49:34 -0000 1.4 @@ -1,12 +1,13 @@ package org.lwjgl.util; + import java.io.BufferedOutputStream; -import java.io.BufferedReader; import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; +import java.io.LineNumberReader; import java.util.HashMap; import java.util.StringTokenizer; @@ -15,169 +16,209 @@ * <p> * NOTE: This simple XPM reader does not support extensions nor hotspots * </p> + * * @author Brian Matzon <br...@ma...> + * @author Jos Hirth * @version $Revision$ */ public class XPMFile { /** Array of bytes (RGBA) */ - private byte bytes[] = null; + private byte bytes[] = null; - /** Height of image */ - private int height = 0; + private final static int WIDTH = 0; - /** Width of image */ - private int width = 0; + private final static int HEIGHT = 1; - /* - * Private constructor, use load(String filename) + private final static int NUMBER_OF_COLORS = 2; + + private final static int CHARACTERS_PER_PIXEL = 3; + + private static int[] format = new int[4]; + + /* + * Private constructor, use load(String filename) */ - private XPMFile() { } - + private XPMFile() { + } + /** - * Loads the XPM file + * Loads the XPM file * - * @param file path to file - * @return XPMFile loaded, or exception - * @throws IOException If any IO exceptions occurs while reading file + * @param file + * path to file + * @return XPMFile loaded, or exception + * @throws IOException + * If any IO exceptions occurs while reading file */ public static XPMFile load(String file) throws IOException { return load(new FileInputStream(new File(file))); } - + /** - * Loads the XPM file + * Loads the XPM file * - * @param is InputStream to read file from - * @return XPMFile loaded, or exception - * @throws IOException If any IO exceptions occurs while reading file + * @param is + * InputStream to read file from + * @return XPMFile loaded, or exception + * @throws IOException + * If any IO exceptions occurs while reading file */ public static XPMFile load(InputStream is) throws IOException { XPMFile xFile = new XPMFile(); xFile.readImage(is); return xFile; - } + } - /** - * @return the height of the image. + /** + * @return the height of the image. */ public int getHeight() { - return height; + return format[HEIGHT]; } - /** - * @return the width of the image. + /** + * @return the width of the image. */ public int getWidth() { - return width; + return format[WIDTH]; } - /** - * @return The data of the image. + /** + * @return The data of the image. */ public byte[] getBytes() { return bytes; } - /** - * Read the image from the specified file. + /** + * Read the image from the specified file. * - * @throws IOException If any IO exceptions occurs while reading file + * @throws IOException + * If any IO exceptions occurs while reading file */ private void readImage(InputStream is) throws IOException { try { - BufferedReader br = new BufferedReader(new InputStreamReader(is)); + LineNumberReader reader = new LineNumberReader( + new InputStreamReader(is)); HashMap colors = new HashMap(); - - String comment = br.readLine(); - String typedef = br.readLine(); - int[] format = parseFormat(br.readLine()); - + + format = parseFormat(nextLineOfInterest(reader)); + // setup color mapping - for (int i = 0; i < format[2]; i++) { - Object[] colorDefinition = parseColor(br.readLine()); + for (int i = 0; i < format[NUMBER_OF_COLORS]; i++) { + Object[] colorDefinition = parseColor(nextLineOfInterest(reader)); colors.put(colorDefinition[0], colorDefinition[1]); } - + // read actual image (convert to RGBA) - bytes = new byte[format[0] * format[1] * 4]; - for (int i = 0; i < format[1]; i++) { - parseImageLine(br.readLine(), format, colors, i); + bytes = new byte[format[WIDTH] * format[HEIGHT] * 4]; + for (int i = 0; i < format[HEIGHT]; i++) { + parseImageLine(nextLineOfInterest(reader), format, colors, i); } } catch (Exception e) { + e.printStackTrace(); throw new IllegalArgumentException("Unable to parse XPM File"); } } /** + * Finds the next interesting line of text. + * + * @param reader + * The LineNumberReader to read from + * @return The next interesting String (with stripped quotes) + * @throws IOException + * If any IO exceptions occurs while reading file + */ + private String nextLineOfInterest(LineNumberReader reader) + throws IOException { + String ret; + do { + ret = reader.readLine(); + } while (!ret.startsWith("\"")); + // lacks sanity check + return ret.substring(1, ret.lastIndexOf('\"')); + } + + /** * Parses the format of the xpm file given a format string - * - * @param format String to parse + * + * @param format + * String to parse * @return Array specifying width, height, colors, characters per pixel */ private int[] parseFormat(String format) { - // format should look like this: - // "16 16 122 2", - - // nuke first and last " and last , - format = format.substring(1, format.length() - 2); + // 16 16 122 2 // tokenize it StringTokenizer st = new StringTokenizer(format); - return new int[] { - Integer.parseInt(st.nextToken()), /* width */ - Integer.parseInt(st.nextToken()), /* height */ - Integer.parseInt(st.nextToken()), /* colors */ - Integer.parseInt(st.nextToken()) /* chars per pixel */ + return new int[] { Integer.parseInt(st.nextToken()), /* width */ + Integer.parseInt(st.nextToken()), /* height */ + Integer.parseInt(st.nextToken()), /* colors */ + Integer.parseInt(st.nextToken()) /* chars per pixel */ }; } /** * Given a line defining a color/pixel, parses this into an array containing * a key and a color - * @param line Line to parse + * + * @param line + * Line to parse * @return Array containing a key (String) and a color (Integer) */ private Object[] parseColor(String line) { - // line should look like this - // "# c #0A0A0A", - - // nuke first and last " - line = line.substring(1, line.length() - 2); + // line should look like this: + // # c #0A0A0A - String key = line.substring(0, 2); - String type = line.substring(3, 4); - String color = line.substring(6); + // NOTE: will break if the color is something like "black" or "gray50" + // etc (instead of #rrggbb). + + String key = line.substring(0, format[CHARACTERS_PER_PIXEL]); + // since we always assume color as type we dont need to read it + // String type = line.substring(format[CHARACTERS_PER_PIXEL] + 1, + // format[CHARACTERS_PER_PIXEL] + 2); + String color = line.substring(format[CHARACTERS_PER_PIXEL] + 4); // we always assume type is color, and supplied as #<r><g><b> - return new Object[] { key, new Integer(Integer.parseInt(color, 16))}; + return new Object[] { key, new Integer(Integer.parseInt(color, 16)) }; } /** * Parses an Image line into its byte values - * @param line Line of chars to parse - * @param format Format to expext it in - * @param colors Colors to lookup - * @param index current index into lines, we've reached + * + * @param line + * Line of chars to parse + * @param format + * Format to expext it in + * @param colors + * Colors to lookup + * @param index + * current index into lines, we've reached */ - private void parseImageLine(String line, int[] format, HashMap colors, int index) { + private void parseImageLine(String line, int[] format, HashMap colors, + int index) { // offset for next line - int offset = index * 4 * format[0]; - - // nuke first " - line = line.substring(1, line.length()); + int offset = index * 4 * format[WIDTH]; - // read format[3] characters format[0] times, each iteration is one color - for (int i = 0; i < format[0]; i++) { - String key = line.substring(i * 2, (i * 2 + 2)); + // read <format[CHARACTERS_PER_PIXEL]> characters <format[WIDTH]> times, + // each iteration equals one pixel + for (int i = 0; i < format[WIDTH]; i++) { + String key = line + .substring( + i * format[CHARACTERS_PER_PIXEL], + (i * format[CHARACTERS_PER_PIXEL] + format[CHARACTERS_PER_PIXEL])); Integer color = (Integer) colors.get(key); - bytes[offset + (i * 4) ] = (byte) ((color.intValue() & 0x00ff0000) >> 16); - bytes[offset + ((i * 4) + 1)] = (byte) ((color.intValue() & 0x0000ff00) >> 8); - bytes[offset + ((i * 4) + 2)] = (byte) ((color.intValue() & 0x000000ff) >> 0); // looks better :) - bytes[offset + ((i * 4) + 3)] = (byte) 0xff; // always 0xff alpha + bytes[offset + (i * 4)] = (byte) ((color.intValue() & 0x00ff0000) >> 16); + bytes[offset + ((i * 4) + 1)] = (byte) ((color.intValue() & 0x0000ff00) >> 8); + bytes[offset + ((i * 4) + 2)] = (byte) ((color.intValue() & 0x000000ff) >> 0); // looks + // better + // :) + bytes[offset + ((i * 4) + 3)] = (byte) 0xff; // always 0xff alpha } } @@ -192,16 +233,16 @@ try { String out = args[0].substring(0, args[0].indexOf(".")) + ".raw"; XPMFile file = XPMFile.load(args[0]); - BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(new File(out))); + BufferedOutputStream bos = new BufferedOutputStream( + new FileOutputStream(new File(out))); bos.write(file.getBytes()); bos.close(); - //showResult(file.getBytes()); + // showResult(file.getBytes()); } catch (Exception e) { e.printStackTrace(); } } - /* private static void showResult(byte[] bytes) { final BufferedImage i = new BufferedImage(16, 16, BufferedImage.TYPE_INT_ARGB); @@ -232,4 +273,4 @@ frame.setSize(100, 100); frame.setVisible(true); }*/ -} +} \ No newline at end of file |