Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

zeppenwolf

macrumors regular
Original poster
Nov 17, 2009
129
3
I am trying to compile the function pasted below. I copied it from "Quartz 2D Primer" or somesuch, as it does exactly what I think I need.

( And when I say, "copied", I mean I had to type to whole thing myself, as the text was not 'selectable' in the PDF. Heh. Thx, Apple )

So I'd like to just compile this one file. It contains references to "CGDataProvider" etc, which are undefined without appropriate includes.

Ok, fine. I loate the file which defines "CGDataProvider", and attempt to include it:

#import <CGDataProvider.h>

But that doesn't work. Fine. So I try:

#import <CoreGraphics/CGDataProvider.h>

But that doesn't work. Fine. So I try:

#import <CoreGraphics/CoreGraphics.h>

But that doesn't work.

*Excuse me*, but what the heck is going on with this new goofy magic with "import" and the whole slash thing? I know exactly which file contains the definition, but I can't include it... Where is this goofiness documented?? Aaaargh/Thx. :)

Code:
// iWidth			width of bitmap
// iHeight			height of bitmap
// iBytesPerRow		number of bytes per row, given by GetPixRowBytes()
// contextR			a Core Graphics context to draw the image to

void	Draw32BitARGBToContext( void* iBitsP, size_t iWidth, size_t iHeight, size_t iBytesPerRow, CGContextRef contextR ) {

	CGRect			rectangle;
	CGDataProvider	provider;
	CGColorSpaceRef	colorSpace;
	size_t			size;
	CGImageRef		image;

	size		= iBytesPerRow * height;

	// Create a data provider with a pointer to the memory bits
	provider	= CGDataProviderCreateWithData( NULL, iBitsP, size, NULL );

	// Colorspace can be device, calibrated, or ICC profile based
	colorSpace	= CGColorSpaceCreateDeviceRGB();

	// Create the image
	image		= CGImageCreate( iWidth, iHeight,
					8,		// bitsPerComponent
					32,		// bitsPerPixel
					iBytesPerRow, colorSpace, kCGImageAlphaFirst, provider, NULL, 0, kVGRenderingIntentDefault );

	//	Once the image is created we can release our reference to the provider and the colorspace.
	// They will be retained by the image.
	CGDataProviderRelease( provider );
	CGColorSpaceRelease( colorSpace );

	// Determine the location where the image will be drawn in userspace.
	rectangle	= CGRectMake( 0, 0, iWidth, iHeight );

	//	Draw the image to the Core Graphics context
	CGContextDrawImage( context, rectangle, image );

	CGImageRelease( image );

}
 
*Excuse me*, but what the heck is going on with this new goofy magic with "import" and the whole slash thing? I know exactly which file contains the definition, but I can't include it... Where is this goofiness documented??

http://developer.apple.com/mac/libr...l/BPFrameworks/Tasks/IncludingFrameworks.html

And when I say, "copied", I mean I had to type to whole thing myself, as the text was not 'selectable' in the PDF. Heh. Thx, Apple


Which OS version are you using? What PDF reader? I just downloaded "Quartz Primer.pdf" containing Draw32BitARGBToContext source from here:

ftp://ftp.sfu.ca/pub/mac/OSX/QuartzPrimer.pdf

The source text was selectable and copy-pasteable on 10.5 Leopard and 10.6 Snow Leopard using Preview.app as the PDF reader.
 
Ok guys, thanks for the help. Apparently, "ApplicationServices" is an "umbrella" framework, and I am not allowed to directly include files from frameworks inside it... I have to say, I'm not surprised I didn't figure that one out.

chown33, I'm on OS 10.2.8 Heh. Yes, things may have advanced by now, but I assure you the text is not selectable on the pdf which comes with that era's Dev CD's. But hey-- at least I'm catching up!! :)
 
chown33, I'm on OS 10.2.8 Heh. Yes, things may have advanced by now, but I assure you the text is not selectable on the pdf which comes with that era's Dev CD's. But hey-- at least I'm catching up!! :)

For future reference, you might at least mention that you're using an extremely old OS version. It does have a direct bearing on what you will be able to do.

You should also specify what tool you're using. Acrobat Reader can select text on 10.2.8; Preview.app cannot. Acrobat Reader 5.0 should be a standard part of the OS install.

http://www.mikeash.com/getting_answers.html

Booting up my ancient PowerPC machine under 10.2.8, I see Acrobat Reader 5.0 located in the /Applications folder. I drag Quartz Primer.pdf onto it and it runs. I see a Text Select tool in Acrobat Reader's toolbar. I choose it and select text, then copy and paste. It all works fine.

Edit: I just rebooted the PPC to 10.3.5, and Preview.app can select, copy, and paste text in PDFs. You should consider upgrading to something a little less obsolete than 10.2.8.
 
Edit: I just rebooted the PPC to 10.3.5, and Preview.app can select, copy, and paste text in PDFs. You should consider upgrading to something a little less obsolete than 10.2.8.

Someday, hopefully someday soon, I will have a newer machine.

Not a 'new' machine, but a 'newer' machine.

Meanwhile, the machine I am on cannot be upgraded past 10.2.8, not by motherboard upgrade, not by anthying. It is absolutely impossible, according to Apple. And purchasing a 'new' machine is absolutely impossible, according to my finances.

I apologize if I have wasted anyone's time or led anyone down the wrong path; I will remember to mention my OS / tool versions in the future. I didn't think it was an issue in this thread. Thanks again for the help.
 
Meanwhile, the machine I am on cannot be upgraded past 10.2.8, not by motherboard upgrade, not by anthying. It is absolutely impossible, according to Apple. And purchasing a 'new' machine is absolutely impossible, according to my finances.

To install OS X on older unsupported machines:
http://eshop.macsales.com/OSXCenter/XPostFacto/

So, from my research, this would mean you're running either a Beige PowerMac G3 or a non-Pismo PowerBook G3. Wow. Ancient. Incredibly ancient. But yes, XPostFacto can get these running newer versions of OS X.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.