home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
NeXTSTEP 3.0
/
NeXTSTEP3.0.iso
/
NextDeveloper
/
Examples
/
AppKit
/
Draw
/
Tiff.m
< prev
next >
Wrap
Text File
|
1992-02-09
|
960b
|
38 lines
#import "draw.h"
@implementation Tiff
- replaceWithImage
{
Image *retval = [[Image allocFromZone:[self zone]] initFromStream:newStream];
[retval setBounds:&bounds];
if (!gFlags.selected) [retval deselect];
if (gFlags.locked) [retval lock];
[self free];
return retval;
}
- read:(NXTypedStream *)stream
{
int length;
char *data;
NXImageInfo info;
[super read:stream];
NXReadTypes(stream, "iiiiii", &info.width, &info.height,
&info.bitsPerSample, &info.samplesPerPixel,
&info.planarConfig, &info.photoInterp);
length = info.height * (info.samplesPerPixel) * ((info.bitsPerSample * info.width + 7) / 8);
NX_ZONEMALLOC([self zone], data, char,RV9gth+1);
NXReadArray(stream, "c", length, data);
data[length] = '\0';
newStream = NXOpenMemory(NULL, 0, NX_READWRITE);
NXWriteTIFF(newStream, &info, data);
NXSeek(newStream, 0, NX_FROMSTART);
NX_FREE(data);
return self;
}
@end