Scaling TIFFRepresentation
Scaling TIFFRepresentation
- Subject: Scaling TIFFRepresentation
- From: Michael Briscoe <email@hidden>
- Date: Wed, 15 May 2002 11:25:13 -0700
Hello All,
I'm trying to add an export feature to my program, and it seems to work,
except for the scaling. At first I tried to scale the NSBitmapImageRep
data directly by setting it's size; all that did was to change it's
resolution (dpi). So then I created an NSImage using the
NSBitmapImageRep data, and scaled that. According to my NSLog that
appears to work, BUT the files are saved at the original screen size.
I'm stumped!
Here's my code:
// saveTIFFFrame
-(void) saveTIFFFrame:(int)frameNo
{
NSBitmapImageRep *imageRep;
NSData *tiffData;
NSImage *screenImage;
NSString *filename;
BOOL success;
NSSize imageSize;
float imageScale;
imageScale = 0.25;
[self lockFocus];
imageRep = [[[NSBitmapImageRep alloc]
initWithFocusedViewRect:[self frame]] autorelease];
[self unlockFocus];
if (imageRep) {
screenImage = [[[NSImage alloc] initWith
Data:[imageRep
TIFFRepresentation]] autorelease];
imageSize = [screenImage size];
imageSize.width = imageSize.width * imageScale;
imageSize.height = imageSize.height * imageScale;
[screenImage setScalesWhenResized:YES];
[screenImage setSize:imageSize];
imageSize = [screenImage size];
NSLog(@"screenImage size = width:%f height:%f", imageSize.width,
imageSize.height);
tiffData = [screenImage TIFFRepresentation];
filename = [[NSString stringWithFormat:@"%@ %d", qtPath,
frameNo] stringByAppendingPathExtension:@"tiff"];
NSLog(@"filename = %@", filename);
success = [tiffData writeToFile:filename atomically:NO];
NSLog(@"saveTIFFFrame: success = %d", success);
}
}
Any help would be appreciated!
Best Regards,
Michael Briscoe
SkyRocket Multimedia
http://www.digitalfireworks.com/SkyRocket/index.html
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.