File:  [NeXTSTEP 3.3 examples] / Examples / AppKit / Draw / Tiff.m
Revision 1.1.1.1 (vendor branch): download - view: text, annotated - select for diffs
Tue Apr 24 17:48:36 2018 UTC (8 years, 1 month ago) by root
Branches: NeXT, MAIN
CVS tags: NeXTSTEP33, HEAD
Sample Programs from NeXSTEP 3.3

#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, length+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

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.