Save NSView as TIFF

Discussion in 'Mac Programming' started by Darkroom, Jul 2, 2008.

  1. Guest

    Darkroom

    Joined:
    Dec 15, 2006
    Location:
    Montréal, Canada
    #1
    this isn't working right now, but i think i'm on the right path... maybe i just have something small missing from the method?

    it's an IBAction method. user activates the actions, the NSView is suppose to convert into a TIFF and save itself to the desktop.

    Code:
    -(IBAction)saveViewToDesktop:(id)sender
    	{
    	[self lockFocus];
    	NSBitmapImageRep *rep = [[NSBitmapImageRep alloc] initWithFocusedViewRect:[self bounds]];
    	[self unlockFocus];
    	NSData *data = [rep TIFFRepresentation];
    	NSString *filePath = @"/Users/[I]myrealname[/I]/Desktop/";
    	[data writeToFile:filePath atomically:YES];
    	}
    
     
  2. thread starter Guest

    Darkroom

    Joined:
    Dec 15, 2006
    Location:
    Montréal, Canada
    #2
    i wrote over my old post with this post. i had found the answer before anyone responded.
     
  3. Moderator emeritus

    robbieduncan

    Joined:
    Jul 24, 2002
    Location:
    London
    #3
    The answer being that you didn't provide a file name in the path you were saving to?
     
  4. thread starter Guest

    Darkroom

    Joined:
    Dec 15, 2006
    Location:
    Montréal, Canada
    #4
    omg... ha... that was very special of me wasn't it :p

    thanks robbieduncan :)
     

Share This Page