| 43 | | |
|---|
| 44 | | @implementation FHImage |
|---|
| 45 | | |
|---|
| 46 | | + (id)imageNamed:(NSString *)name { |
|---|
| 47 | | NSImage *image; |
|---|
| 48 | | |
|---|
| 49 | | image = [NSImage imageNamed:name]; |
|---|
| 50 | | |
|---|
| 51 | | if(!image) |
|---|
| 52 | | return NULL; |
|---|
| 53 | | |
|---|
| 54 | | return [[[self alloc] initImageWithImage:image] autorelease]; |
|---|
| 55 | | } |
|---|
| 56 | | |
|---|
| 57 | | |
|---|
| 58 | | |
|---|
| 59 | | #pragma mark - |
|---|
| 60 | | |
|---|
| 61 | | - (id)initImageWithImage:(NSImage *)image { |
|---|
| 62 | | self = [super init]; |
|---|
| 63 | | |
|---|
| 64 | | _NSImage = [image retain]; |
|---|
| 65 | | _size = [_NSImage size]; |
|---|
| 66 | | |
|---|
| 67 | | return self; |
|---|
| 68 | | } |
|---|
| 69 | | |
|---|
| 70 | | |
|---|
| 71 | | |
|---|
| 72 | | - (id)initImageWithURL:(WIURL *)url { |
|---|
| 73 | | NSData *data; |
|---|
| 74 | | |
|---|
| 75 | | self = [super init]; |
|---|
| 76 | | |
|---|
| 77 | | data = [NSData dataWithContentsOfURL:url returningResponse:NULL]; |
|---|
| 78 | | |
|---|
| 79 | | if(!data) { |
|---|
| 80 | | [self release]; |
|---|
| 81 | | |
|---|
| 82 | | return NULL; |
|---|
| 83 | | } |
|---|
| 84 | | |
|---|
| 85 | | if(![self _initImageWithData:data]) { |
|---|
| 86 | | [self release]; |
|---|
| 87 | | |
|---|
| 88 | | return NULL; |
|---|
| 89 | | } |
|---|
| 90 | | |
|---|
| 91 | | return self; |
|---|
| 92 | | } |
|---|
| 93 | | |
|---|
| 94 | | |
|---|
| 95 | | |
|---|
| 96 | | - (id)initImageWithData:(NSData *)data { |
|---|
| 97 | | self = [super init]; |
|---|
| 98 | | |
|---|
| 99 | | if(![self _initImageWithData:data]) { |
|---|
| 100 | | [self release]; |
|---|
| 101 | | |
|---|
| 102 | | return NULL; |
|---|
| 103 | | } |
|---|
| 104 | | |
|---|
| 105 | | return self; |
|---|
| 106 | | } |
|---|
| 107 | | |
|---|
| 108 | | |
|---|
| | 43 | @implementation FHImage(Private) |
|---|
| | 81 | } |
|---|
| | 82 | |
|---|
| | 83 | @end |
|---|
| | 84 | |
|---|
| | 85 | |
|---|
| | 86 | @implementation FHImage |
|---|
| | 87 | |
|---|
| | 88 | + (id)imageNamed:(NSString *)name { |
|---|
| | 89 | NSImage *image; |
|---|
| | 90 | |
|---|
| | 91 | image = [NSImage imageNamed:name]; |
|---|
| | 92 | |
|---|
| | 93 | if(!image) |
|---|
| | 94 | return NULL; |
|---|
| | 95 | |
|---|
| | 96 | return [[[self alloc] initImageWithImage:image] autorelease]; |
|---|
| | 97 | } |
|---|
| | 98 | |
|---|
| | 99 | |
|---|
| | 100 | |
|---|
| | 101 | #pragma mark - |
|---|
| | 102 | |
|---|
| | 103 | - (id)initImageWithImage:(NSImage *)image { |
|---|
| | 104 | self = [super init]; |
|---|
| | 105 | |
|---|
| | 106 | _NSImage = [image retain]; |
|---|
| | 107 | _size = [_NSImage size]; |
|---|
| | 108 | |
|---|
| | 109 | return self; |
|---|
| | 110 | } |
|---|
| | 111 | |
|---|
| | 112 | |
|---|
| | 113 | |
|---|
| | 114 | - (id)initImageWithURL:(WIURL *)url { |
|---|
| | 115 | NSData *data; |
|---|
| | 116 | |
|---|
| | 117 | self = [super init]; |
|---|
| | 118 | |
|---|
| | 119 | data = [NSData dataWithContentsOfURL:url returningResponse:NULL]; |
|---|
| | 120 | |
|---|
| | 121 | if(!data) { |
|---|
| | 122 | [self release]; |
|---|
| | 123 | |
|---|
| | 124 | return NULL; |
|---|
| | 125 | } |
|---|
| | 126 | |
|---|
| | 127 | if(![self _initImageWithData:data]) { |
|---|
| | 128 | [self release]; |
|---|
| | 129 | |
|---|
| | 130 | return NULL; |
|---|
| | 131 | } |
|---|
| | 132 | |
|---|
| | 133 | return self; |
|---|
| | 134 | } |
|---|
| | 135 | |
|---|
| | 136 | |
|---|
| | 137 | |
|---|
| | 138 | - (id)initImageWithData:(NSData *)data { |
|---|
| | 139 | self = [super init]; |
|---|
| | 140 | |
|---|
| | 141 | if(![self _initImageWithData:data]) { |
|---|
| | 142 | [self release]; |
|---|
| | 143 | |
|---|
| | 144 | return NULL; |
|---|
| | 145 | } |
|---|
| | 146 | |
|---|
| | 147 | return self; |
|---|