jbanes
|
 |
«
Posted
2006-02-14 17:18:58 » |
|
Next time you need to explain to someone just how small 4 kilobytes really is, put it this way: 360 games can fit on a single floppy disk.That's enough to include every 4K game produced in the last 4 years of competition, and still have nearly half the space left over. If floppy drives were still popular, I'd be tempted to produce a "Java 4K Contest Special Edition Floppy" just to drive the point home. So remember, guys. The stuff we're doing here really is incredible. 
|
|
|
|
jojoh
|
 |
«
Reply #1 - Posted
2006-02-14 17:26:28 » |
|
368 games can fit on a single floppy disk.
...or roughly 175 000 on a single CD 
|
|
|
|
Anon666
Junior Devvie  
aka Abuse/AbU5e/TehJumpingJawa
|
 |
«
Reply #2 - Posted
2006-02-14 17:49:53 » |
|
yeah, put all the games on one floppy........ and the JRE on the other 12 =)
|
|
|
|
Games published by our own members! Check 'em out!
|
|
Rick
Junior Devvie   Projects: 1
Java games rock!
|
 |
«
Reply #3 - Posted
2006-02-14 18:56:09 » |
|
It's the size of a 64X64 pixel image.
|
|
|
|
kevglass
|
 |
«
Reply #4 - Posted
2006-02-14 18:59:08 » |
|
Oooo.. images from 4k jars.. good idea.. I wonder who has the coolest looking jar converted to an image ?  Kev
|
|
|
|
cborders
|
 |
«
Reply #5 - Posted
2006-02-14 19:03:09 » |
|
I would LOVE to see these!! 
|
|
|
|
jbanes
|
 |
«
Reply #6 - Posted
2006-02-14 19:28:19 » |
|
Your wish is my command: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
| import java.awt.*; import java.awt.image.*; import java.io.*;
import javax.imageio.*;
public class ImageMaker4K { public static void main(String[] args) throws Exception { int[] buffer = new int[4096]; BufferedImage image; FileInputStream in; int data; int index;
if(args.length < 2) { System.out.println("Usage: java 4kImageMaker <input> <output>.png"); return; }
in = new FileInputStream(args[0]); index = 0;
while((data = in.read()) >= 0 && index < buffer.length) { buffer[index] = (data << 16) | (data << 8) | data; index++; }
image = new BufferedImage(64, 64, BufferedImage.TYPE_INT_RGB); image.setRGB(0, 0, 64, 64, buffer, 0, 64); ImageIO.write(image, "PNG", new File(args[1]+".png")); } } |
I love Java.  See the attachments for a few examples. (Sorry if your favorite game is missing, but a LOT of people need to fix or remove their JAR links.)
|
|
|
|
cborders
|
 |
«
Reply #7 - Posted
2006-02-14 19:34:45 » |
|
HAHA very cool!
|
|
|
|
kevglass
|
 |
«
Reply #8 - Posted
2006-02-14 19:37:23 » |
|
Daftest - tool - ever. Kev PS. Way cool 
|
|
|
|
jbanes
|
 |
«
Reply #9 - Posted
2006-02-14 19:41:46 » |
|
What's interesting is that you can see massive amounts of wasted space in Warpstar4K, and reasonably good sized chunks of wasted space in W4K. You see that white wave in Xero? That means that the data is nearly all binary 1's. I'm guessing that this area could be slightly better compressed, but there is some variation in the white, which would make it more difficult for the compressor. BTW, if you want black to represent data and white to represent the lack of data, change the loop to this: 1 2 3
| data = 0xFF - data; buffer[index] = (data << 16) | (data << 8) | data; index++; |
|
|
|
|
Games published by our own members! Check 'em out!
|
|
oNyx
|
 |
«
Reply #10 - Posted
2006-02-14 20:00:19 » |
|
Same in argb  1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
| import java.awt.*; import java.awt.image.*; import javax.imageio.*; import java.io.*; public class Gen4kImage{ public static void main(String[]args)throws IOException{ byte []a=new byte[4096]; File file=new File(args[0]); DataInputStream in=new DataInputStream(new FileInputStream(file)); int read=0; do{ int got=in.read(a,read,(int)file.length()-read); read+=got; if(got==-1){ System.out.println("meh"); return; } }while(read<file.length()); in.close(); System.out.println(read); int []ab=new int[1024]; DataInputStream in2=new DataInputStream(new ByteArrayInputStream(a)); for(int i=0;i<1024;i++) ab[i]=in2.readInt(); BufferedImage i=new BufferedImage(32,32,BufferedImage.TYPE_INT_ARGB); i.setRGB(0,0,32,32,ab,0,32); ImageIO.write(i,"png",new File("out.png")); } } |
fuzetsu in technicolor: 
|
|
|
|
jbanes
|
 |
