• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag
 

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: NSImageView PICTRepresentation?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSImageView PICTRepresentation?


  • Subject: Re: NSImageView PICTRepresentation?
  • From: email@hidden (Heinrich Giesen)
  • Date: Sun, 10 Oct 2004 12:47:01 +0200


On Oct 10, 2004, at 11:26 AM, George Lawrence Storm wrote:


I have read a fair amount on moving from PICT to PDF & other formats but not much on converting to PICT from other formats and nothing about automatic conversion using the pasteboard. Can someone please point me to the appropriate documentation.?

Sorry, I know of no documentation. I am a bit playing with pasteBoard ans wrote an
application to observe the behaviour of pasteBoard. So I found this conversion
by accident. But because it is not documented it may be subject for
changing in further after Panther systems.

Try this code snippet: (tested in my application)
(the path to imagefiles is hardcoded, please change)

NSPasteboard *pb = [NSPasteboard generalPasteboard];
NSBitmapImageRep *theRep;
NSData *pictData;
NSData *tiffData;

[pb declareTypes:[NSArray arrayWithObject:NSTIFFPboardType] owner:nil];

theRep = [NSImageRep imageRepWithContentsOfFile:@"/Users/heinrichgiesen/Pictures/ DSC01506.jpg"];
tiffData = [theRep TIFFRepresentation];
[pb setData:tiffData forType:NSTIFFPboardType];
pictData = [pb dataForType:NSPICTPboardType];
[pictData writeToFile:@"/Users/heinrichgiesen/Pictures/DSC01506.pict" atomically:YES];
// see if the data are correct:
NSLog( @"class is %@\n", NSStringFromClass( [NSImageRep imageRepClassForData:pictData] ) );

the answer is: *** [1533] class is NSPICTImageRep
looks good :-)

I think (if this really works) it could be a nice category for NSImageRep
(still not tested and without errorchecking):

@implementation NSImageRep( PICT )

- (NSData *) PICTRepresentationForImageRep:(NSImageRep *)rep
{
NSPasteboard *pb;

if( [rep respondsToSelector:@selector( PICTRepresentation )] )
return [rep PICTRepresentation];

if ( ! [rep respondsToSelector:@selector( TIFFRepresentation )] )
return nil;

pb = [NSPasteboard generalPasteboard]; // better use a private pasteboard !
[pb declareTypes:[NSArray arrayWithObject:NSTIFFPboardType] owner:nil];
[pb setData:[rep TIFFRepresentation] forType:NSTIFFPboardType];
return [pb dataForType:NSPICTPboardType];
}

@end

--
Heinrich Giesen
email : email@hidden


On Oct 10, 2004, at 11:26 AM, George Lawrence Storm wrote:

There is a much simpler way to create a NSPICTImageRep:

<snip>

[sender setData:[theRep TIFFRepresentation] forType:type];
}

There you are. You can now read data of type NSPICTPboardType from the pastBoard.
The pasteBoard did the conversion from TIFF to PICT for you.

I am confused, based on your placing the data returned from -TIFFRepresentation: how are you returning PICT data?

I have read a fair amount on moving from PICT to PDF & other formats but not much on converting to PICT from other formats and nothing about automatic conversion using the pasteboard. Can someone please point me to the appropriate documentation.?

-----

George Lawrence Storm
Macintosh Applications Development
Snohomish (Seattle), Washington
E-mail: <email@hidden>


_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden
References: 
 >RE: NSImageView PICTRepresentation? (From: George Lawrence Storm <email@hidden>)

  • Prev by Date: Re: NSImageView PICTRepresentation?
  • Next by Date: A little confused about concatenating NSAffineTransform
  • Previous by thread: RE: NSImageView PICTRepresentation?
  • Next by thread: NSFileManager and fileAttributesAtPath
  • Index(es):
    • Date
    • Thread