Posterizing Images

A message on a Flash list posed the question of whether there was any way to dynamically generate a posterized version of a bitmap image in Director. My response: “Nothing could be simpler.”

The following movie script takes an image object and applies the built-in Web 216 palette to the picture without dithering, which results in a fair amount of posterization. Using a more restricted palette would result in more dramatic effects.

on posterize imageRef
  memberRef = new (#bitmap)
  posterizedImage = image (imageRef.rect.width, imageRef.rect.height, 8, #web216)
  posterizedImage.copyPixels (imageRef, imageRef.rect, imageRef.rect)
  memberRef.image = posterizedImage
end

You can see the results of this script here (click to open up a larger version):

To execute the script, if you’ve got a bitmap image in cast member position 1, you just type “posterize member (1).image” in the Message window.

The first command creates a new cast member for the posterized bitmap.

The second command assigns an image object to a variable, using the size of the original image, setting the color depth of the posterized image, and specifying a palette to use.

The third command copies the original image into the image object.

Finally, the image object is assigned to the image property of the new member.

To make the third version of the original image in the JPG, I just substituted a 4 for the 8 in the third parameter of the image function, to make it 16-color instead of 256-color. For more control over the colors of the posterization, you can create a custom palette and substitute its member reference for the fourth parameter. There are all other sorts of effects you can do automatically using copyPixels, including things like inverting the brightness of the colors. If you’re not in a hurry, it’s certainly possible to do a pixel-by-pixel processing of the image.

You can download the source file (compatible with Director 8.5 and later) here.

More Director Guys in the Media

In those hazy days back before the Web, the name Marvyn Hortman rose high in the Director community. Marvyn set up an FTP site where developers could post tutorials, samples, and information in an era (only a decade ago) when getting up-to-date material wasn’t exactly easy.

Late last Saturday night, Marvyn and his neighbor came home late and just missed running into a bank robber who’ been featured that night on America’s Most Wanted. The fugitive, Terence Washington, stole the neighbor’s Hummer and headed off into the night.

Marvyn reports that a camera crew from AMW was due to interview him and his neighbor Friday, and it should air as a lead story on Saturday, March 20.

Director/Shockwave/Flash Game Developers at GDC

Haven’t determined whether I’m going to make it this year, but if you’re attending the Game Developers Conference 2004 — or if you’re just in the San Jose area on March 26 — Brian Robbins announced the meeting time and place for the annual gathering of Director/Shockwave and Flash game developers.

Most of the show’s oriented toward the big-time console and computer-based markets, but a number of folks from our community, including Brian and Gray Rosenzweig, regularly present at the conference (see my article at DOUG on last year’s dinner).

Brian says to meet up from 4-5PM, Friday, March 26 at the IGDA booth outside the main entrance to the Expo hall at the San Jose Convention Center (you don’t need a pass to get that far). It’s a great way to meet people who love to play and develop (and sell) games!

Lingo PDF Generators

Years ago, I thought I was pretty cool for knowing enough about PostScript to be able to write a tool to import simple EPS and PostScript files into Director as vector shape data (PS2VS).

Now that I’m old and all of my creativity has dried up, I can only look admiringly on as people move into areas I thought about but never managed to explore. Specifically, Daniel Nelson and Valentin Schmidt, who have both posted code demos and libraries showing how to generate PDF files with Lingo.

Check out Daniel’s BlueJade demo page or download Valentin’s latest PDF Class library.

P.S. Valentin also has a Windows-only PDF-creation Xtra!

P.P.S. Daniel’s got a set of vector shape import scripts that beat PS2VS on speed, too.

Metal and Help

Christophe Leske’s posted commands for giving MX2004 on OS X a metal look, and for opening specific help topics.

Circular Lingo

A thread on DIRECT-L came up wondering about a handler that could draw a vector shape circle of a specific size. This little knock-off script is just reverse-engineered from a circle drawn with the vector shape tools.

on createVectorCircle diameter
  vs = new (#vectorshape)
  radius = diameter / 2.0
  rhsqh = radius * sqrt (0.5)
  cpoffset = rhsqh * 0.5625
  vs.vertexlist = [[#vertex: point(-rhsqh, -rhsqh), \
                    #handle1: point(cpoffset, -cpoffset), \
                    #handle2: point(-cpoffset, cpoffset)], \
                   [#vertex: point(rhsqh, -rhsqh), \
                    #handle1: point(cpoffset, cpoffset), \
                    #handle2: point(-cpoffset, -cpoffset)], \
                   [#vertex: point(rhsqh, rhsqh), \
                    #handle1: point(-cpoffset, cpoffset), \
                    #handle2: point(cpoffset, -cpoffset)], \
                   [#vertex: point(-rhsqh, rhsqh), \
                    #handle1: point(-cpoffset, -cpoffset), \
                    #handle2: point(cpoffset, cpoffset)]]
  vs.closed = true
end



Director ROI

Over the past couple of months, I’ve updated a number of Macromedia products: Flash, Fireworks, Dreamweaver, Freehand — and now Director — to the MX 2004 level. In addition, I’ve gotten ColdFusion, JRun and Flash Communication Server developer editions and copies of Contribute for both platforms, as well as a year’s worth of Developer Resource Kits.

What’s annoying is that the Director upgrade cost me $399 per platform, while everything else cost only $599 as part of a DevNet Professional upgrade.

Flash underwent some major changes in MX 2004. The other applications in the DevNet upgrade didn’t change as much (at least not in ways I cared about, apart from the greater incorporation of CSS in Dreamweaver), but Macromedia’s push is definitely behind Flash in a way that you just don’t see there for Director. It’s clear that Macromedia sees a future in Flash.

That’s not so obvious for Director. Yes, much has changed in DMX2004, but it’s not getting the kind of overhauling that it needs for long-term development. We’re still missing standard controls. Compare the text display engine in Director with the inlined graphics and style sheets text in Flash. Shockwave 3D, the thing that was supposed to save Director and which siphoned off development resources four years ago has been relatively stagnant for two versions; nobody’s shipping new SW3D exporters.

I wish my Director dollars went as far as my Flash dollars do.