«
Reply #11 - Posted
2006-02-14 20:05:21 » |
|
Will you look at that? Here I was just about to post my wonderful color version, and oNyx beats me to it! Oh well, mine's better anyway.  1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
| import java.awt.*; import java.awt.image.*; import java.io.*;
import javax.imageio.*;
public class ImageMaker4K { public static void main(String[] args) throws Exception { int[] buffer = new int[4096]; BufferedImage image; FileInputStream in; int data; int index;
if(args.length < 2) { System.out.println("Usage: java 4kImageMaker <input> <output>.png"); return; }
in = new FileInputStream(args[0]); index = 0;
while((data = in.read()) >= 0 && index < buffer.length) { int Y = ((data & 0xE0) >> 6); int U = ((data & 0x1C) >> 3); int V = (data & 0x03);
double R = Math.abs(Y + 1.403 * V); double G = Math.abs(Y - 0.344 * U - 0.714 * V); double B = Math.abs(Y + 1.770 * U);
buffer[index] = ((int)(R * 255) << 16) | ((int)(G * 255) << 8) | (int)(B * 255); index++; }
image = new BufferedImage(64, 64, BufferedImage.TYPE_INT_RGB); image.setRGB(0, 0, 64, 64, buffer, 0, 64); ImageIO.write(image, "PNG", new File(args[1]+".png")); } } |
This version works by treating each 8 bit value as a YUV color. While I'm not so sure about my YUV to RGB color conversion, it does produce a 64x64 image that can easily be palletized. It also retains much of the analytical ability of the previous version, allowing you to see "dead spots" in your code. See attachments for some examples.
|
|
|
|
jbanes
|
 |
«
Reply #12 - Posted
2006-02-14 20:14:35 » |
|
Speaking of analytical abilities, BTW, the new version makes several things more clear: 1. There is a lot more space in Warpstar4K, and bit more space in both Xero and W4K. 2. The previously visible white area in Xero is obviously more varied than previously visible. 3. Colors are prrreeeeeettty.  I have a theory about that space at the end, though. I'm thinking that may be the ZIP file metadata about where the files are in the archive. Since it doesn't have to store much (a directory and two files), it's probably got large amounts of empty space. Just a theory, anyway. I'd need to break out a hex editor to be sure. 
|
|
|
|
Anon666
Junior Devvie  
aka Abuse/AbU5e/TehJumpingJawa
|
 |
«
Reply #13 - Posted
2006-02-14 20:39:43 » |
|
Speaking of analytical abilities, BTW, the new version makes several things more clear: 1. There is a lot more space in Warpstar4K, and bit more space in both Xero and W4K. 2. The previously visible white area in Xero is obviously more varied than previously visible. 3. Colors are prrreeeeeettty.  I have a theory about that space at the end, though. I'm thinking that may be the ZIP file metadata about where the files are in the archive. Since it doesn't have to store much (a directory and two files), it's probably got large amounts of empty space. Just a theory, anyway. I'd need to break out a hex editor to be sure.  If that were the case, wouldn't there be similar gaps in everyones jars? Afterall pretty much everyone has the same number of files, and file names.
|
|
|
|
jbanes
|
 |
«
Reply #14 - Posted
2006-02-14 20:50:34 » |
|
If that were the case, wouldn't there be similar gaps in everyones jars? Afterall pretty much everyone has the same number of files, and file names. That would be correct. So far, this seems to be holding true. (A few more game images are attached.)
|
|
|
|
Anon666
Junior Devvie  
aka Abuse/AbU5e/TehJumpingJawa
|
 |
«
Reply #15 - Posted
2006-02-14 21:13:10 » |
|
So, who is going to write a 64x64 image -> jar file converter =) A Visual Editor of sorts 
|
|
|
|
swpalmer
|
 |
«
Reply #16 - Posted
2006-02-14 21:41:49 » |
|
Yeah, what we need is something to go back from the image to the game.. Then we can trade bitmaps 
|
|
|
|
woogley
|
 |
«
Reply #17 - Posted
2006-02-14 21:53:22 » |
|
that would be insanely cool! you could technically compress the games further with pngout etc 
|
|
|
|
kaffiene
|
 |
«
Reply #18 - Posted
2006-02-14 22:20:03 » |
|
That is insanely geeky.
Well done!
|
|
|
|
Morre
|
 |
«
Reply #19 - Posted
2006-02-14 22:24:54 » |
|
This is fantastic! Awesome indeed!  Posting Icejump4k and FreefallFour4k. EDIT: Also, I too would love it if you could create a tool that'd reverse the process. Color wouldn't be neccessary, just b&w  Not necessarily one that works with recompressed images using visual editors, just one that could re-jar the original from-jar image. EDIT2: I took the liberty of creating an anti-jar (going backwards?), ehm, I mean, inverted image. Also, for your pleasure... a fake!
|
|
|
|
jbanes
|
 |
«
Reply #20 - Posted
2006-02-14 22:42:40 » |
|
You guys do understand that modifying the image is pointless, right? It's just a visual representation of a ZIP data stream. Any attempts to modify it would corrupt the JAR file, guaranteed.
Creating a program to reverse the process would work for the black and white images. (Not that I can figure out anything useful for it.) However, the conversion between RGB and YUV is fraught with rounding errors and would probably screw up the data.
|
|
|
|
kappa
|
 |
