Color Icons
Volume Number: | | 5
|
Issue Number: | | 10
|
Column Tag: | | Programmer's Forum
|
Related Info: Color QuickDraw
Understanding Color Icons
By Steve and Patricia Sheets, Herdon, VA
Note: Source code files accompanying article are located on MacTech CD-ROM or source code disks.
Understanding, Creating and Using Color Icons
Traditional Quickdraw contains numerous data structures. Bit Images, BitMaps, Patterns, and Icons are all graphic concepts that a Macintosh programmer uses in order to manipulate Quickdraw. Most of these graphic concepts are layered in construction. For example, in order to understand how to create and manipulate Icons, a Mac programmer needs to know about Bitmaps.
The topic of this column is the Color Icon data structure. The same layered approach that is used in traditional Quickdraw is also used in Color Quickdraw. Thus in order to understand Color Icons, this article will explain about Pixel Images, Pixel Bitmaps, and Color Look-up tables. Once the Color Icons structure is defined, this article will discuss the simple usage of Color Icons in Menus and Dialogs. Finally, creating Color Icons using ResEdit templates will be covered.
Bit Images and Bitmaps
In Quickdraw, the basis of all graphic data structures is the Bit Image. The Bit Image is a portion of memory that represents an arbitrary black and white display. Each bit of the image represents a pixel of the display. If a Bit is set, the pixel is black. If it is unset, the pixel is white. The pixels are laid out left to right, then top to bottom. The Pixel in the upper left corner is defined in Bit 1, the Pixel to the right of it is defined in Bit 2 and so on. Notice that a Bit Image has no built-in definition. There is no explanation of the horizontal or vertical dimensions of the image. Non-color Macintosh (Mac 128K, Mac 512K, Mac Plus, Mac SE) screens are represented as Bit Images.
The Quickdraw Bitmap is the data structure that represents an exact black and white display. A Bitmap contains a pointer to the Bit Image, the row width of that Bit Image, and the coordinates of that Image. The coordinates of the Bit Image is defines as a boundary rectangle. The upper left coordinate of the rectangle is the first pixel of the Bitmap. In most cases, this is defined as 0,0. While it is easiest to work with Bitmaps laid out this way, the upper left coordinate could be any value. The row width defines the the number of pixels that are on one row of the Bit Image. This is given in Bytes of memory, not pixels. Also, the row width must be an even number of Bytes. Thus a BitMap that had 32 pixels in a row would have a byte with at least 4 bytes (8*4). The row width could be larger, that would just mean some of the bits of the Image were not being used. For example, a Bitmap that had only 30 pixels in a row would still require a row width of 4 bytes. The 31st & 32nd bits would not be used.
{1}
Bitmap = RECORD
baseAddr:Ptr;
rowBytes:Integer;
bounds:Rect;
END;
Pix Images and PixMaps
Color Quickdraws equivalent of a Bit Image is the Pixel Image. The Pixel Image is a portion of memory that represents a display, possibly a color display. Each Pixel on the display is represented by one or more bits in the memory. The number of bits that is required for a single pixel is called the depth of the Image. Pixel Images are similar to Bit Images in that the size and row width of a Pixel Image is not defined. Also undefined is the depth of the image, the exact lay out of the bits in memory, and the conversion of the bits of a pixel to colors. All these values are defined in a Pixel Map.
The Pixel Map is Color Quickdraws equivalent of a Bit Map. Like a Bitmap, it contains a pointer to the Image (Pixel in this case), the row width (in bytes) of the Image, and the dimensions of the rectangle. However the Pixel Map is more complicated than that.
{2}
PixelMap = RECORD
baseAddr:Ptr;
rowBytes:Integer;
bounds:Rect;
pmVersion: Integer;
packType:Integer;
packSize:LongInt;
hRex: Fixed;
vRes: Fixed;
pixelType: Integer;
pixelSize: Integer;
cmpCount:Integer;
cmpSize: Integer;
planeBytes:LongInt;
pmTable: CTabHandle;
pmReserved:LongInt;
END;
PixMapPtr = ^PixMap;
PixelMapHandle = ^PixmapPtr;
A PixMap is usually manipulated as a handle. Most of the data structures and routines that work with PixMaps, use or pass handles to the PixMap. For this reason, the 3 high bits of the row width field are used as flags. The high bit of the row width field must be set (1). This indicates that this data structure is a PixMap, not a BitMap. The next two bits are reserved for future use. For now, they must be unset (0).
Beyond the three normal Bitmap variables, the PixMap has twelve other variables. The pmVersion field contains the version number of Color Quickdraw. Currently this is set to 0. The packType field is used to define the Packing Algorithm that the PixMap uses on the bits. Again, this is normally set to 0 since, as of now, Color Quickdraw does not support a PixMap packing algorithm. The packSize field contains the number of bytes of the packed image. It is set to 0 if no packing algorithm is used. The hRes and vRes fields contain the horizontal and vertical resolution of the PixMap in pixels per inch. Currently all Mac screens are 72 DPI, thus the hRes and vRes settings of the Pixmap are 72.
The next few fields define the exact layout of the bits in the PixMaps Pixel Image. The pixelType field defines the format. PixelType should be set to 0 to indicate Chunky. A value of 1 indicates Chunky/Planar format and a value of 2 indicates Planar. The first and most important format is the Chunky format. In a Chunky Pixel Image, all of a rows pixels are stored consecutively. Thus for a Pixel Image with the depth of 4, the first 4 bits of memory represent the first Pixel.
Originally, Chunky format was the only format that Color Quickdraw could use; all Mac // video cards used Chunky. However, with the introduction of video cards with more than 8 bits per pixel, the other formats were also used. The Planar and Chunky/Planar formats divide the Pixel Image in memory into separate sections. These sections, called planes, usually represent different color components of a shade. For example, a 24 Bit card might divide the memory up into Red, Green and Blue portions, or components, of memory. Hopefully, this column will be discussing more about 32-Bit Quickdraw in the future. For this article, only Chunky Format will be explored.
For Chunky Format, it is important to realize that for every pixel on the screen there is a group of consecutive bits in memory. This group of bits contains an integer value, representing the color of the pixel being displayed. For example, a PixMap with a depth of 4 would have 4 bits for every pixel in the image. Since 4 bits can contain 16 distinct integer values (0 thru 15), that PixMap could contain 16 different colors at one time. A 8 bit PixMap could contain up to 256 distinct colors.
The pixelSize field of the PixMap defines the depth of the PixMap and its Pixel Image. The pixelSize must be in powers of 2 for Chunky format (ie. 1, 2, 4, 8). The next field, cmpCount, defines the number of color components (planes). The cmpSize field contains the number of bits per each color component. The planeBytes field gives the offset from one color plane to the next. Since Chunky format has only 1 component, the cmpCount field is set to 1, the cmpSize field should match the pixelSize field, and the planeBytes field should be set to 0 (indicating no offset). Jumping ahead one field, the pmReserved field is exactly that: reserved for future expansion and currently set to 0.
The last field of a PixMap to be explained is the pmTable field. So far, the layout and dimensions of the PixMap have been defined. However, there has been no mention of how the value of a set of bits is converted into a RGB color. Such a conversion is defined in a Color Table data structure. The pmTable field contains a handle to a Color Table data structure.
Color Tables
So far in this article, the terms screen and PixMap display have been used interchangeably. This is not exactly correct. All video display devices are Graphic Devices. Graphic Devices have numerous data structures associated with them, including a device driver, Color GrafPort, a Color Table and a PixMap. The Graphic Devices PixMap is the entire viewable area of the screen. This is similar to the way traditional Quickdraw has a screenbit variable that is a Bitmap of the entire screen. Other PixMaps that contain portions of the screen must point to the same data as the Graphic Devices PixMap and must share the same Color Table. However that Color Table is owned by the Graphic Device, not any PixMap. Offscreen PixMaps can also be created. These PixMaps would point to a different Pix Image than the Graphic Device. Each PixMap could have its own Color Table or share a Graphic Devices Color Table. More will be discussed in the next article about the advantages of each method. For now, realize that there is a difference in layout between a Color Table owned by a PixMap and one owned by a Graphic Device.
Both PixMaps or Graphic Devices use the Color Table data structure to convert the bit values of pixels into some RGB color. To do this, a Color Table contains a list of colors, defined in the Color Spec data structure. Each Color Spec contains a RGB color field, defined using the RGBColor data structure which specifies the Red, Green and Blue portions of the color. Each Color Spec also has a number associated with it. Thus if the Color Table has 16 colors, there are 16 numbers associated with it. If the bits that are associated with a specific pixel of a PixelMap are equal to the number of some Color Spec, then that Pixel has that associated RGB value. If the PixMap was part of a Graphic Device, the display would show that RGB color on the Graphic Device. Where the number that is associated with each Color Spec comes from will be explained below.
When some pixels of a PixMap are copied onto another PixMap, each pixel on the source PixMap is converted into the RGB value. Then the closest matching RGB value is found on the destination PixMap. The associated value is then placed in the destination PixMap in the correct bits. Thus PixMaps having various depths and colors can be copied from one and another. While it makes things simpler and faster if the PixMaps share the same Color Table, it is not necessary. Color Quickdraw calculates the correct bit values for all the pixels even if they do not share the same Color Table.
{3}
RGBColor = RECORD
red: Integer;
green: Integer;
blue: Integer;
END;
ColorSpec = RECORD
value: Integer;
rgb: RGBColor;
END;
ColorTable = RECORD
ctSeed:LongInt;
ctFlags: Integer;
ctSize:INTEGER;
ctTable: ARRAY [0..0] OF ColorSpec;
END;
CTabPtr = ^ColorTable;
CTabHandle = ^CTabPtr;
The Color Table data structure consists of a handle to a variable size record. The first field, the ctSeed field, is the version identifier number used internal by Color Quickdraw. It keeps track of changes to the Color Table. Everytime the Table is changed, the ctSeed needs to be reset using the Color Manager GetCTSeed function. If Color Quickdraw changes the Color Table, it will reset the field. If an application does the changes, it must reset the field. When creating PixMaps, this field is set to 0.
The second field of the Color Table is the ctFlags field. As mentioned above, some Color Tables are owned by Graphic Devices, while others can be owned by simple offscreen PixMaps. If the PixMap owns the Color Table, this field must be set to 0. If the Graphic Device owns the PixMap, the high bit of the field will always be set. The rest of the bits of the field will be used as flags by the Graphic Device Manager.
The next field of the PixMap is the ctSize field. It is the number of RGB colors that are defined in the Color Table. The number of colors equals the value of the field minus one, thus a setting of 1 indicates 2 Colors, while a setting of 255 indicates 256 colors. For a Graphic Device, this number needs to be a power of 2. For a PixMap, this number can be any positive value. Remember that the bit depth of the PixMap, not the ctSize field, defines the maximum number of colors for a Pixel Image.
The last portion of the Color Table contains a variable size array of Color Spec data structures. The RGB field contains the exact Red, Green and Blue components of the Color Spec. The number that is associated with that Color Spec is dependent on who owns the Color Table. Graphic Devices use the position of the Color Spec (zero count) in order to find the number. Thus the first Color Spec would have the number 0, the next Color Spec would have the number 1 and so on. In that case, the value field of the Color Spec is used internally by the Color Device manager. Color Tables that are owned by PixMaps use the value field to determine what the number of the Color Spec is. Each value field of the Color Table should then have a unique number. While the contents of the value fields can be in any order (first Color Spec, value 9, next Color Spec, value 3, next one, value 23, and so on), it is recommended that PixMaps follow the Color Devices method of numbering the Color Specs (first Color Spec, value 0, next Color Spec, value 1, next one, value 2, and so on). This makes it easier to visualize the image.
Graphic Devices have very special rules about the Color Tables associated with them. As mentioned above, the number of colors must be a power of 2, and match the bit depth of the Graphic Device. The first color must be white (RGB value $FFFF,$FFFF,$FFFF) and the last color must be black (RGB value $0,$0,$0). Color Tables used with PixMaps are much more unrestricted in their constructions. There can be any number of Color Specs and they may be in any order. Just remember that the PixMap that points to the Color Table can only use the first N number of colors where N is dependent on the depth of the Pix Image (depth 4, 16 colors, depth 8, 256). It is a good rule of thumb to have the first Color Spec be white and the last one be black. Again, this makes it easier to visualize the image.
Icons and Color Icons
Now that an Image, a Bitmap, a Pixel Image and a PixMap have been discussed, traditional Icons and Color Icons can be explained. Under Quickdraw, an Icon is a Bit Image of a very specific size. The dimensions of an Icon are the always the same. An Icon is a 32 bit by 32 bit black and white image. Its Row width is 4 bytes. Since the dimensions are always the same, the Icon data structure consists of a handle to the Bit Image portion of the Icon.
Under normal Quickdraw, there are two types of Icons; icons stored in ICON resources and icons stored in ICN# resources. The handle of a ICON type Icon contains only the Bit Image. Since the Row Width is 4 bytes and the vertical size is 32, the size of such an Icon handle is 128 bytes. When an ICON type Icon is drawn on the screen, the entire Bit Image is transferred (all 32 by 32 pixels) to the screen.
An ICN# icons handle contains the Bit Image of the Icon followed by the Bit Mask of the Image. Thus it is twice the size, or 256 bytes. If the Bit Image portion explains what is to be drawn, the Bit Mask portion explains where. Thus each pixel has 2 bits associated with it, an Image bit and a Mask bit. When an ICN# type Icon is drawn on the screen, only the pixels of the Bit Image, whose corresponding Mask bits are set, are then transferred to the screen.
For example, imagine an ICN# type of Icon consisting of a 10 by 10 frame. The Bit Image portion contains a hollow square. The pixels in the frame are set (black). The pixels of the outside of the frame and the inside of the frame are unset (white). The Bit Mask portion of the Icon contains a solid square. The pixels in the 10 by 10 square are all set, while only the pixels outside that 10 by 10 square are unset. When this Icon is drawn on the screen, only the pixels of the Bit Image that are set in the Bit Mask ( the ones in the 10 by 10 square) are copied. Thus if the Icon is copied onto a gray background, the frame would be black and the inside of the frame would be white. The idea that an Icon contains a Image and a Mask is an important one in understanding Color Icons.
Given the understanding of all the other data structures, the Color Icon data structure is fairly simple. It contains a PixMap defining the Color Image, a Bitmap defining the Mask, another Bitmap defining the Black and White image, a Handle to the Color Image data and a variable size array of data containing the bitmap images.
{4}
CIcon = RECORD
iconPMap:PixMap;
iconMask:Bitmap;
iconBMap:BitMap;
iconData:Handle;
iconMaskData: ARRAY[0..0] of Integer;
END;
CIconPtr = ^ CIcon;
CIconHandle = ^ CIconPtr;
The first thing to notice is that the Icon can be of any size, not just 32 by 32 pixels. The iconPMap field defines a PixMap of any given size, depth or color. Second, note that a Color Icon always contains a Mask, held in the iconMask field. When a Color Icon is drawn, only the color pixels in the PixMap which correspond to the set bits in the Mask Bit Image will be copied. Next, notice that the Pixmap will not be drawn on screens with a depth of 1 or 2 (Black and White displays or 4 Color displays). In these cases, the BitMap defined in the iconBMap field would be drawn instead. While the Pixel Image and the Bit Image do not need to look similar, it is better if they do. Both images share the same Mask. Finally, note that while the color Pixel Image data is stored as a handle in the iconData field, the Mask and Bitmap Images are stored at the end of the Color Icon data structure. Thus a Color Icon handle is a variable size handle, depending on the dimensions of the Mask and Bit Image.
Color Icon Resource
Now that the Color Icon data structure has been explored, creating Color Icons can be discussed. While Color Icons can be made with many methods, the most common one is to use a Color Icon Resource. Color Quickdraw has a routine, GetCIcon, that creates a PixMap (and associated Color Table and Pix Image) using a resource template. Color Icon resource use resource type cicn. The important thing to realize is that the resource is used as information in the creation of a Color Icon. Once the Color Icon is created, the template is released by the call. This is different than other traditional Quickdraw resources (ie. ICON or ICN#) where the resource is the entire data structure. The cicn resource is a merge of the various data structures and fields that the Color Icon data structure contains. Thus there are similar fields and values. The cicn resource format and content is as follows:
Name Date Type Use
Icon PixMap Portion
baseAddr Handle 0
rowbytes Integer rowbytes of PixMap
bounds Rect boundary rectangle of PixMap
pmVersion Integer 0
packType Integer 0
packSize LongInt 0
hRes Fixed 72
vRes Fixed 72
pixelType Integer 0 (Chunky)
pixelSize Integer bits per pixel of PixMap
cmpCount Integer 1
cmpSize Integer bits per pixel of PixMap
planeByte LongInt 0
pmTable Handle 0
pmReserved LongInt 0
Icon Mask Portion
baseAddr Handle 0
rowbytes Integer rowbytes of Mask
bounds Rect boundary rectangle of Mask
Icon Bitmap Portion
baseAddr Handle 0
rowbytes Integer rowbytes of BitMap
bounds Rect boundary rectangle of BitMap
Icon Data Handle 0
Mask Data Masks rowbytes * Masks vertical size
Bitmap Data Bitmaps rowbytes * Bitmaps vertical size
Color Table Portion
ctSeed LongInt 0
ctFlag Integer 0
ctSize Integer Number of Color Specs - 1
ctSpecs Number Specs*8 array of Color Specs
PixMap Data PixMaps rowbytes * PixMaps vertical size
Many of the fields are place holders. As such, they are set to 0. Remember that Integers are 2 bytes in size, Handles are 4 bytes, LongInt are 4 bytes, Fixed (real values) are 4 bytes and Rect (Rectangles) are 8 bytes (4 Integers). The rest of the field directly related to the Color Icon data structure.
Color Icons in Menus and Dialogs
The two most common usages of normal Icons are placing them in Menus and drawing them in Dialogs. In both cases, the ICON resources number is somehow defined in the Menu and Dialog. The Menu and Dialog Manager then displays the Icon.
The method to place icons in the menu is slightly complicated. If a Menu Item is created using the GetMenu or AppendMenu procedures that contains a circumflex (^) followed by an ASCII character beyond 48, then the ASCII value of the character subtracted by 48 then added to 256 gives the resource number of the Icon to be displayed in that Menu Item. This strange numbering scheme means that a Menu Item with ^1 in it will display the Icon with the resource number of 257. ^2 will give resource number 258, while ^9 will give 256. Also the SetItemIcon procedure can be used to directly attach a Icon to a Menu Item. In that case, 256 must be added to the Icon number in the procedure to find the correct ICON resource number. Thus Icons that are displayed in the Menu must be in the range of 257 to 512.
To display Icons in Dialogs and Alerts, the Dialog Item List must contain an iconItem. That Item will contain the Display rectangle in local coordinates of the Dialog and the 2 byte resource ID. Any ICON resource number can be used.
With the implementation of Color Quickdraw, changes to the Menu Manager and Dialog Manager have been added. Now, when an Icon is referred to by a Menu or Dialog, first the resource number is calculated. Next, a Color Icon resource (cicn) with that resource number is looked for. If that resource exists, a Color Icon is created using it. That Color Icon will be displayed in the Menu or Dialog. If a cicn resource with that resource number does not exist, the ICON resource with that number is looked for and used.
This method of using cicn resource, when one exists, was well thought out. Imagine a program is created that has Icons in the menu and in its dialogs. The program is designed to run on color and non-color Macintoshes. For each Icon needed, an ICON resource and a cicn resource are created with the same number. When the program runs on non-color Macintoshes, the ICON resource is loaded into the computer and displayed. When the program is run on a color Macintosh, the cicn resource is found and displayed. Color Icons can be added to a program without any source code changes. Some of the Colorization programs available use this idea to add color to programs already created.
Creating Color Icon Resources
The Color Icon resource structure is a complex one. It is not a fixed width structure. Many of the field sizes are dependent on the settings of other fields. For this reason, most resource tools (ResEdit, RMaker) are not capable of easily manipulating the resource structure. The only resource tool that can do this is MPWs Rez tool. While MPW does have a cicn resource template that works, it has a couple of faults. First of all, it is hard to imagine the image that the Color Icon is trying to create. Changing and editing the Color Icon is difficult. Secondly the template does not do a good job of deciphering the Color Table portion of the data structure. Lastly, many of the fields of the data structure could be precalculated or predefined.
To solve these problems, a modified cicn resource template has been created (see resource code example #1). First a couple of assumptions must be made. The Color Icon that is to be created must be within a 32 by 32 pixel size. Since the standard size of the tradition Icon is 32 by 32, this is usually acceptable. Secondly, the depth of the Color Icon is 4 bits or 16 colors. For most uses, 16 colors are enough.
Given these rules, large portions of the resource data structure can be precalculated. Many of the fields are preset, while other variable size fields can be defined as a fixed size. More importantly, the Pixel Image and Bit Images can be displayed in Hex and Binary, respectively, so that an image can be more easily seen. Examine resource code example #2. Five different Color icons are displayed in a more viewable format. Resource code example #2 also contains the resource code for an Alert that displays the icons. Creating Color Icons this way is much easier than using the template provided by MPW! Code example #3 gives the Pascal and Resource source for a very simple demonstration application. The application, cicnFun, displays the Color Icons in an Alert. With this, an user can quickly see the Color Icons that were created.
Listing #1: CIcon.r
/*
* File CIcon.r
*
* Created by Steve Sheets for MacTutor
*
* revised cicn Resource Template
*
*/
type cicn {
longint = 0; /* Base address */
integer = $8010;/*New pixMap flag & Offset tonext row*/
integer = 0; /* Bitmap bounds */
integer = 0;
integer = 32;
integer = 32;
integer = 0; /* pixMap vers number */
integer = 0; /* Packing format */
longint = 0; /* Size of packed pixel data*/
unsigned hex longint = $00480000; /* h. resolution (ppi) (fixed) */
unsigned hex longint = $00480000; /* v. resolution (ppi) (fixed) */
integer = 0; /* Pixel storage format */
integer = 4; /* # bits in pixel*/
integer = 1; /* # components in pixel*/
integer = 4; /* # bits per field */
longint = 0; /* Offset to next plane */
longint = 0; /* Offset to color table*/
longint = 0; /* Reserved*/
/* IconMask (bitMap) record */
fill long; /* Base address */
integer = 4; /* Row bytes */
integer = 0; /* Bitmap bounds */
integer = 0;
integer = 32;
integer = 32;
/* IconBMap (bitMap) record */
fill long; /* Base address */
integer = 4; /* Row bytes */
integer = 0; /* Bitmap bounds */
integer = 0;
integer = 32;
integer = 32;
longint = 0; /* Handle placeholder */
array [32] { /* Mask Data */
unsigned binary longint;
};
array [32] { /* BMap Data */
unsigned binary longint;
};
/* PMapCTab*/
longint = 0; /*ctSeed */
integer = 0; /*transIndex */
integer = $$Countof(ColorSpec) - 1; /*ctSize*/
wide array ColorSpec {
hex integer; /*value */
unsigned integer; /*RGB: red */
unsigned integer; /*green*/
unsigned integer; /*blue */
};
array [32] { /*PMap Data*/
hex string[16];
};
};
Listing #2: cicnFunRes.r
/*
* File cicnFunRes.r
*
* Created by Steve Sheets for MacTutor
*
* Resource source file for cicnFun application
*
*/
#include Types.r /*For ALRT & DITL resources */
#include CIcon.r /*For revised cicn resources */
resource ALRT (1000) {
{40, 180, 192, 460}, 1000,
{ OK, visible, silent, OK, visible, silent,
OK, visible, silent, OK, visible, silent } };
resource DITL (1000) {
{ {112, 110, 132, 170}, Button { enabled, OK },
{60, 20, 92, 52}, Icon { disabled, 1000 },
{60, 72, 92, 104}, Icon { disabled, 1001 },
{60, 124, 92, 156}, Icon { disabled, 1002 },
{60, 176, 92, 208}, Icon { disabled, 1003 },
{60, 228, 92, 260}, Icon { disabled, 1004 },
{20, 79, 40, 201}, StaticText { disabled,
Sampe Color Icons } } };
resource cicn (1000, cicn Sun) {
{ 0b00000000000000111110000000000000, /* Mask */
0b00000000000000111110000000000000,
0b00011110000001111111000000111100,
0b00011111000001111111000001111100,
0b00011111100111111111110011111100,
0b00011111111111111111111111111100,
0b00001111111111111111111111111000,
0b00000111111111111111111111110000,
0b00000011111111111111111111100000,
0b00000011111111111111111111100000,
0b00000111111111111111111111110000,
0b00000111111111111111111111110000,
0b00011111111111111111111111111100,
0b01111111111111111111111111111111,
0b01111111111111111111111111111111,
0b01111111111111111111111111111111,
0b01111111111111111111111111111111,
0b01111111111111111111111111111111,
0b00011111111111111111111111111100,
0b00000111111111111111111111110000,
0b00000111111111111111111111110000,
0b00000011111111111111111111100000,
0b00000011111111111111111111100000,
0b00000111111111111111111111110000,
0b00001111111111111111111111111000,
0b00011111111111111111111111111100,
0b00011111100111111111110011111100,
0b00011111000001111111000001111100,
0b00011110000001111111000000111100,
0b00000000000000111110000000000000,
0b00000000000000111110000000000000,
0b00000000000000000000000000000000 },
{ 0b00000000000000011100000000000000, /* B&W Icon */
0b00000000000000100010000000000000,
0b00011110000001101011000000111100,
0b00010011000001001001000001100100,
0b00010101100111001001110011010100,
0b00011010111100000000011110101100,
0b00001101000001111111000001011000,
0b00000110100111111111110010110000,
0b00000010001111111111111000100000,
0b00000010011111111111111100100000,
0b00000110111111111111111110110000,
0b00000100111100111110011110010000,
0b00011101111111011101111111011100,
0b00110001111111111111111111000110,
0b01000001111100111110011111000001,
0b01011101111100111110011111011101,
0b01000001111111111111111111000001,
0b00110001111111110111111111000110,
0b00011101111111111111111111011100,
0b00000100111110111110111110010000,
0b00000110111111011101111110110000,
0b00000010011111100011111100100000,
0b00000010001111111111111000100000,
0b00000110100111111111110010110000,
0b00001101000001111111000001011000,
0b00011010111100000000011110101100,
0b00010101100111001001110011010100,
0b00010011000001001001000001100100,
0b00011110000001101011000000111100,
0b00000000000000100010000000000000,
0b00000000000000011100000000000000,
0b00000000000000000000000000000000 },
{ 0x0, 65535, 65535, 65535,/* Color Table */
0x1, 65535, 2998, 8638,
0x2, 65535, 65535, 0,
0x3, 65535, 17770, 2591,
0x4, 0, 0, 0 },
{ $00000000000000223220000000000000",/* Pix Image */
$00000000000000234320000000000000",
$00022222000000234320000000222200",
$00023332000002234322000002233200",
$00023432200222234322220022343200",
$00022343222233333333322223432200",
$00002234323334444444333234322000",
$00000223433444444444443343220000",
$00000022334442222222444332200000",
$00000023344422222222244433200000",
$00000223444222222222224443220000",
$00000233442211222221122443320000",
$00002234422222122212222244322000",
$02222234422222222222222244322222",
$02333334422211222221122244333332",
$03444434422211222221122244344443",
$02333334422222222222222244333332",
$02222234422222221222222244322222",
$00002234422222222222222244322000",
$00000233442221222221222443320000",
$00000223444222122212224443220000",
$00000023344422211122244433200000",
$00000022334442222222444332200000",
$00000223433444444444443343220000",
$00002234323334444444333234322000",
$00022343222233333333322223432200",
$00023432200222234322220022343200",
$00023322000002234322000002233200",
$00022220000000234320000000222200",
$00000000000000234320000000000000",
$00000000000000223220000000000000",
$00000000000000000000000000000000" } };
resource cicn (1001, cicn Moof) {
{ 0b11111111111111111111111111111111, /* Solid Mask */
0b11111111111111111111111111111111,
0b11111111111111111111111111111111,
0b11111111111111111111111111111111,
0b11111111111111111111111111111111,
0b11111111111111111111111111111111,
0b11111111111111111111111111111111,
0b11111111111111111111111111111111,
0b11111111111111111111111111111111,
0b11111111111111111111111111111111,
0b11111111111111111111111111111111,
0b11111111111111111111111111111111,
0b11111111111111111111111111111111,
0b11111111111111111111111111111111,
0b11111111111111111111111111111111,
0b11111111111111111111111111111111,
0b11111111111111111111111111111111,
0b11111111111111111111111111111111,
0b11111111111111111111111111111111,
0b11111111111111111111111111111111,
0b11111111111111111111111111111111,
0b11111111111111111111111111111111,
0b11111111111111111111111111111111,
0b11111111111111111111111111111111,
0b11111111111111111111111111111111,
0b11111111111111111111111111111111,
0b11111111111111111111111111111111,
0b11111111111111111111111111111111,
0b11111111111111111111111111111111,
0b11111111111111111111111111111111,
0b11111111111111111111111111111111,
0b11111111111111111111111111111111 },
{ 0b00000000000000000000000000000000,
0b00000000000000000000000000000000,
0b00000000000000000000000000000000,
0b00000000000000000000000000000000,
0b00000000000000000000000000000000,
0b00000000000000000000000000000000,
0b00000111011100000000000000000000,
0b00000101110100000000000000001000,
0b00000100001100000000000000001100,
0b00001101001100000000000000010100,
0b00010000000100000000000001100100,
0b00100000000011000000000001000100,
0b00100001100001111111111110001000,
0b00011110100000001111111100010000,
0b00000001100000000011110000010000,
0b00000110010000000000000000010000,
0b00000000011100000000000000010000,
0b00000000011100000000000000010000,
0b00000000011100000000000000010000,
0b00000000010011111111111100010000,
0b00000000010010000000000100010000,
0b00000000010010000000000110010000,
0b00000000010010000000000010010000,
0b00000000110110000000000110010000,
0b00000001101100000000001101110000,
0b00000000110000000000000111000000,
0b00000000000000000000000000000000,
0b00000000000000000000000000000000,
0b00000000000000000000000000000000,
0b00000000000000000000000000000000,
0b00000000000000000000000000000000,
0b00000000000000000000000000000000 },
{ 0x0, 65535, 65535, 65535,
0x1, 65535, 0, 0,
0x2, 0, 65535, 0,
0x3, 0, 0, 65535,
0x4, 57343, 57343, 57343,
0x5, 9111, 49151, 8237,
0x6, 32767, 32767, 32767,
0x7, 4158, 24575, 3251,
0x8, 16383, 16383, 16383,
0x9, 0, 0, 0 },
{ $00000000000000000000000000000000",
$00000000000000000000000000000000",
$00000000000000000000000000000000",
$00000000000000000000000000000000",
$00000000000000000000000000000000",
$00000000000000000000000000000000",
$00000999099900000000000000000000",
$00000949994900000000000000009000",
$00000900009900000000000000009900",
$00009903009900000000000000094900",
$00090000000900000000000009944900",
$00900000000099000000000009440900",
$00900009900009999999999994409000",
$00099991900000048888888844090000",
$00001119900000044466664440090000",
$00001990094440000444444000090000",
$00001000096640000000000000090000",
$00000000098640000000000000090000",
$00000000096640000000000000090000",
$00000000094499999999999900090000",
$00000000290090000000000900090222",
$00000027290092007000000990092222",
$00000022790092727272222290097272",
$02227222990097727725555990097722",
$22272229909975577555559909997222",
$27272222992275555555555999557555",
$22772222222222222222555555555555",
$22222222222222222227555555555555",
$22722772222222222227225555555555",
$22727222727222227227272225555555",
$22772222277222222727722225555555",
$22722222227722222277222225555555" } };
resource cicn (1002, cicn Robbie) {
{ 0b00000000000000111111110000000000,
0b00000000000000111111110000000000,
0b00000000000000111111110000000000,
0b00000000000000111111110000000000,
0b00000000000000111111110000001001,
0b00000000000000111111110000001001,
0b00000000000000000110000000001111,
0b00011100000000111111111000001111,
0b00000110000001111111111100000110,
0b00000110000011100111011110001110,
0b00011111000111000111001111011100,
0b00000011101110000111000111111000,
0b00000001111100000111000011110000,
0b00000000111000000111000001100000,
0b00000000010000001111110000000000,
0b00000000000000111111110000000000,
0b00000000000011111111111000000000,
0b00000000001111111111111000000000,
0b00000000111111111111111100000000,
0b00000011111111111111111100000000,
0b00000111111111111111111100000000,
0b00000011111111111111111110000000,
0b00001011111111111111111110100000,
0b00011111111111111111111111110000,
0b00001111111111111111111111100000,
0b00111111111111111111111111111000,
0b00011111111111111111111111110000,
0b00111111111111111111111111111000,
0b00001111111111111111111111100000,
0b00011111111111111111111111110000,
0b00001011111111111111111110100000,
0b00000010010010010010010010000000 },
{ 0b00000000000000111111110000000000,
0b00000000000000111111110000000000,
0b00000000000000100110010000000000,
0b00000000000000100110010000000000,
0b00000000000000111111110000001001,
0b00000000000000111111110000001001,
0b00000000000000000110000000001111,
0b00011100000000111111111000001111,
0b00000110000001111111111100000110,
0b00000110000011100111011110001110,
0b00011111000111000111001111011100,
0b00000011101110000111000111111000,
0b00000001111100000111000011110000,
0b00000000111000000111000001100000,
0b00000000010000001111110000000000,
0b00000000000000111111110000000000,
0b00000000000011111111111000000000,
0b00000000001111111111111000000000,
0b00000000111111111111111100000000,
0b00000011111111111111111100000000,
0b00000111111111111111111100000000,
0b00000010010010010010010010000000,
0b00001011111111111111111110100000,
0b00011111111111111111111111110000,
0b00001111101111101111101111100000,
0b00111111101111101111101111111000,
0b00011110000010000010000011110000,
0b00111111101111101111101111111000,
0b00001111101111101111101111100000,
0b00011111111111111111111111110000,
0b00001011111111111111111110100000,
0b10010010010010010010000000 },
{ 0x0, 65535, 65535, 65535,
0x1, 65535, 0, 0,
0x2, 0, 65535, 0,
0x3, 0, 0, 65535,
0x4, 49151, 48660, 48660,
0x5, 32767, 32767, 32767,
0x6, 24575, 24575, 24575,
0x7, 0, 0, 0 },
{ $00000000000000777777770000000000",
$00000000000000666666660000000000",
$00000000000000611661160000000000",
$00000000000000611661160000000000",
$00000000000000666666660000007007",
$00000000000000666666660000007007",
$00000000000000000770000000007777",
$00077700000000444444444000004444",
$00000740000004444444444400000440",
$00000740000044440444044440004440",
$00077744000444400444004444044400",
$00000044404444000444000444444400",
$00000004444400000444000044444000",
$00000000444000000444000004400000",
$00000000040000004454440000000000",
$00000000000000444555540000000000",
$00000000000044455555544000000000",
$00000000004445555555554000000000",
$00000000444555555555554400000000",
$00000044455555555555555400000000",
$00000444444444444444444400000000",
$00000030030030030030030030000000",
$00003033333333333333333330300000",
$00033333333333333333333333330000",
$00003333323333323333323333300000",
$00333333323333323333323333333000",
$00033332222232222232222233330000",
$00333333323333323333323333333000",
$00003333323333323333323333300000",
$00033333333333333333333333330000",
$00003033333333333333333330300000",
$00000030030030030030030030000000" } };
resource cicn (1003, cicn Flag) {
{ 0b00000000000000000000000000000000,
0b00000000000000000000000000000000,
0b00000000000000000000000000000000,
0b00000000000000000000000000000000,
0b00000000000000000000000000000000,
0b00001100000000000000000000000000,
0b00001100000000000000000000000000,
0b00001100000000000000000000000000,
0b00001111111111111111111111111000,
0b00001111111111111111111111111000,
0b00001111111111111111111111111000,
0b00001111111111111111111111111000,
0b00001111111111111111111111111000,
0b00001111111111111111111111111000,
0b00001111111111111111111111111000,
0b00001111111111111111111111111000,
0b00001111111111111111111111111000,
0b00001111111111111111111111111000,
0b00001111111111111111111111111000,
0b00001111111111111111111111111000,
0b00001111111111111111111111111000,
0b00001100000000000000000000000000,
0b00001100000000000000000000000000,
0b00001100000000000000000000000000,
0b00001100000000000000000000000000,
0b00001100000000000000000000000000,
0b00001100000000000000000000000000,
0b00001100000000000000000000000000,
0b00001100000000000000000000000000,
0b00001100000000000000000000000000,
0b00001100000000000000000000000000,
0b00001100000000000000000000000000 },
{ 0b00000000000000000000000000000000,
0b00000000000000000000000000000000,
0b00000000000000000000000000000000,
0b00000000000000000000000000000000,
0b00000000000000000000000000000000,
0b00001100000000000000000000000000,
0b00001100000000000000000000000000,
0b00001100000000000000000000000000,
0b00001111111111111111111111111000,
0b00001111011011011000000000000000,
0b00001110110110111111111111111000,
0b00001111101101101000000000000000,
0b00001111011011011111111111111000,
0b00001110110110111000000000000000,
0b00001111111111111111111111111000,
0b00001100000000000000000000000000,
0b00001111111111111111111111111000,
0b00001100000000000000000000000000,
0b00001111111111111111111111111000,
0b00001100000000000000000000000000,
0b00001111111111111111111111111000,
0b00001100000000000000000000000000,
0b00001100000000000000000000000000,
0b00001100000000000000000000000000,
0b00001100000000000000000000000000,
0b00001100000000000000000000000000,
0b00001100000000000000000000000000,
0b00001100000000000000000000000000,
0b00001100000000000000000000000000,
0b00001100000000000000000000000000,
0b00001100000000000000000000000000,
0b00001100000000000000000000000000 },
{ 0x0, 65535, 65535, 65535,
0x1, 65535, 0, 0,
0x2, 65535, 65535, 0,
0x3, 0, 0, 65535 },
{ $00000000000000000000000000000000",
$00000000000000000000000000000000",
$00000000000000000000000000000000",
$00000000000000000000000000000000",
$00000000000000000000000000000000",
$00002200000000000000000000000000",
$00002200000000000000000000000000",
$00002200000000000000000000000000",
$00002233333333333111111111111000",
$00002233033033033000000000000000",
$00002230330330333111111111111000",
$00002233303303303000000000000000",
$00002233033033033111111111111000",
$00002230330330333000000000000000",
$00002233333333333111111111111000",
$00002200000000000000000000000000",
$00002211111111111111111111111000",
$00002200000000000000000000000000",
$00002211111111111111111111111000",
$00002200000000000000000000000000",
$00002211111111111111111111111000",
$00002200000000000000000000000000",
$00002200000000000000000000000000",
$00002200000000000000000000000000",
$00002200000000000000000000000000",
$00002200000000000000000000000000",
$00002200000000000000000000000000",
$00002200000000000000000000000000",
$00002200000000000000000000000000",
$00002200000000000000000000000000",
$00002200000000000000000000000000",
$00002200000000000000000000000000" } };
resource cicn (1004, cicn Mac) {
{ 0b00000000000001111111111110000000,
0b00000000000010000000000000000000,
0b00000000000010000111111000100000,
0b00000000000010000000000100100000,
0b00000000000010000000000100100000,
0b00000100000010000000000100100000,
0b00001100000010000000000100100000,
0b00001000000010000000000100100000,
0b01100110000010000000000100100000,
0b10011001000010000000000100100000,
0b10000001000010001111111000100000,
0b10000000000010000000000000100000,
0b10000000000010000000000000100000,
0b01001010000000000001111100100000,
0b00110100000000000000000000100000,
0b00000000111111000000000000100000,
0b00000011000000000000000000000000,
0b00000100000000011111111111110000,
0b00000100000000000000000000001000,
0b00000011111000000001111111100100,
0b00000000000100000000010101010010,
0b00000000000100000000000010101001,
0b00000000001000000000000000000001,
0b00000000001000000000000111111110,
0b00000000000110000000000000000000,
0b00000000000001000000000000000000,
0b00000000000000001100000000000000,
0b00000000000000010010000000000000,
0b00000000000000100101000000000000,
0b00000000000000001000100000000000,
0b00000000000000000000100000000000,
0b00000000000000000001000000000000 },
{ 0b00000000000001111111111110000000,
0b00000000000010000000000000000000,
0b00000000000010000111111000100000,
0b00000000000010000000000100100000,
0b00000000000010000000000100100000,
0b00000100000010000000000100100000,
0b00001100000010000000000100100000,
0b00001000000010000000000100100000,
0b01100110000010000000000100100000,
0b10011001000010000000000100100000,
0b10000001000010001111111000100000,
0b10000000000010000000000000100000,
0b10000000000010000000000000100000,
0b01001010000000000001111100100000,
0b00110100000000000000000000100000,
0b00000000111111000000000000100000,
0b00000011000000000000000000000000,
0b00000100000000011111111111110000,
0b00000100000000000000000000001000,
0b00000011111000000001111111100100,
0b00000000000100000000010101010010,
0b00000000000100000000000010101001,
0b00000000001000000000000000000001,
0b00000000001000000000000111111110,
0b00000000000110000000000000000000,
0b00000000000001000000000000000000,
0b00000000000000001100000000000000,
0b00000000000000010010000000000000,
0b00000000000000100101000000000000,
0b00000000000000001000100000000000,
0b00000000000000000000100000000000,
0b00000000000000000001000000000000 },
{ 0x0, 65535, 65535, 65535,
0x1, 0, 0, 65535,
0x2, 65535, 65535, 0,
0x3, 0, 65535, 0,
0x4, 65535, 0, 0,
0x5, 0, 0, 0 },
{ $00000000000005555555555550000000",
$00000000000050000000000000000000",
$00000000000050000222222000500000",
$00000000000050000000000200500000",
$00000000000050000000000200500000",
$00000300000050000000000200500000",
$00003300000050000000000200500000",
$00003000000050000000000200500000",
$03300330000050000000000200500000",
$30033003000050000000000200500000",
$30000003000050002222222000500000",
$30000000000050000000000000500000",
$30000000000050000000000000500000",
$03003030000000000005555500500000",
$00330300000000000000000000500000",
$00000000444444000000000000500000",
$00000044000000000000000000000000",
$00000400000000055555555555550000",
$00000400000000000000000000005000",
$00000044444000000001111111100500",
$00000000000400000000010101010050",
$00000000000400000000000010101005",
$00000000004000000000000000000005",
$00000000004000000000000555555550",
$00000000000440000000000000000000",
$00000000000004000000000000000000",
$00000000000000005500000000000000",
$00000000000000050050000000000000",
$00000000000000500205000000000000",
$00000000000000002000500000000000",
$00000000000000000000500000000000",
$00000000000000000005000000000000" } };
Listing #3: cicnFun Source
{cicnFun- Sample Application to demonstrate Color Icons}
{Created by Steve Sheets for MacTutor}
program cicnFun;
var
N: INTEGER;
begin
InitCursor;
N := Alert(1000, nil);
end.