0

HI,

I am using following code to convert view into image format:

- (void)printViewToPNG
{
 NSData *data;
 NSBitmapImageRep *rep;

 NSDictionary *properties;

 rep = [self bitmapImageRepForCachingDisplayInRect:[self frame]];
 [self cacheDisplayInRect:[self frame] toBitmapImageRep:rep];
 data = [rep TIFFRepresentation];
 properties = [NSDictionary dictionaryWithObject:[NSNumber numberWithBool:NO] forKey:NSImageInterlaced];
 data = [rep representationUsingType:NSPNGFileType properties:properties];
 [data writeToFile:[NSHomeDirectory() stringByAppendingPathComponent:@"Desktop/test.png"] atomically:YES];
}

But it gives me errors at NSBitmapImageRep and NSImageInterlaced. I have used the class framework Appkit.framework but not getting specific class that help to remove the errors.

Updated : I am getting errors like : NSBitmapImageRep & NSImageInterlaced undeclared. then on the line data = [rep representationUsingType:NSPNGFileType properties:properties]; i m getting NSPNGFileType undeclared.

Any solution for this?

Thanking you.

Yama Puvar
  • 2,658
  • 3
  • 30
  • 62
  • 2
    What are the exact errors you are getting? – Nathan Kinsinger Dec 16 '10 at 15:54
  • The code compiles for me (though it probably doesn't do exactly what you want). You shouldn't have to add AppKit if you are creating a GUI app. What type of project are you building? Did you start with one of Apple's project templates? If not how did you create the project? – Nathan Kinsinger Dec 17 '10 at 16:27
  • Sorry for the late reply,I have taken view based template.Actually I need to convert the pdf page to image and in that process it's giving me error with the code above. Any solution? – Yama Puvar Jan 10 '11 at 07:22

0 Answers0