• 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: C *char representation of PDF into NSImage
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: C *char representation of PDF into NSImage


  • Subject: Re: C *char representation of PDF into NSImage
  • From: Marcel Weiher <email@hidden>
  • Date: Sun, 25 Feb 2007 15:06:06 -0800


On Feb 25, 2007, at 9:08 , Eric Brown wrote:

-(void) awakeFromNib
{
    int            PDFDataLength;
    NSMutableData *PDFData;
    char          *PDFbuffer;
    char *oneChar=" ";

    NSPDFImageRep *pdfImage;

// obtain length of "%PDF...." The returned number is around 15000.
PDFDataLength=pdfbuf(oneChar,0);


    // I've seen this method used for floats, ints, etc.
    PDFData  =[[NSMutableData alloc]
                    initWithCapacity: (unsigned int) PDFDataLength];
    PDFbuffer=[PDFData mutableBytes];

    // Here I try to slurp in the data
    PDFDataLength=pdfbuf(PDFbuffer, PDFDataLength);

[PDFData setLength:PDFDataLength];

    // I'm not sure if this is relevant yet!
    pdfImage=[[NSPDFImageRep alloc] initWithData: PDFData];
    image=[[NSImage alloc] initWithData: PDFData];
}

A couple of style pointers: classes are typically uppercase, variables/instances lowercase. The pdfbuf() function appears a bit magical. You don't need to initialize both an NSImage and a NSPDFImageRep with the data. The NSImage will create an NSPDFImageRep internally, while the NSPDFImageRep can be converted if necessary.


Marcel

_______________________________________________

Cocoa-dev mailing list (email@hidden)

Do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


References: 
 >C *char representation of PDF into NSImage (From: Eric Brown <email@hidden>)

  • Prev by Date: Re: Implications of changing an app's bundle identifier
  • Next by Date: Re: How to track all window creation?
  • Previous by thread: C *char representation of PDF into NSImage
  • Next by thread: [ANN] Drop-Installable Subversion Server
  • Index(es):
    • Date
    • Thread