Saturday, May 19, 2007

PC Gods Angry! PC Gods SMASH!

For the last few weeks, I've been contemplating a PC upgrade - there's been a recent RAM and CPU price drop, and there are a ton of games coming out that I'm dying to play, but that my current PC really isn't up to.

However, I couldn't really justify dropping that much cash, so I decided to buy an Xbox 360 instead. I picked it up on Friday, and had a blast the whole weekend smashing zombies in Dead Rising and playing various demos.

But, of course, I knew my defection would not go unnoticed by the supernatural powers that control the PC Gaming world. So I was not surprised when my wife's PC died on Sunday morning - I could tell by the crusty brown ooze that had leaked out of several capacitors that she was yet another victim of The Bad Cap Scandal.

So at that point, I had a choice - rebuild her PC for a couple of hundred bucks, or give her my PC and build myself a new one. I'm weak, so I decided to build a new PC!

She needed her PC by Tuesday morning, which pretty much eliminated any chance of shopping online, so I headed down to Fry's in Renton, wandered down the aisles filled with Fabulous Products (peppered with loss leaders which were invariably out of stock), weathered the gauntlet of belligerent East African salesmen who didn't actually know anything about the products they were trying to sell me, but were quite willing to say anything I wanted to hear to close the sale, and came home with a pile of merchandise that was invariably priced 20-30% over what I would have paid had I just ordered from NewEgg. Plus a shiny new copy of Vista Home Premium, Upgrade Edition (queue forboding music)

Now, for the fun part - building the PC! So, the first, easy step is to move my PC from my giant case to a smaller case that fits under the Darling Wife's desk. No problem! Um, except it no longer boots. So I reseated all the components, and...it crashes booting into Windows! Several hours later, after swapping components around, etc, I finally figure out that it's some kind of ESCD problem (whatever that is) and putting the components back exactly how they were lets me boot to desktop.

Whew.

Now to do a fresh install of Windows XP on the PC...except Windows XP doesn't support hard drives > 128Gb without SP2, which isn't part of my install disk. So I create a new install disk that includes SP2, and we're off to the races. One down, one to go.

I nervously unpacked all my components from Fry's, including the budget motherboard I picked up because It Was Just So Damned Cheap! put them all in my new PC, plugged everything in, turned on the PC and....everything works. It just boots right up, and starts chugging through the Vista install. Maybe the most painless PC build I've ever done, until...Vista asks me for my product key. No problem, I enter it, figuring it might ask me to insert my Win2K CD (since it's an upgrade CD) or maybe enter my Win2K product key.

Nope. It wants me to run the CD from within my Win2K installation, basically making the "upgrade" CD worthless if you are simultaneously upgrading the hardware (especially since it's incredibly unlikely that Win2K would support my new SATA drive, etc).

Once again, Google and Paul Thurrott came to my rescue - the trick is to install Vista without a product key (which puts it in a 30 day trial mode), then "upgrade" that Vista installation using my install DVD. Voila!

This may be the last home-build I do, though - life is just too damned short to spend hours building PCs anymore.

P.S. Oooh, almost forgot - I mostly play my 360 using headphones, and I got this fun little gadget to help me. It's a tiny, battery-powered amp from penguinamp.com, and it sounds great:


Sunday, May 06, 2007

The web is a fickle mistress

So I've been doing some extracurricular web development work lately, and I figured I'd share what I learned:

1) The internets are filled with lies!

I'd mocked up a site using Ruby on Rails as the backend, and I'd gotten some new assets from our graphic designer to use as menu rollovers. I decided to do a little research to see if there was anything built in to Rails or Scriptaculous to help automate this task, when I came across a "usability" message forum, containing gems like "Don't use images in place of text!" (sure, maybe when the Browser Gods give me more than 3 fonts to work with).

Anyhow, one of the posts on there said something along the lines of "I can't stand it when I see noobs still using Javascript to do their menu rollovers instead of CSS", and I thought "Well, I certainly don't want some random stranger on the internet to think I'm a noob! I'd better check this out!"

Anyhow, the idea as outlined in the forum was to setup your links with a forced width/height in the CSS, and set a background image on them. You can then use the a:hover or a:active CSS elements to specify a different background image when they are rolled over or clicked on.

Brilliant! ...except it doesn't quite work, because some browsers don't gracefully cache background images, so they get loaded from scratch when you rollover them. And even the ones that do cache background images still result in flickering when you rollover the item.

Anyhow, it turns out that there's a workaround that my random forum friend didn't know about - you basically combine all your rollovers into a single image, then use CSS to change the image offset to swap images when you want to display the rollover. It's darned clever, although in the end I think it would've been faster for me to just roll my own Javascript preloader/rollover handler than muck around with all the images.

Of course, when editing the images, I couldn't help but notice that there was some significant artifacting on them, which leads me to:

2) JPEG is a piss-poor format for images with text in them!

Yeah, yeah, I knew this already (it's for photographic images, people!), but that's the format the graphic designer gave them to us in. At first glance they looked acceptable, but the more I looked at them, the more I couldn't stand it. So I had her regenerate the images as PNG, only to discover:

3) PNG has problems also!

So this is probably old news to anyone who has worked with the Macintosh, but the Mac uses a different gamma function than the PC. This means that if you have an RGB value, it'll look lighter on the Mac than it does on the PC - it's built right into the video drivers.

The creators of the PNG format, in their infinite wisdom, thought "hey, this is bad - our images might look different on different systems!" so they decided to put gamma information directly into the PNG file so when viewed with a well-behaved application, the image would look identical on different systems.

Sounds great, huh?

Except the rest of the world (like HTML) doesn't come with customizable gamma functions. So when your PNG file contains gamma information that doesn't match the built-in gamma function for your system, then the colors in the PNG won't match the other colors in your web page, even though they have identical RGB values. This is bad, if you want the background color of your image to match the background-color CSS setting on your page, for example.

Turns out that Photoshop inserts this gamma information automatically, and there's no good way to keep it from doing this. The Mac version of Photoshop inserts gamma information that matches the Mac's gamma function - this means that everything looks perfect on the Mac (which is what most graphics professionals are going to use) but then looks off when viewed on a PC (which is what most web developers and the rest of the world use).

4) The internets will save you!

So of course a few minutes of searching on the internet yielded dozens of solutions, ranging from the inane ("don't use PNG!") to the obscure ("Go into this random File Info dialog in the latest version of Photoshop and delete this random chunk of file information!") to the pragmatic ("Use one of these free utilities to strip out the gamma info!"). I went for the pragmatic option - Ken Silverman (creator of the PNGOUT utility), I owe you a beer, man.