[comp.graphics] 24-bit color Pict-2?

raja@bombay.cps.msu.edu (Narayan S. Raja) (01/03/91)

Excuse what may be an elementary question...
does PICT-2 support 24-bit color?  (for
example, the GIF image format supports only
8-bit colormapped images, whereas TIFF or
Sun rasterfile formats can deal with 24 bits).

Also, how is PICT-2 different from PICT-1?

Thanks in advance,


Narayan Sriranga Raja.

ftanaka@Apple.COM (Forrest Tanaka) (01/04/91)

raja@cpswh.cps.msu.edu writes:

>Excuse what may be an elementary question...
>does PICT-2 support 24-bit color?

The Macintosh PICT format consists of a small header followed by a
sequence of an opcode, followed by the data for the opcode, followed
by another opcode, followed by the data for that opcode, and so on
until the end of the PICT.  These opcodes specify colors, raster ops,
pixel images, and lots of other stuff that's documented in Inside
Macintosh volume V from Addison-Wesley.

When 32-Bit QuickDraw 1.0 was released in May of 1989, it added two
new opcodes to the PICT format that specifically support 15-bit and
24-bit color images.  By default, 15-bit color images (16 bits per
pixel, five bits each for red, green, and blue plus a one-bit alpha
channel) is compressed using run-length encoding and 24-bit color
images (32 bits per pixel, 8 bits each for red, green, and blue
plus an eight-bit alpha channel) is compressed by sorting the red,
green, and blue channels (and optionally the alpha channel) and
using run-length encoding on the result.

For those who don't know, 32-Bit QuickDraw is a file containing a
lot of patches that gave Color QuickDraw 15-bit and 24-bit color
support and made it act a lot better than it did before (mainly for
error-diffusion dithering when copying a pixel image from one depth
to a lesser depth and anti-aliasing when shrinking a pixel image)
and it added quite a few more routines, mainly for system-level
support for off-screen images.  The 32-Bit QuickDraw file has been
included with system software since system software version 6.0.5 and
is built into the ROMs of the IIci, IIfx, LC, and IIsi.  System
software version 7.0 will have all its features built in. 

>Also, how is PICT-2 different from PICT-1?

Opcodes in PICT-1 are eight bits wide.  The worry was that 256
different opcodes might not be enough, so when the PICT format had to
be updated to support color, the opcodes were made to be 16 bits
wide, and the whole update was called PICT-2.  PICT was known as
PICT-1 from then on.  For now, if you try to draw a PICT-2 on a
Macintosh that doesn't support color, you'll get nothing.  Starting
with system software version 7.0, you can draw a PICT-2 on a black &
white Macintosh and get a black & white representation of the
picture.

>Thanks in advance,
>
>
>Narayan Sriranga Raja.


-- 
Forrest Tanaka                                    AppleLink: TANAKA
Graphics/Toolbox Developer Technical Support       Internet: ftanaka@apple.com
Apple Computer, Inc.                                  Phone: 408 974-1243

topix@gpu.utcs.utoronto.ca (R. Munroe) (01/04/91)

In article <1991Jan3.065804.17254@msuinfo.cl.msu.edu> raja@cpswh.cps.msu.edu writes:
>
>Excuse what may be an elementary question...
>does PICT-2 support 24-bit color?  (for
>example, the GIF image format supports only
>8-bit colormapped images, whereas TIFF or
>Sun rasterfile formats can deal with 24 bits).
>
>Also, how is PICT-2 different from PICT-1?
>
>Thanks in advance,
>
>
>Narayan Sriranga Raja.


Yes, PICT2 supports 24 bit images.  Actually, PICT2 supports 2, 4, 8, 16, and 32
bits per pixel.  The 32 bit format allows you to disregard the last 8 bits
or use them for anything you like (alpha, etc.).  2, 4, and 8 bit images
are indexed color, while 16 and 32 bit are direct.  PICT2 differs from PICT1
in that PICT1 supports only 1 bit per pixel.  PICT2 was Apple's first real
implementation of color (early Macs understood 8 colors but could not
display them).  The first release of Color QuickDraw (Macintosh color
drawing toolbox) supported up to 8 bits per pixel.  The fairly recent release
of 32 Bit Color QuickDraw allows Mac applications to create up to 
32 bit per pixel PICT2 files.  One word of warning:  if you are planning
on writing a PICT filter you should have no trouble converting to 
PICT format.  However, if you are planning on reading a PICT file things
will be much more difficult.  PICT files can contain everything from
bit maps to geometry to comments to text.  There are dozens of opcodes
that a PICT reader would have to handle. (This assumes that the PICT reader
is being developed on a system OTHER than a Mac - if it's going to be on a 
Mac things are much easier - toolbox calls will handle reading and writing
PICT files for you).

There is source code for a Portable Bit Map to PICT (and vice versa) utility.
The code can be found at any ftp site that archives the PBM set.
Although the code is a nice starting point, it doesn't properly
handle (or even skip) non-bitmap opcodes.  It also only works on PICT2
files of up to 8 bits per pixel.

Bob Munroe
topix@utcs.utoronto.ca