Mailing Lists: Apple Mailing Lists
Image of Mac OS face in stamp
Re: Flattening CGImageRef and CGDataProviderRef using CFPropertyListWriteToStream
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Flattening CGImageRef and CGDataProviderRef using CFPropertyListWriteToStream



Hi Scott,

Thanks for your code snippet. While I should have been sleeping last night I suddenly thought of another approach. Instead of reading the images into a provider from disk and then compressing them for storage in my document I am now reading in the data in using the file manager (that data is already compressed as PNG or JPEG) and storing that in my document. That way I am not de- and recompressing and stick to the format the user chose for each image. For display I draw it once in a bitmap context and use that each time an image needs to be drawn. The original PNG or JPEG data I keep around for when the user saves. Now I just need to add support for PDF in a similar way. looks like that will be sligthly more complicated than for PNG and TIFF, but it should not be too bad.

david.


At 17:04 -0600 9/3/05, Scott Thompson wrote:
On Mar 9, 2005, at 4:19 PM, David Niemeijer wrote:
Do you happen to have url to the documentation (or sample code) on this around? I see a lot of QT compression related stuff, but I guess you are referring to some particular APIs to use in combination with CG and the providers/consumers. Ideally I would like to store in PNG format.

The code I have that does this is as follows:


verify_noerr(QTNewDataReferenceFromFullPathCFString((CFStringRef) newString,


(QTPathStyle)kQTNativeDefaultPathStyle, 0, &dataRef, &dataRefType));

ComponentResult error = 0;
ComponentInstance exporter;
OpenADefaultComponent( GraphicsExporterComponentType, kQTFileTypePNG, &exporter);
check(exporter);
verify_noerr(GraphicsExportSetInputCGImage(exporter, cgImage));


verify_noerr(GraphicsExportSetOutputDataReference(exporter, dataRef, dataRefType));
verify_noerr(error = GraphicsExportDoExport(exporter, &actualSize));
CloseComponent(exporter);
DisposeHandle(dataRef);


Instead of creating a DataRef to a file you could look in the QuickTime documentation and figure out how to create a DataRef into a block of memory (probably a Handle) and then create the CFData from that handle.

Scott

_______________________________________________ Do not post admin requests to the list. They will be ignored. Quartz-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
References: 
 >Flattening CGImageRef and CGDataProviderRef using CFPropertyListWriteToStream (From: David Niemeijer <email@hidden>)
 >Re: Flattening CGImageRef and CGDataProviderRef using CFPropertyListWriteToStream (From: Derek Clegg <email@hidden>)
 >Re: Flattening CGImageRef and CGDataProviderRef using CFPropertyListWriteToStream (From: David Niemeijer <email@hidden>)
 >Re: Flattening CGImageRef and CGDataProviderRef using CFPropertyListWriteToStream (From: Scott Thompson <email@hidden>)
 >Re: Flattening CGImageRef and CGDataProviderRef using CFPropertyListWriteToStream (From: David Niemeijer <email@hidden>)
 >Re: Flattening CGImageRef and CGDataProviderRef using CFPropertyListWriteToStream (From: Scott Thompson <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2011 Apple Inc. All rights reserved.