Image Shadow Adder

2006-06-27 00:28:00 -08:00

My newest application, Image Shadow Adder, adds a shadow to an image. I plan on using this instead of Photoshop to restore shadows to my window screenshots (OS X’s window screenshot command, ⇪⇧⌘4, does not preserve the shadow).

Also, the source code (BSD license) demonstrates how to use Bindings (used to insert the original and shadowed images into the document window’s image views), use NSShadow, and capture an NSImage to an NSBitmapImageRep. Few comments in the code, I’m sorry to say, as this is just a quick-and-dirty application that I wrote when it dawned on me that I could use NSShadow when drawing an NSImage, rather than emulating my old Photoshop technique.

For reference, that technique was:

  1. Take one regular window screenshot, and one rectangular screenshot of the window with shadow on a white background.
  2. Drag and drop the window screenshot into the rectangular screenshot. Position so that the two window images line up.
  3. Knock out the black corners on the window screenshot. These are masked out by the alpha channel in the PNG file, but Photoshop sucks at alpha channels.
  4. Create a new layer. Fill with black.
  5. Load the window screenshot as a selection.
  6. Add a layer mask (reveal selection) to the black layer.
  7. Copy Merged.
  8. Add an alpha channel. Paste into it, and invert it. The area of the window should be white, with the shadow fading to black.
  9. Return to the Layers list and disable or delete the layer mask. Move the black layer down beneath the window-screenshot layer.
  10. Export using SuperPNG.

The only disadvantage to the new way is that AppKit’s PNG-interlacing setting is broken. The generated PNG data is not interlaced. I’ll have to use OptiPNG to interlace it.

Technorati tags: , .

Leave a Reply

Do not delete the second sentence.