Saving PNG files from NSImage

2011-08-29 Thread Martin Linklater
Hi - I'm writing a texture atlasser and so far I have created an NSImage and composited by sub-images onto it using: -[NSImage drawAtPoint:fromRect:operation:fraction] Now as I understand it the way to save the resulting NSImage to a PNG file is to get the images 'representations' and and save

Re: Saving PNG files from NSImage

2011-08-29 Thread Martin Linklater
Thanks Marco. When I call representationUsingType I get this: -[NSCGImageSnapshotRep representationUsingType:properties:]: unrecognized selector sent to instance 0x100220610 2011-08-29 14:08:16.161 TexLifter[69386:407] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', r

Re: Saving PNG files from NSImage

2011-08-29 Thread Andy Lee
I don't know if this would be the most efficient way, but if you can get your image as a CGImageRef you can use the functions below. They work for me. You might want to handle errors better. There are tips at for getting a CGImageRef.

ARC + CF types

2011-08-29 Thread Thomas Davie
I'm not really very clear on how ARC and CF types are meant to interact yet, because of that I've managed to create some buggy code, could someone have a quick stare at this and tell me what I've misunderstood that's causing a segfault when adding to the mutable set: https://gist.github.com/117

Re: ARC + CF types

2011-08-29 Thread David Duncan
On Aug 29, 2011, at 7:20 AM, Thomas Davie wrote: > I'm not really very clear on how ARC and CF types are meant to interact yet, > because of that I've managed to create some buggy code, could someone have a > quick stare at this and tell me what I've misunderstood that's causing a > segfault w

Re: ARC + CF types

2011-08-29 Thread Dave Zarzycki
Thomas, Why not use a NSMutableSet and avoid the bridging casts entirely? davez On Aug 29, 2011, at 7:20 AM, Thomas Davie wrote: > I'm not really very clear on how ARC and CF types are meant to interact yet, > because of that I've managed to create some buggy code, could someone have a > qu

Re: ARC + CF types

2011-08-29 Thread Thomas Davie
Because NSMutableSet does not have the ability to specify a different version of equality – though as Mike Ash pointed out in #macdev, NSHashTable may well be appropriate. Thanks Thomas if (*ra4 != 0xffc78948) { return false; } ___ Cocoa-dev mailing

App updating

2011-08-29 Thread Dan Hopwood
Hi all, I have an app on the store that uses a wild card app ID. I want to release an update that integrates push notifications. I therefore need to create a new app ID and configure it for push but in Apple's documentation it says: "Use the same Distribution Provisioning Profile to build each ne

Re: Blocked in NSFileCoordinator

2011-08-29 Thread Kyle Sluder
Saving during loading will now deadlock on Lion, since you're trying to do a coordinated write while NSDocumentController still has a coordinated read on your file. Don't save while loading. Does -takkeEvent: happen in response to NSUndoManager notifications? Something could be poking the NSUnd

Re: Saving PNG files from NSImage

2011-08-29 Thread Mike Abdullah
This code is making the assumption that [reps objectAtIndex:0] is a bitmap image rep. NSImage makes no such guarantees. Points: - Walk through all the image reps, looking for the best bitmap - If no bitmap exists, you'll have to create one by drawing the image into a bitmap context - If you're w

Re: Saving PNG files from NSImage

2011-08-29 Thread Martin Linklater
Thanks for the info guys. The method below is working great. On 29 Aug 2011, at 14:38, Marco Tabini wrote: > Hi Martin— > > On 2011-08-29, at 9:11 AM, Martin Linklater wrote: > >> Thanks Marco. When I call representationUsingType I get this: >> > > You need to first convert the representatio

Re: Long delay of NSPopUpButton first click

2011-08-29 Thread Glenn L. Austin
If you use text drawing, your first click will be slow. That's the penalty of loading each font. That's why -- at least internally -- the menu code caches the image of each item, so that the second and subsequent displays of the menu will be quick. You really have two solutions -- pre-image eac

Re: Long delay of NSPopUpButton first click

2011-08-29 Thread Jens Alfke
On Aug 28, 2011, at 11:25 PM, Rimas M. wrote: > Well.. that worked. Generally. But those images must have transparent > background. And as I have discovered, when dealing with text drawing, that > causes loose of sub-pixels antialiasing. This is unacceptable. Will need to > use NSAttributedString

Re: ARC + CF types

2011-08-29 Thread Dave Zarzycki
Or, your code could subclass NSMutableSet and interpose the methods that add to the set. In other words, mentally separate "objects that are equal" from "objects that should be in the set". The former is an equality check, the latter is a policy decision. davez On Aug 29, 2011, at 7:37 AM, Th

Re: ARC + CF types

2011-08-29 Thread Thomas Davie
Doing that wouldn't magically use the more efficient equality check though without recoding NSMutableSet almost entirely, or… you know, using CFMutableSetRef and providing your own equality function. Thanks Tom Davie if (*ra4 != 0xffc78948) { return false; } On 29 Aug 2011, at 17:43, Dave Zarz

Re: Blocked in NSFileCoordinator

2011-08-29 Thread Gerriet M. Denkmann
On 29 Aug 2011, at 22:05, Kyle Sluder wrote: > Saving during loading will now deadlock on Lion, since you're trying to do a > coordinated write while NSDocumentController still has a coordinated read on > your file. Don't save while loading. > > Does -takkeEvent: happen in response to NSUndoMa

Re: ARC + CF types

2011-08-29 Thread Greg Parker
On Aug 29, 2011, at 9:43 AM, Dave Zarzycki wrote: > Or, your code could subclass NSMutableSet and interpose the methods that add > to the set. In other words, mentally separate "objects that are equal" from > "objects that should be in the set". The former is an equality check, the > latter is a

