Linking to ImageIO and Errors

Member
Posts: 64
Joined: 2005.06
Post: #1
Maybe I'm thinking about this a little too hard, but how in the name of all that is holy, link to ImageIO?

I'm trying #import <ImageIO/ImageIO.h>, but it just gives me this error: Command /usr/bin/gcc-4.0 failed with exit code 1.

Also, from the looks of it, even though I added the ImageIO framework stored inside the ApplicationServices framework (my computer has 5 different versions, all stored in seemingly random places, I have no idea how they all got created), it says its trying to link to a copy of ImageIO in the trashcan...? What's going on?
Quote this message in a reply
Member
Posts: 64
Joined: 2005.06
Post: #2
Nevermind, I figured out what was happening. Idiot me, was trying to link to ImageIO directly instead of just linking to ApplicationServices. Apparently XCode doesn't handle that very well and it completely choked.

I actually have it working now, I just have to figure out how to flip the OpenGL context so textures are drawn right-side up.

Oh, and thanks to OSC for turning me onto ImageIO; it only works in 10.4+, but its much nicer than the Quicktime APIs and the raw data-copy method I was using before had to essentially be hacked together to work.
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #3
You should be able to set the transformation matrix on the CGBitmapContext to flip the image as it's drawn.
Quote this message in a reply
Apprentice
Posts: 17
Joined: 2006.02
Post: #4
Alternatively, just swap your texture 'v' coordinates. Instead of the top being 0.0, make the top 1.0 and the bottom 0.0.

EDIT: if setting the transformation matrix allows the image to be flipped before uploading it to the OpenGL, then that's gonna be the better way to do it. I don't know how ImageIO works though, and a quick scan of the xcode docs doesn't reveal much.
Quote this message in a reply
Member
Posts: 64
Joined: 2005.06
Post: #5
I'm using glPixelZoom(1.0f, -1.0f) to try and flip the projection (which all the documents says it does), but nothing happens onscreen, there's just no change.
Quote this message in a reply
DoG
Moderator
Posts: 869
Joined: 2003.01
Post: #6
Just use the texture matrix to do the transformation, it is easily done. translate by +1.0 in y and set the y-vector to (0.0, -1.0, 0.0), upload to OpenGL, and enjoy.
Quote this message in a reply
Member
Posts: 64
Joined: 2005.06
Post: #7
To update, I found a way to flip the image using ImageIO:
Code:
CGContextConcatCTM(context, CGAffineTransformMakeScale(1.0, -1.0));
CGContextTranslateCTM(context, 0.0, -height);

But, I figured that it's probably much more processor intensive than just flipping the coordinate system in OpenGL, so ended up coming up with this:
Code:
glScalef(1.0f, -1.0f, 1.0f);
glTranslatef(0, -[self bounds].size.height, 0);

I don't know why it took so long to find out how to do that by searching the web, but it did.
Quote this message in a reply
Apprentice
Posts: 17
Joined: 2006.02
Post: #8
glPixelZoom only affects glDrawPixels and glCopyPixels, which I doubt is how you're drawing your images :-p

And as far as flipping the image during rendering goes, it's much simpler to just flip your vertical texture coordinates. Instead of the bottom being 0.0 and the top being 1.0, make the top 0.0 and the bottom 1.0.
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  ImageIO texture loader crashing - Cocoa mahalis 4 3,118 Aug 16, 2006 07:33 AM
Last Post: djork
  SDL causing linking errors. unknown 1 2,291 Feb 26, 2006 10:12 AM
Last Post: unknown
  Wierd Linking Errors Sta7ic 2 2,722 Aug 13, 2002 07:47 AM
Last Post: Sta7ic