«
Reply #21 - Posted
2006-02-14 23:48:28 » |
|
wow this is amazing now i can look at the 4k games in a totally different way  making a height map out of them would also be cool, as in 3d terrain hint* please someone do that  *hint
|
|
|
|
swpalmer
|
 |
«
Reply #22 - Posted
2006-02-15 01:36:40 » |
|
Creating a program to reverse the process would work for the black and white images. (Not that I can figure out anything useful for it.) However, the conversion between RGB and YUV is fraught with rounding errors and would probably screw up the data.
I don't think any colour space conversion applies in this case. PNG is a lossless format and it typically uses RGB.
|
|
|
|
Anon666
Junior Devvie  
aka Abuse/AbU5e/TehJumpingJawa
|
 |
«
Reply #23 - Posted
2006-02-15 02:10:07 » |
|
I believe jbanes is refering to his own code for generating the colorized versions. 1 2 3 4 5 6 7
| int Y = ((data & 0xE0) >> 6); int U = ((data & 0x1C) >> 3); int V = (data & 0x03);
double R = Math.abs(Y + 1.403 * V); double G = Math.abs(Y - 0.344 * U - 0.714 * V); double B = Math.abs(Y + 1.770 * U); |
There is certainly rounding error in there =)
|
|
|
|
Morre
|
 |
«
Reply #24 - Posted
2006-02-15 09:20:20 » |
|
I do know that it is pointless, and I realized it'd work better with b&w, that's why I suggested using those. I just tnink it'd be interesting to see, letting you convert to images and back (here's my java source, encrypted. Decompile this: (sending png)). :>
|
|
|
|
oNyx
|
 |
«
Reply #25 - Posted
2006-02-15 10:24:52 » |
|
>and I realized it'd work better with b&w
My ARGB version is just fine. Each pixel contains 4 bytes of information and its lossless. You can also embedd some meta information in png files. So, you could write some loader which hooks such a png into the classpath and runs the main class specified in the tEXT chunk.
|
|
|
|
DonaldEKnuth
|
 |
«
Reply #26 - Posted
2006-02-15 12:35:24 » |
|
Nice to see my entry (Sokoban4k) used for something! ;-) And this is a crazy idea! :-)
|
|
|
|
jbanes
|
 |
«
Reply #27 - Posted
2006-02-15 19:31:03 » |
|
I do know that it is pointless, and I realized it'd work better with b&w, that's why I suggested using those. I just tnink it'd be interesting to see, letting you convert to images and back (here's my java source, encrypted. Decompile this: (sending png)). :> There had better be some serious geek cred in this. Here you go: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70
| import java.awt.*; import java.awt.image.*; import java.io.*; import java.lang.reflect.*; import java.net.*; import java.util.jar.*; import java.util.zip.*;
import javax.imageio.*;
public class ImageRunner4K { public static void main(String[] args) throws Exception { int[] buffer = new int[4096]; byte[] array = new byte[4096];
BufferedImage image; ZipInputStream jarin; ZipOutputStream jarout; ZipEntry entry;
int data; int index;
if(args.length < 1) { System.out.println("Usage: java ImageRunner4K <input>\n\nDo not pass the PNG extension."); return; }
image = ImageIO.read(new File(args[0]+".png")); image.getRGB(0, 0, 64, 64, buffer, 0, 64);
for(int i=0; i<buffer.length; i++) array[i] |= (buffer[i] & 0xFF);
jarin = new ZipInputStream(new ByteArrayInputStream(array)); jarout = new ZipOutputStream(new FileOutputStream(args[0]+".jar"));
while(jarin.available() > 0) { index = 0; entry = jarin.getNextEntry();
if(entry == null) break;
array = new byte[(int)entry.getSize()];
while(index < array.length) index += jarin.read(array, index, array.length-index);
jarout.putNextEntry(new ZipEntry(entry.getName())); jarout.write(array, 0, array.length); jarout.closeEntry(); }
jarout.close(); jarin.close();
URLClassLoader loader = new URLClassLoader(new URL[]{new File(args[0]+".jar").toURL()}); Manifest manifest = new Manifest(loader.findResource("META-INF/MANIFEST.MF").openStream()); Attributes attributes = manifest.getMainAttributes(); String className = attributes.getValue("Main-Class");
Class gameClass = loader.loadClass(className); Method method = gameClass.getMethod("main", new Class[]{String[].class});
method.invoke(null, new Object[]{new String[0]}); } } |
It only works on the Grayscale images. You use it by running "java ImageRunner4K <name>" where " name" is the name of the PNG file without the extension. Don't run this in the same directory where you have your master JAR files or you may be in for a nasty surprise. Edit: There are test files you can use in this post.
|
|
|
|
cborders
|
 |
«
Reply #28 - Posted
2006-02-15 20:03:29 » |
|
I'm not worthy! You are awesome!!
|
|
|
|
Morre
|
 |
«
Reply #29 - Posted
2006-02-15 20:34:25 » |
|
Awesome. You have all the cred you want  EDIT: Can't get it to work though. Crashes with: 1 2
| Exception in thread "main" java.lang.NegativeArraySizeException at ImageRunner4K.main(ImageRunner4K.java:48) |
|
|
|
|
|