home *** CD-ROM | disk | FTP | other *** search
/ OpenStep (Enterprise) / OpenStepENTCD.toast / OEDEV / DEV.Z / SimpleImageFilter_main.m < prev    next >
Encoding:
Text File  |  1996-08-17  |  1.1 KB  |  37 lines

  1. /*
  2.  * Filter service example.
  3.  * This is a simple, NSUnixStdio type filter. 
  4.  * Author: Ali T. Ozer, NeXT Software, Inc.
  5.  * Written for 3.0, June 1, 1992.
  6.  * Rewritten for OpenStep, May 11, 1996.
  7.  *
  8.  * You may freely copy, distribute and reuse the code in this example.
  9.  * NeXT disclaims any warranty of any kind, expressed or implied, as to its
  10.  * fitness for any particular use.
  11.  */
  12.  
  13. #import <Foundation/Foundation.h>
  14. #import <AppKit/AppKit.h>
  15.  
  16. extern NSBitmapImageRep *bitmapImageRepFromIFF(NSData *iffData);
  17.  
  18. int main (int argc, const char *argv[]) {
  19.     NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
  20.     NSArray *args = [[NSProcessInfo processInfo] arguments];
  21.     NSData *data;
  22.     NSBitmapImageRep *tiff;
  23.     BOOL success = NO;
  24.  
  25.     if (args && ([args count] == 2) &&
  26.         (data = [NSData dataWithContentsOfFile:[args objectAtIndex:1]]) &&
  27.     (tiff = bitmapImageRepFromIFF(data)) &&
  28.     (data = [tiff TIFFRepresentation])) {
  29.     [[NSFileHandle fileHandleWithStandardOutput] writeData:data];
  30.         success = YES;
  31.     }
  32.  
  33.     [pool release];
  34.     exit(success ? 0 : 1); 
  35.     return 0;      // ...and make main fit the ANSI spec.
  36. }
  37.