home *** CD-ROM | disk | FTP | other *** search
/ OpenStep 4.2J (Developer) / os42jdev.iso / NextDeveloper / OpenStepConversion / IntermediateFrameworks3 / AppKit.framework / Headers / NSImageRep.h < prev    next >
Text File  |  1995-12-21  |  4KB  |  100 lines

  1. /*
  2.     NSImageRep.h
  3.     Application Kit
  4.     Copyright (c) 1988, 1989, 1990, NeXT, Inc.  All rights reserved. 
  5. */
  6.  
  7. #import <Foundation/NSObject.h>
  8. #import "NSGraphics.h"
  9.  
  10. @class NSPasteboard;
  11.  
  12. /* NSImageRepMatchesDevice indicates the value is variable, depending on the output device. It can be passed in (or received back) as the value of bitsPerSample, pixelsWide, and pixelsHigh.
  13. */
  14. enum {
  15.     NSImageRepMatchesDevice = 0
  16. };
  17.  
  18. @interface NSImageRep : NSObject <NSCopying> {
  19.     struct __repFlags {
  20.     unsigned int hasAlpha:1;
  21.     unsigned int :3;
  22.     unsigned int bitsPerSample:6;
  23.     unsigned int :3;
  24.     unsigned int dataLoaded:1;
  25.     unsigned int isOpaque:1;
  26.     unsigned int :0;
  27.     }                   _repFlags;
  28.     NSSize              size;
  29.     int                 _pixelsWide;
  30.     int                 _pixelsHigh;
  31.     int                 _gsaved;
  32.     NSString           *_colorSpaceName;
  33. }
  34.  
  35. /* Drawing methods. drawAtPoint: and drawInRect: go through draw after modifying the CTM.
  36. */
  37. - (BOOL)draw;
  38. - (BOOL)drawAtPoint:(NSPoint)point;
  39. - (BOOL)drawInRect:(NSRect)rect;
  40.  
  41. /* Methods to return info about the image. NSImageRep provides storage for all of these; however, it's illegal to set them in some subclasses.
  42. */
  43. - setSize:(NSSize)aSize;
  44. - (NSSize)size;
  45. - setAlpha:(BOOL)flag;
  46. - (BOOL)hasAlpha;
  47. - setOpaque:(BOOL)flag;
  48. - (BOOL)isOpaque;
  49. - (void)setColorSpaceName:(NSString *)string;
  50. - (NSString *)colorSpaceName;
  51. - setBitsPerSample:(int)anInt;
  52. - (int)bitsPerSample;
  53. - setPixelsWide:(int)anInt;
  54. - (int)pixelsWide;
  55. - setPixelsHigh:(int)anInt;
  56. - (int)pixelsHigh;
  57.  
  58. /* The rest of the methods all deal with subclassers which can read/write data in files or pasteboards. 
  59. */
  60.  
  61. /* Registry management: Subclasses which deal with file & pasteboard types should register themselves. These classes should also implement imageUnfilteredFileTypes, imageUnfilteredPasteboardTypes, initWithData:, canInitWithData:, imageRepWithData:, and, if they have the ability to read multiple images from a file, imageRepsWithData:. These last three should not do any filtering; all filtering is automatic.
  62. */
  63. + (void)registerImageRepClass:(Class)imageRepClass;
  64. + (void)unregisterImageRepClass:(Class)imageRepClass;
  65. + (NSArray *)registeredImageRepClasses;
  66. + (Class)imageRepClassForFileType:(NSString *)type;
  67. + (Class)imageRepClassForPasteboardType:(NSString *)type;
  68. + (Class)imageRepClassForData:(NSData *)data;
  69.     
  70. /* Should be overridden by subclassers to load an unfiltered image. 
  71. */
  72. + (BOOL)canInitWithData:(NSData *)data;
  73.  
  74. /* Implemented by subclassers to indicate what data types they can deal with.
  75. */
  76. + (NSArray *)imageUnfilteredFileTypes;
  77. + (NSArray *)imageUnfilteredPasteboardTypes;
  78.  
  79. /* These expand the unfiltered lists returned by imageUnfilteredFileTypes and imageUnfilteredPasteboardTypes.
  80. */
  81. + (NSArray *)imageFileTypes;
  82. + (NSArray *)imagePasteboardTypes;
  83.  
  84. /* Convenience method: Checks to see if any of the types on the pasteboard can be understood by a registered imagerep class after filtering or if the pasteboard contains a filename that can be understood by a registered imagerep class after filtering. If sent to a subclass, does this for just the types understood by the subclass.
  85. */
  86. + (BOOL)canInitWithPasteboard:(NSPasteboard *)pasteboard;
  87.  
  88. /* Convenience methods: Checks to see if the provided file or pasteboard types can be understood by a registered imagerep class after filtering; if so, calls imageRepsWithData: or imageRepWithData:. If sent to a subclass, does this just for the types understood by that subclass.
  89. */
  90. + (NSArray *)imageRepsWithContentsOfFile:(NSString *)filename;
  91. + (id)imageRepWithContentsOfFile:(NSString *)filename;
  92. + (NSArray *)imageRepsWithPasteboard:(NSPasteboard *)pasteboard;
  93. + (id)imageRepWithPasteboard:(NSPasteboard *)pasteboard;
  94.  
  95. @end
  96.  
  97. /* Notifications */
  98. extern NSString *NSImageRepRegistryDidChangeNotification;
  99.  
  100.