Confusion about -isFlipped in Cocoa - Printable Version
+- iDevGames Forums (http://www.idevgames.com/forums)
+-- Forum: Development Zone (/forum-3.html)
+--- Forum: Graphics & Audio Programming (/forum-9.html)
+--- Thread: Confusion about -isFlipped in Cocoa (/thread-4401.html)
Confusion about -isFlipped in Cocoa - ThemsAllTook - Mar 30, 2006 07:19 AM
I'm working on a graphics program, and having a bit of trouble getting a grasp on my coordinate system. My intention is to have the drawing origin in the upper left corner. Internally, bitmap contents are stored as arrays of unsigned char. I draw them to the document window's view with NSDrawBitmap, as follows:
Does anyone know what could be happening here? Does NSDrawBitmap draw things upside-down in relation to the rest of Quartz, or anything like that? Unless I'm missing something, what I'm seeing is the opposite behavior as the documentation would indicate.
Confusion about -isFlipped in Cocoa - KittyMac - Mar 30, 2006 08:18 AM
Have you checked to see if you are a subview of another flipped view, hence re-flipping your flipped view?
Confusion about -isFlipped in Cocoa - ThemsAllTook - Mar 30, 2006 11:32 AM
Shouldn't be possible. My document window is currently nothing more than an NSWindow with a single NSView subclass inside it.
Confusion about -isFlipped in Cocoa - OneSadCookie - Mar 30, 2006 01:20 PM
I thought that NSDrawBitmap ignored the Quartz coordinate system and does a simple blit to the window...
Confusion about -isFlipped in Cocoa - ThemsAllTook - Mar 30, 2006 08:04 PM
I tried drawing my image to the window with NSBitmapImageRep/NSImage instead of NSDrawBitmap, and it gave me the same behavior.
Another piece in the puzzle: It turns out that I'm currently flipping the Y coordinate on all incoming events. If I don't do this, the Y axis on incoming events runs whichever way is opposite to the Y axis for drawing.
What the heck is going on?
Confusion about -isFlipped in Cocoa - ThemsAllTook - Mar 30, 2006 08:51 PM
I think I understand what's happening now. According to #macdev, it seems that bitmaps are upside-down relative to the rest of Quartz. This seems crazy, but it's consistent with what I'm seeing.
This kind of thing makes me want to go back to QuickDraw. At least things made some amount of sense there.
Confusion about -isFlipped in Cocoa - SethWillits - Mar 30, 2006 10:08 PM
I haven't been following this much at all, but just to ask, is there any reason you really need to fight against Quartz vs use it as is?
Confusion about -isFlipped in Cocoa - ThemsAllTook - Mar 31, 2006 07:55 AM
Why do you think I'm fighting against it? I'm just trying to get it to work.
If you're talking about the fact that I'm using an array of raw pixels internally rather than an NSImage, then yes, I have reasons for doing it that way. I need pixel-level access at all times, and NSImage doesn't appear to give that to me very easily. I'm assuming that I could add an NSBitmapImageRep to it, and access its pixels from -bitmapData, but why jump through those hoops unnecessarily? I don't need any of NSImage's capabilities, so it would be a complete waste to use it unless there was no simpler way to do what I need to do. It also looks as though going through NSBitmapImageRep/NSImage would be slow down my drawing noticeably, which would be unacceptible in this situation.
I'm simply using the right tool for the job.