quartz-graphics

Is anything required to get a Quartz callback besides registering for it?

I'm trying to use CGDisplayRegisterReconfigurationCallback to get display reconfiguration events in Quartz on Mac OS X. Here's the super-simple code: void CB(CGDirectDisplayID display, CGDisplayChangeSummaryFlags flags, void *userInfo) { std::cout << "In callback!" << std::endl; } int main (int argc, char * const argv[])...

How to set order of display in Objective-C

Hey there, I'm trying to mix between UIImageView drawing and line drawing using CGContext path draw commands, but the draw order is not correct. I need to draw the path on top of the images but get the reverse. The way I implemented it: Setting UIImage within a UIImageView and adding the UIImageView as a subview of the main view. Ne...

Beginner iphone question: drawing a rectangle. What am I doing wrong?

Trying to figure out what I'm doing wrong here. Have tried several things, but I never see that elusive rectangle on the screen. Right now, that's all I want to do -- just draw a single rectangle on the screen. I'm getting an "invalid context" on everything but the CGContextSetRGBFillColor(). Getting the context after that seems kind...

How to create a colored 1x1 UIImage on the iPhone dynamically?

I would like to create a 1x1 UIImage dynamically based on a UIColor. I suspect this can quickly be done with Quartz2d, and I'm poring over the documentation trying to get a grasp of the fundamentals. However, it looks like there are a lot of potential pitfalls: not identifying the numbers of bits and bytes per things correctly, not sp...

iphone: delegate questions (I think)

I've taken some stuff from Apple's QUartzDemo project and am trying to modify it. I want to create a screen with a button that will then call the rest of the stuff to make the rectanlges from that demo. I've created a UIViewController that handles my initial view. It has a start button on it. The start button code is: - (IBAction)st...

pushViewController problem...

I create a UIViewController with a button on it. The button's only job is to create a window for drawing some rectangles. (I've taken some code from "QuartzDemo" from Apple's example applications.) Objective C is really giving me fits... When I try this, nothing happens. Here's the code for the button: - (IBAction)startButtonAct:(i...

What is the best way to change the color "pixel by pixel" on iPhone?

Hi, I have a game which is an iPhone adaptation of this game. Here my ship makes paths and then the enclosed path gets filled if there is no enemy present in that enclosed area. I have taken the playField as a 2D array (int playField[300][300]). When the color of the enclosed path needs to be changed to show that it is filled, the p...

Calling setNeedsDisplay on a UIView from another class

I have a UIView subclass that I manipulate a lot of graphics on based on touches. All the [self setNeedsDisplay] calls seem to be fine. However, I used an instance variable pointer to my same UIView subclass instance, and then tried manipulating it and then calling [UIViewSubClass setNeedsDisplay] from another UIView class, and DrawRe...

On iPhone, what is the best way to move a UIImageView with onscreen controls?

Hi, I am developing an iPhone version of this game. http://www.students.uni-mainz.de/rathb000/Fillit/Game.html I am using an NSTimer to change the position of the ship by 1 pixel and the time interval for the timer is 0.002. However, i have noticed that the ship doesnt move faster if i reduce the time interval furthur. Infact, there...

iPhone: Transforming an image using Quartz 2D

I am trying to apply some transformations on images using a CGContextRef. I am using CGContextTranslateCTM, CGContextScaleCTM and CGContextRotateCTM functions, but to keep things simple lets focus on just the first. I was wondering why the following code produces exactly the original image?! Am I missing something? CGColorSpaceRef color...

recreating streetview effect in my own iPhone App

Hi all, My app allows you too "look" around a room in avery similar manner to how you can "look" around a street when you are in streetview in the Maps application. Does anyone know of a simple way to recreate this effect? I do have an image (like the streetview image) that I would like users to look around in. Some ideas I have: 1)...

Retrieving a pixel alpha value for a UIImage

I am currently trying to obtain the alpha value of a pixel in a UIImageView. I have obtained the CGImage from [UIImageView image] and created a RGBA byte array from this. Alpha is premultiplied. CGImageRef image = uiImage.CGImage; NSUInteger width = CGImageGetWidth(image); NSUInteger height = CGImageGetHeight(image); CGColorSpaceRef col...

How to "flick" a UIImageView?

I've got some UIViews that I'd like the user to be able to "flick" across the screen. They're not scroll views. They simply contain a raster image (png). Can anyone point me to some sample code, etc to help get me started? Something a little more heavyweight than "MoveMe" out there that helps detect a "flick" (vs a "nudge" or a drag and...

iPhone: why isn't drawRect getting called?

Okay, I guess I'm missing something important, and I can't seem to find the answer. I'm posting all the code, because it's very small. Can someone please tell me what I'm doing wrong? I've worked on this looking at example after example, for quite a while, and nothing I do seems to work. When I create the app, I use whichever skeleto...

Is it possible to alter the letter-spacing/kerning of a font with Cocoa Touch?

I've been scouring the Internet for a while now for information on how one can alter the letter-spacing/kerning of a font within UIKit. My fear is, that like using your own custom fonts, you simply can't. Which would be terrible news. I know Apple is protecting us from bad design with these constraints, but they're also preventing us f...

Cocoa: Quartz, Core Graphics, Context vs View. Oh My!

Heads starting to hurt. I think I dropped into this too fast... Perhaps someone could help me visualize how these (excluding OpenGL ES) high level drawing libraries fit together - or point me to some high level docs. For example I see "context" and "view" used interchangeably in some cases but a view has one (only one?) context while a c...

Two images intersection transparency

There are two images. image1 and image2. I have added image2 on image1. Overall the output image must be image1 only but, the portion of the image2 must become transparent. I mean the alpha values on the intersection area must be in reverse order( i.e, if alpha value of one pixel( say 120, 100) on image2 is 1.0 then the same pixel's alph...

Setting apple.awt.graphics.UseQuartz to false for applets with Apple's 1.5 update 4

Apple seems to have quart rendering on by default: http://lists.apple.com/archives/Java-dev/2007/Jun/msg00066.html However there are cases where this is attrociously slow. From a desktop app, I merely add: -Dapple.awt.graphics.UseQuartz=false This fixes the slow rendering. But there's isn't a place in the Java preferences panel to se...

My UIViewController is "lying" about its center property

I'm asking my ViewController for it's view.center property and drawing a new UIView that centers itself around this "center"... I am getting (160, 250) as a response. but when the new UIView draws it's below center... So I'm wondering who's giving me this info and what it relates to? This is clearly where the center of the view is in re...

openGL ES textures from PNGs with transparency are being rendered with weird artifacts and driving me nuts!

Hello everybody! I am beginning to work on my first OpenGL iPhone app, but I've hit an early snag. I have a VERY SIMPLE little texture that I want to use as a sprite in a 2D game, but it renders with weird 'randomly' colored pixels up top. http://i40.tinypic.com/2s7c9ro.png <-- Screenshot here I sort of get the feeling that this is P...