osx - How can I get the *original* data behind an NSImage? -


I have an example of NSImage which I have been assigned by the API whose implementation is' T control

I would like to get the original data ( NSData ), to make that data without NSImage Was converted into another representation / format (or otherwise "tampering") if the image was made from a file, then I would have to file a byte-by-byte with all the metadata and so on Amgri accurate, like. If the image was created with some arbitrarily NSData example I is exact, byte-by-byte-equivalent copy of that NSData

To be pedantic (since this is a problem which I have come), if NSIZ was created from animated GIF, give me a NSDT needs to be brought back which is actually the original animated GIF, unmolested.

Edit: I know that it is not strictly possible for all time for the NSImage s; How about the subset of images that were are definitely made from files and / or data?

I have yet to find a way to do this; Does anyone have any ideas?

I agree with Ken, and there is a subset of the terms (I know that this is a GIF Reads from a file) Nothing changes. Unless you have NSImage , a lot of things have already happened with the data. Coco does not like to catch a bunch of data in memory, which is not needed directly if you do not have an original CGImage ( NSImage ), You can actually be lucky and can find the data that you wanted in CGDataProviderCopyData

but if you are incredibly lucky, then do this work Try:

But how can you work, thinking that How can:

  • list of representations with -imagererepresentations .
  • Find the original that matches (hopefully is just one)
  • Code> CGImage with it with -CGImageForProposedRect: reference: hint < / Code>. You probably want a reset that matches the size of the image, and maybe I do not intercept.
  • Get the data provider with the CGImageGetDataProvider
  • Copy its data from CGDTetifier sender . (But I suspect that this will be the actual original data, including metadata, byte-to-byte.)

    There are the callbacks that will take you directly to the byte-pointers in internal data CGDataProvider (like CGDataProviderGetBytePointerCallback ), but I do not know any way to request a list of callback from an existing CGDataProvider . Usually, some quartz reaches, and we just pass during the creation.

    I strongly suspect that this is impossible.

  • Comments

    Popular posts from this blog

    php - PDO bindParam() fatal error -

    logging - How can I log both the Request.InputStream and Response.OutputStream traffic in my ASP.NET MVC3 Application for specific Actions? -

    java - Why my included JSP file won't get processed correctly? -