Re: Large over 100K pixel high ruler scroll view

2011-08-29 Thread wadeslists
> One warning about extremely large views is that at some point you will run > into floating-point rounding errors, since AppKit and CoreGraphics coords are > 32-bit floats and have only 24 bits of precision. Still, that should get you > to millions of pixels before the coords stop being pixel-a

UpdateSystemActivity(OverallAct) to prevent sleep in Lion...

2011-08-29 Thread R
I'm using UpdateSystemActivity(OverallAct) successfully to prevent sleep in Snow Leopard. Can anyone confirm that this works with Lion? thanks ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator commen

NSWindowController

2011-08-29 Thread koko
I have created a nib which contains a window. I have set the File's Owner to NSWindowController. I have connected the window outlet of File's Owner to the window defined in the nib. I do this: NSWindowController *wc = [[NSWindowController alloc] initWithWindowNibName:@"ProjectAdvisor"]; which

Re: NSWindowController

2011-08-29 Thread Jens Alfke
On Aug 29, 2011, at 3:51 PM, koko wrote: > I have created a nib which contains a window. I have set the File's Owner to > NSWindowController. > I have connected the window outlet of File's Owner to the window defined in > the nib. Don’t forget to wire the window’s delegate outlet up to the Fil

Re: NSWindowController

2011-08-29 Thread Ken Thomases
On Aug 29, 2011, at 6:13 PM, Jens Alfke wrote: > On Aug 29, 2011, at 3:51 PM, koko wrote: > >> I have created a nib which contains a window. I have set the File's Owner to >> NSWindowController. >> I have connected the window outlet of File's Owner to the window defined in >> the nib. > > Don’

Re: Large over 100K pixel high ruler scroll view

2011-08-29 Thread Julie Porter
On 8/29/11 1:17 PM, wadesli...@mac.com wrote: One warning about extremely large views is that at some point you will run into floating-point rounding errors, since AppKit and CoreGraphics coords are 32-bit floats and have only 24 bits of precision. Still, that should get you to millions of pix

Re: Large over 100K pixel high ruler scroll view

2011-08-29 Thread Graham Cox
On 30/08/2011, at 12:18 PM, Julie Porter wrote: > On 8/29/11 1:17 PM, wadesli...@mac.com wrote: >>> One warning about extremely large views is that at some point you will run >>> into floating-point rounding errors, since AppKit and CoreGraphics coords >>> are 32-bit floats and have only 24 bit

UIBarButtonItem exclusive touch

2011-08-29 Thread Leon Qiao
Dear all, The UI I made is like the system app "Contact", there's an "add" bar button on the navigation bar. And a table view where you can tap and enter the detail view. The problem is when the user tap the bar button item and the table view cell at the same time, it doesn't work well. The code

Re: Large over 100K pixel high ruler scroll view

2011-08-29 Thread Julie Porter
On 8/29/11 7:29 PM, Graham Cox wrote: Use Interface Builder to set up/design your interface. Add a custom NSView, set its class to your subclass. Place it inside a standard NSScrollView. In the -awakeFromNib method of the custom NSView subclass, set the frame size to what you need. The stand

Re: Saving PNG files from NSImage

2011-08-29 Thread Marco Tabini
Hi Martin— On 2011-08-29, at 8:18 AM, Martin Linklater wrote: > Can anyone point me in the right direction as to how to save my NSImage to a > PNG file ? Or some documentation which actually describes how to convert the > NSCGImageSnapshotRep into something I can save out ? I've spent a few hou

Re: Large over 100K pixel high ruler scroll view

2011-08-29 Thread Jens Alfke
On Aug 29, 2011, at 7:18 PM, Julie Porter wrote: > In some ways it is too bad I can not call the cocoa classes from a postscript > syntax, considering that the program already defines the data in arrays of > dictionaries. I think at one time there was interactive postscript on the > NEXT. No

Re: Large over 100K pixel high ruler scroll view

2011-08-29 Thread Julie Porter
On 8/29/11 9:01 PM, Jens Alfke wrote: On Aug 29, 2011, at 7:18 PM, Julie Porter wrote: In some ways it is too bad I can not call the cocoa classes from a postscript syntax, considering that the program already defines the data in arrays of dictionaries. I think at one time there was interac

Re: Large over 100K pixel high ruler scroll view

2011-08-29 Thread Graham Cox
On 30/08/2011, at 12:54 PM, Julie Porter wrote: > I already have the NSDocument.m which loads the array of dictionaries from > the file. Do I place the awakefrom nib in that set of class files, or would > they go into the file that I would derive from NSView called cisView.m? > > Do I need t

drag and drop not working between windows on 10.7

2011-08-29 Thread Michael Link
I have a document based app that has a source list (NSOutlineView) that allows drag and drop on itself or another source list (same class) in a different document in the same application. Everything works on 10.6, in 10.7 drags to the same NSOutlineView are validated as I expect. Drags to the o

Re: UIBarButtonItem exclusive touch

2011-08-29 Thread Conrad Shultz
Sorry, I don't have time right now to fully respond, but first thing's first: UIKit is generally not thread-safe, so you should not invoke user interface actions (like popping a nav controller) on a secondary thread. This is a situation where GCD can make your life a lot simpler (with nested d

Re: UIBarButtonItem exclusive touch

2011-08-29 Thread Leon Qiao
Hi, Thanks for your response ! I missed something.In the thread method "saveTheData", I do call the popToRootViewController on the main thread by using "performSelectorOnMainThread:". It seems that both of the two functions(saveAction: and tableView's delegate method) are invoked. And the navigat