Friday, December 22, 2006

What is wrong with computer scientists?

Today I spent pretty much all my time trying to get fricking Java to convert a 1D buffer of 8 bit colors (i.e. RGBRGBRGBRGBRGBRGBRGB...) into a viewable image. But no, Java has to abstract everything to death into Raster, DataBuffer, BufferedImage, ColorSpace, ColorModel, ComponentColorModel ... ad nauseum. There's been more or less no progress since I started. I still have a buffer in a perfectly valid format and it still isn't rendered.

Why can't it be as simple as this?

BufferedImage image = new BufferedImage(TYPE_BYTE, FORMAT_RGB, width, height, data);


Surely for a tool to be useful simple things should be simple and complex things should be possible. *sigh*

4 comments:

Squirk said...

You must be new here.

;-)

Robert Ancell said...

Last time I used Java it didn't seem that hard. Perhaps I'm too used to the Python library (though that could do with a rework to be really nice).

Don't even get me started on how hard the Independant JPEG group API was to link up to...

Anonymous said...

I fully agree, the Java Image classes are way too complex to use.

What I usually do is to create a BufferedImage, IIRC it has a setRGB() method that can be used to set a single pixel or a number of pixels.

Robert Ancell said...

Hi Anonymous!

Yeah I'd do that if it was a single image... unfortunately in this case it was a MJPEG (motion JPEG) stream on relatively slow iMac so we needed a fast decoder. Much easier in Python :)