|
|
Saturday, September 20, 2003 |
Technical Notes.Trackback is now enabled (I think) for this Radio Userland -powered blog. I've been playing a bit with Movable Type and may switch, but for now...we'll proceed with this. The pictures in the previous entry might look a little better if you expand your browser window. I wrote a quick Java program to read in my 1MB+ source images (from my Canon S50 camera)...It uses the 1.4 SE imaging API. I've done a lot of image work in the past, and I don't mind telling you that the imaging API is, on the face of it, pretty crappy. You simply have to do too much work to do some simple things, and there are way too many formats and options on most of the classes. Some of it is infrastructure that's dedicated to handling asynchronous image work and I understand the complexities of it are necessary, but for God's sake, provide simple ways to do the simple things. Resizing an image turns out to be a pain in the ass. You can easily load your image in with ImageIO, which provides you with a BufferedImage. BufferedImage inherits a getScaled-type call, which looks like exactly what you need, until you realize that it returns an Image. If you check the class of the image, it's some weird AWT thing. In order to use ImageIO's writing, you need a RenderedImage (of which BufferedImage is one). So how do you get there? The answer is, you can't. What I ended up doing is creating a new BufferedImage, getting a Graphics2D from it, then rendering the source image onto the target. I set the rendering hints, but frankly the image quality absolutely sucks. I'll need to go back and tack on the interpolation hint directly and see if that makes a difference. The main reason I ended up writing a little program to do this is that the batch resizing program I have (Adobe Photoshop Elements) is just plumb stupid about portrait vs. landscape images. There's no way to convince it to do the right thing. 2:53:42 PM |
The Flood.My building was surrounded by the flood in Old Town Alexandria...check it out! I got lucky and had power the whole time; people in surrounding neighborhoods didn't. Note the kayak; I was ready, baby.
2:36:27 PM |
blog at soletta dot com