2 * Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights
7 * Reserved. This file contains Original Code and/or Modifications of
8 * Original Code as defined in and that are subject to the Apple Public
9 * Source License Version 1.1 (the "License"). You may not use this file
10 * except in compliance with the License. Please obtain a copy of the
11 * License at http://www.apple.com/publicsource and read it before using
14 * The Original Code and all software distributed under the License are
15 * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
16 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
17 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the
19 * License for the specific language governing rights and limitations
22 * @APPLE_LICENSE_HEADER_END@
25 * Dump a tiff file into a format that is easily
28 * Copyright 1993 NeXT, Inc.
29 * All rights reserved.
36 #import "BooterBitmap.h"
38 #define DEFAULT_CURSOR_NAME "ns_wait"
40 void printCursors(char *name, int bg_color, int use_c_mode)
44 bitmap = [[BooterBitmap alloc] init];
47 [bitmap setHeight:16];
48 [bitmap setColorDataBytes:64];
49 [bitmap setBgColor:bg_color];
50 [bitmap setTwoBitsPerPixelAlphaData:(unsigned char *)waitAlpha2];
52 sprintf(buf,"%s1",name);
53 [bitmap setTwoBitsPerPixelColorData:waitData2W1];
54 use_c_mode ? [bitmap writeAsCFile:buf] :
55 [bitmap writeAsBinaryFile:buf];
57 sprintf(buf,"%s2",name);
58 [bitmap setTwoBitsPerPixelColorData:waitData2W2];
59 use_c_mode ? [bitmap writeAsCFile:buf] :
60 [bitmap writeAsBinaryFile:buf];
62 sprintf(buf,"%s3",name);
63 [bitmap setTwoBitsPerPixelColorData:waitData2W3];
64 use_c_mode ? [bitmap writeAsCFile:buf] :
65 [bitmap writeAsBinaryFile:buf];
72 fprintf(stderr,"Usage: dumptiff [-b <bgcolor] [-c] [-C] [-o <ofile>] <tiff>\n");
73 fprintf(stderr,"-C prints cursor bitmaps\n");
74 fprintf(stderr,"-c creates files <tiff>.h and <tiff>_bitmap.h\n");
75 fprintf(stderr,"(default is to create binary .bitmap file)\n");
80 main(int argc, char **argv)
83 char buf[MAXPATHLEN], *file;
84 int vflag=0, errflag=0, pcursors=0, c, ret;
87 int bg_color = BG_COLOR;
89 char *output_name = NULL;
91 while ((c = getopt(argc, argv, "Ccvb:o:")) != EOF)
103 bg_color = atoi(optarg);
106 output_name = optarg;
113 if (pcursors && !errflag) {
114 if (output_name == NULL)
115 output_name = DEFAULT_CURSOR_NAME;
116 printCursors(output_name, bg_color, use_c_mode);
120 if (errflag || (optind != argc-1))
124 if (strcmp(file + strlen(file) - strlen(".tiff"), ".tiff") != 0)
125 sprintf(buf,"%s.tiff",file);
127 sprintf(buf,"%s",file);
128 bitmap = [[BooterBitmap alloc] initFromTiffFile:buf];
130 fprintf(stderr, "Could not create booter bitmap object\n");
133 [bitmap setBgColor:bg_color];
135 buf[strlen(buf) - strlen(".tiff")] = '\0';
136 if (output_name == NULL)
140 [bitmap writeAsCFile: output_name] :
141 [bitmap writeAsBinaryFile: output_name];