PDA

View Full Version : #import <KillMeNow/KillMeNow.h>




zeppenwolf
Dec 13, 2009, 02:19 PM
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. :)

// 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 );

}



Cromulent
Dec 13, 2009, 02:26 PM
A slash just denotes a different folder. It is just a relative path basically.

#import is just the same as #include except that it makes sure to only include files once.

Guiyon
Dec 13, 2009, 02:53 PM
Have you added/tried adding the ApplicationServices framework to the project?

lloyddean
Dec 13, 2009, 02:57 PM
Change 'CGDataProvider' to 'CGDataProviderRef' and you'll be much less unhappy!

chown33
Dec 13, 2009, 03:00 PM
*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/library/DOCUMENTATION/MacOSX/Conceptual/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.

zeppenwolf
Dec 13, 2009, 07:13 PM
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
Dec 13, 2009, 08:01 PM
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.

zeppenwolf
Dec 13, 2009, 09:26 PM
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.

Detrius
Dec 13, 2009, 11:35 PM
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 (http://eshop.macsales.com/OSXCenter/XPostFacto/Framework.cfm?page=Compatibility.html) get these running newer versions of OS X.