Tuesday, July 27, 2010

Color in AFP

AFP has a number of interesting places that it hides color.

Most obvious from what I have posted so far are images. AFP does not support as elaborate a model as PDF but there are still many places you can put color.

In AFP there are some 150 or so types of records. Each type of record does something unique and specific. Within these record types there are several more sub-record types. I divide the main AFP record types up into different categories based on my goals. For example, for color processing Page Segments (PSEGs) are used to hold images, bar codes, and graphics. One Page Segement Begin/End record pair can bracket up to a few dozen or so other AFP record types - mostly related to specifying things about height, width, resolution, and so on. Within each sub category, e.g., graphics, there are record types that hold sub-records, e.g., for drawing a box, stroking a line, etc.

So in terms of color you need to be able to find the PSEGs in an AFP file and them delve into them to find their sub-parts. Only at that point can you then think about processing color.

Let's consider the GOCA sub-record type in PSEGs. Color is manifest in a couple of record types related to color, here we will consider GSPCOL because its the most general. This is basically a "set color" operator. It supports RGB, CMYK, LAB and a few other types of color.

So to find and change a GOCA GSPCOL here's basically what you have to do:

- Scan the AFP file until you find a Begin/End pair of Page Segment records. These two record types bound all GOCA - though there may not be any GOCA in them.

- Scan the AFP records in the PSEG and look for Begin/End Graphics. If we don't find any we are done.

- If we find some, then we have to find the AFP records containing the sub-record GOCA commands.

- We then have to scan these sub records looking for GOCA GSPCOL record types.

- When we find a GSPCOL when then check it for color to determine what we should do with in.

Images work in a similar fashion but all the different. In the case of image there are also the actual image raster to consider as well, i.e., in GOCA you can change the color of a box with GSPCOL in a GOCA AFP record. For images you have to do basically the same, but also change the actual raster.

Unfortunately each major color carrying AFP record type, e.g., PTX, has a similar yet unique process required for it.

1 comment:

  1. One other thing you want to be aware of. If you like black and white prints, be sure you specify TRUE BLACK AND WHITE prints.

    beta afp browser

    ReplyDelete