OpenGL needs a direct ByteBuffer though, so you'll have to copy the byte[]. I do like accessing the byte[] your way better than row by row. I've updated my test, but it didn't make ImageIO faster:
http://n4te.com/temp/Test.javaWith the new decoder, it fails to decode your Ken fireball pic and also
my test image (bent over next to a plant stake!). I tried it on a
third pic (only click if you want to see me drinking frozen lemonade with my nipple

) and it worked. This image is 1280x960. I found it took 211ms to parse. With SWT's decoder it is parsed in 81ms, with ImageIO 85ms to 140ms. Here is my test for the new decoder:
http://n4te.com/temp/Test2.javaHPROF:
1 2 3
| 1 64.90% 64.90% 1407 300051 JPEGDecoder2.ScaleIDCT 2 17.76% 82.66% 385 300053 JPEGDecoder2.output 3 8.63% 91.28% 187 300052 JPEGDecoder2.output |
I think the IDCT is not as advanced as SWT's, which seems to do some checks and shortcut if possible. I probably won't pursue the new decoder further since it seem to be slower and has an unfriendly license. I am impressed with its conciseness though!
I tried Sun's decoder. I can get it to decode once, but the second time around it fails. This makes little sense to me! Here is the test:
http://n4te.com/temp/Test3.java