2006-06-15 16:03:30 |
Category: GoogleFood
|
Description: IE forces the .value of a TEXTAREA to be readonly if the textarea is named "keywords". You can therefore not change the value with Javascript.
Solution: Name it something besides "keywords" and it'll work.
This took me seems-like-forever to figure out. Grrr.
2006-06-15 16:00:03 |
Category: GoogleFood
|
If, when compiling gcc, it dies with the following error:
gcc: c-parse.c: No such file or directory
Here is the (wonderfully non-obvious) solution:
The problem is that gcc now either requires bison to compile (and conviniently doesn't tell you that,) or that for some reason, it chooses bison over yacc when you don't have bison.
2006-01-04 12:50:53 |
Category: GoogleFood
|
If you haven't guessed already, the category "GoogleFood" is just a place for me to put stuff and find it later, and make it easier to find using Google.
Anyways...
When you want to resize an image using Java Advanced Imaging (JAI), most tutorials on the web say to use JAI "resize" operator. Unfortunately, if you do that, your images will look like crap because it doesn't do any antialiaing. It doesn't matter what RenderHints you pass to it, it will always look bad. I tried applying low-pass filters both before and after the scaling, and it still looked bad.
The trick is to convert your RenderedImage to a BufferedImage and then use the .getScaledInstance() method on it. That will properly antialias the scaling.
Here's some code to convert from a RenderedImage to a BufferedImage...
public BufferedImage fromRenderedToBuffered(RenderedImage img) {
if (img instanceof BufferedImage) {
return (BufferedImage) img;
}
ColorModel cm = img.getColorModel();
int w = img.getWidth();
int h = img.getHeight();
WritableRaster raster = cm.createCompatibleWritableRaster(w,h);
boolean isAlphaPremultiplied = cm.isAlphaPremultiplied();
Hashtable props = new Hashtable();
String [] keys = img.getPropertyNames();
if (keys != null) {
for (int i = 0 ; i < keys.length ; i++) {
props.put(keys[i], img.getProperty(keys[i]));
}
}
BufferedImage ret = new BufferedImage(cm, raster,
isAlphaPremultiplied,
props);
img.copyData(raster);
return ret;
}
Thanks to "Thomas M." who posted this method as a comment on this web page.
2005-12-29 21:21:33 |
Category: General
|
"How do you bankrupt a monopoly and get named CEO of the year?"
-- WestJet CEO Clive Beddoe, on Air Canada CEO Robert Milton's selection as CEO of the year by Report on Business magazine.
2005-11-23 20:04:10 |
Category: General
|
As of now, I have about 4.5 Gb of text and images here on my website.
Sometimes I wonder... What brings people here?
As it turns out, many come from search engines like Google. And so, for no particular reason at all, here are the top 10 words that people have typed into search engines in the past year to find me: