home *** CD-ROM | disk | FTP | other *** search
/ Nebula / nebula.bin / SourceCode / MiniExamples / ScrollTiff / ImageReader.m < prev    next >
Text File  |  1991-04-21  |  1KB  |  42 lines

  1. /* ImageReader.m
  2.  *
  3.  * This file defines the image reading function that lets the user open 
  4.  * a file and display it on the screen.
  5.  *
  6.  * You may freely copy, distribute, and reuse the code in this example.
  7.  * NeXT disclaims any warranty of any kind, expressed or  implied, as to
  8.  * its fitness for any particular use.
  9.  */
  10.  
  11. #import <appkit/OpenPanel.h>    
  12. #import "ImageReader.h"
  13. #import "TiffDocView.h"
  14.  
  15. @implementation ImageReader
  16.  
  17. - readImage:sender
  18. {
  19.     id            op;
  20.     const char        *imageFile;
  21.     const char *const    tiffType[2] = {"tiff", NULL};
  22.  
  23.     /* 
  24.      Run the App's OpenPanel and get the name of the image file to load.
  25.      We filter for TIFF files for simplicity, but without the filter, this
  26.      would work for eps files as well.    See README.
  27.      */
  28.     op = [OpenPanel new];
  29.     [op runModalForDirectory:"~" file: NULL types:tiffType];
  30.     
  31.     /* Only try to read an image if one has been specified */
  32.     if (imageFile = [op filename])
  33.     {
  34.         [imageView readImageFile: imageFile];
  35.     }
  36.     
  37.     return self;
  38. }
  39.  
  40.  
  41. @end
  42.