ftp.nice.ch/pub/next/graphics/movie/MovieApp.0.02.s.tar.gz#/Fun_With_Movies/MovieApp/MovieView.m

This is MovieView.m in view mode; [Download] [Up]

#import "MovieView.h"
#import "MovieApp.h"
#import <appkit/Bitmap.h>
#import <appkit/nextstd.h>
#import <appkit/Panel.h>
#import <appkit/Window.h>
#import <objc/List.h>
#import <streams/streams.h>

@implementation MovieView

/* creates a new MovieView instance */
+ newPath:(const char *)thePath Width:(int)w Height:(int)h NumFrames:(int)nf
{
	self = [super new];
	path = malloc(strlen(thePath));
	strcpy(path, thePath);
	width = w;
	height = h;
	currentFrame = 0;
	numFrames = nf;
	frames = calloc(numFrames, sizeof(id));
	return self;
}

/* show a frame, load it if necessary */
- showFrameNumber:(int)frameNumber
{
	NXStream       *theStream;
	NXPoint         zeroPoint = {0, 0};
	char            tempPath[128];

	if (frames[frameNumber] == NULL) {
		strcpy(tempPath, path);
		sprintf(&tempPath[strlen(tempPath)], "/%d.tiff", frameNumber);
		frames[frameNumber] = [Bitmap newFromTIFF:tempPath];
		if (frames[frameNumber] == NULL) {
			NXRunAlertPanel("Error", "Frame %d not found.",
					"OK", NULL, NULL, frameNumber);
			[window close];
			return self;
		}
	}
	currentFrame = frameNumber;
	[self lockFocus];
	[frames[currentFrame] composite:NX_COPY toPoint:&zeroPoint];
	[self unlockFocus];
	return self;
}

/* respond to inquiries */
- (int)numFrames
{ return numFrames; }
- (int)currentFrame
{ return currentFrame; }

/* clean up */
- free
{
	int             i;
	for (i = 0; i < numFrames; i++)
		if (frames[i])
			[frames[i] free];
	free(frames);
	free(path);
	return[super free];
}

@end

These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.