Question about UIImage, scaling, and UIGraphicsBeginImageContextWithOptions

2012-03-27 Thread Ray
OK, so I have this iOS 3.x code base that I need to update. I have the following code, to make a thumbnail image: ... // let's say we have a UIImage *selectedImage with a size of 1000 x 1000 UIImage *newImage; NSData *imageData; UIGraphicsBeginImageContext(CGSizeMake(44.0, 44.0)); [selectedImage

Re: How to throttle rate of NSInputStream?

2012-03-27 Thread Ken Thomases
On Mar 26, 2012, at 6:13 PM, Jens Alfke wrote: > What can I do about this? Ideally I’d like the stream to hold off on reading > more from the socket until my code finishes processing the buffer. You can try simply unscheduling the stream from the run loop until you're ready for more. I'm not 1

Re: Question about UIImage, scaling, and UIGraphicsBeginImageContextWithOptions

2012-03-27 Thread Giacomo Tufano
Il giorno 27/mar/2012, alle ore 09:38, Ray ha scritto: > OK, so I have this iOS 3.x code base that I need to update. I have the > following code, to make a thumbnail image: > Code is simplified, just for illustrative purposes. I store imageData as a > binary property (called "listImage") in a Co

Re: How to throttle rate of NSInputStream?

2012-03-27 Thread jonat...@mugginsoft.com
On 27 Mar 2012, at 00:13, Jens Alfke wrote: > (And there’s also the fact that CFNetwork must be buffering megabytes of > data from the socket that my code hasn’t read yet.) The network stack is there to deal with all this so I wouldn't fret about it. > > This seems to hinge on the way the str

Re: Question about UIImage, scaling, and UIGraphicsBeginImageContextWithOptions

2012-03-27 Thread Ray
Thanks Giacomo for your answer, but the problem is not so much that the resizing doesn't work, but that [UIImage imageWithData:listImage] always returns a scale of 1.0 for the image. This means that I encounter the problem described, when images are saved using an iPhone with a retina screen...

PDFKit: translate point coordinates from view coordinates into page coordinates

2012-03-27 Thread Nick
Hello I would like to place a PDFAnnotation onto a PDF page in a place where the user clicked with the mouse. Position for PDFAnnotations is specified using "page coordinates". Mouse position - using global coordinates, which can be translated into PDFView coordinates. However, I can't figure out

Re: Question about UIImage, scaling, and UIGraphicsBeginImageContextWithOptions

2012-03-27 Thread Marco Tabini
Hi Ray— > But this seems kludgy and it's using programmer's knowledge, so to speak. I > watched WWDC2010 session 134 "Optimize your iPhone App for the Retina > Display" again, searched stackoverflow etc. but I can't find a more elegant > solution. What would be a more thorough approach? Maybe i

Re: PDFKit: translate point coordinates from view coordinates into page coordinates

2012-03-27 Thread Alvaro Costa Neto
Hey Nick, how are you? Try to use the PDFView's convertPoint/Rect:to/fromPage: methods . The trick is to always remember to use a common ground (the PDF

Re: PDFKit: translate point coordinates from view coordinates into page coordinates

2012-03-27 Thread Nick
Hi Alvaro Thank you for the response! Yes, this is it. I just found a sample code PDFKitLinker2, and it showed how to do just what i need. 27 марта 2012 г. 15:05 пользователь Alvaro Costa Neto написал: > Hey Nick, how are you? > > Try to use the PDFView's convertPoint/Rect:to/fromPage: methods

Re: Question about UIImage, scaling, and UIGraphicsBeginImageContextWithOptions

2012-03-27 Thread Ray
Hi Marco, Thanks for your thoughts! Let me first say, the original app is already out there, using the old UIGraphicsBeginImageContext (at the time there was no UIGraphicsBeginImageContextWithOptions to begin with), used now on a variety of devices with normal and retina screens etc. The probl

Re: PDFKit: translate point coordinates from view coordinates into page coordinates

2012-03-27 Thread Antonio Nunes
On 27 Mar 2012, at 12:19, Nick wrote: > I would like to place a PDFAnnotation onto a PDF page in a place where > the user clicked with the mouse. [...] > NSPoint locationInView = [self convertPoint:[theEvent > locationInWindow] fromView:[[self window] contentView]]; You are receiving the event lo

Re: Question about UIImage, scaling, and UIGraphicsBeginImageContextWithOptions

2012-03-27 Thread Roland King
UIImageView's scale automatically so just setting the frame of the UIImageView containing the UIImage to ( x, y, 44, 44 ), possibly after you load the image into it, will just work whatever size the image actually is on whatever type of display you are using. On Mar 27, 2012, at 3:38 PM, Ray

Re: How to throttle rate of NSInputStream?

2012-03-27 Thread Roland King
On Mar 27, 2012, at 7:13 AM, Jens Alfke wrote: > [I posted this to macnetworkprog earlier today, but 3 hours later it hasn’t > shown up yet, so I’m trying here too.] > > I’m using an async NSInputStream to read from a TCP socket. Given a good > connection, the data comes in faster than an iOS

Rotating CALayer on iDevice rotation

2012-03-27 Thread Eric E. Dolecki
In my viewDidLoad I have this code which sets up some drawing on a CALayer: rootLayer = [CALayer layer]; rootLayer.frame = CGRectMake(164, 243, 30, 30); [self.view.layer addSublayer:rootLayer]; It's positioned properly. Now, I'd like to have it rotate around it's "registration" point. Adding a

Example implementation of NSAnimatablePropertyContainer?

2012-03-27 Thread Kenneth Baxter
I have some objects that I want to use implicit animations for, but they are not views.  I understand that I should be able to implement the NSAnimatablePropertyContainer protocol and it should just work from there.  Unfortunately the documentation seems pretty light on how to implement the p

Re: File types...

2012-03-27 Thread Kyle Sluder
On Mar 26, 2012, at 11:14 PM, Randy Widell wrote: > It is a custom UTI, so, of course, I export it: > >UTExportedTypeDeclarations > > >UTTypeConformsTo > >public.database > Not sure this will fix your problem, but you haven't d

Re: Question about UIImage, scaling, and UIGraphicsBeginImageContextWithOptions

2012-03-27 Thread Andreas Mayer
Am 27.03.2012 um 13:47 schrieb Marco Tabini: > When you save to a file format that supports metadata, like JPEG, some of the > metadata is stored there, while other is derived from the file name. So, for > example, if you were to save a PNG file to disk with an @2x suffix, upon > loading it wi

Re: Question about UIImage, scaling, and UIGraphicsBeginImageContextWithOptions

2012-03-27 Thread Ray
Right, cell.imageView sets its own frame, no matter where you try to set it manually. I could of course add my own image view to the cell's contentView... On Mar 27, 2012, at 4:21 PM, Roland King wrote: > UIImageView's scale automatically so just setting the frame of the > UIImageView containin

Re: Question about UIImage, scaling, and UIGraphicsBeginImageContextWithOptions

2012-03-27 Thread Ray
On Mar 27, 2012, at 4:50 PM, Andreas Mayer wrote: > The documentation for UIImage -scale says: > > "If you load an image from a file whose name includes the @2x modifier, the > scale is set to 2.0. If the filename does not include the modifier but is in > the PNG or JPEG format and has an asso

Re: File types...

2012-03-27 Thread Randy Widell
Yup, that was it. public.data has to be the first item in the array. I tried: * public.database (item 0) only: fail. * public.database (item 0), public.data (item 1): fail. * no conformance declarations: fail. * public.data (item 0), public.database (item 1): success. * public.data (item 0) only

Re: Question about UIImage, scaling, and UIGraphicsBeginImageContextWithOptions

2012-03-27 Thread Andreas Mayer
Am 27.03.2012 um 17:31 schrieb Ray: >> So I would expect PNG images to retain their scale value when saved and >> loaded. >> >> If this does not work, there seems to be a bug somewhere. >> Ray, did you try to explicitly set the image's scale value before creating >> the PNG representation? >

Re: Question about UIImage, scaling, and UIGraphicsBeginImageContextWithOptions

2012-03-27 Thread Ray
Andreas: On Mar 27, 2012, at 6:41 PM, Andreas Mayer wrote: > The scale value is the same as set in > UIGraphicsBeginImageContextWithOptions(), as far as I can tell. Right, that was what I meant actually. > But it will be lost when creating PNG data and reading it again. (Since I > don't see

Re: Question about UIImage, scaling, and UIGraphicsBeginImageContextWithOptions

2012-03-27 Thread Ray
Andreas: On Mar 27, 2012, at 6:41 PM, Andreas Mayer wrote: > So either imageWithData does not restore the scale from PNG data or > UIImagePNGRepresentation() does not store it in the first place. When I set a breakpoint at UIImagePNGRepresentation(newImage) I can see that the scale of newImage

Re: Question about UIImage, scaling, and UIGraphicsBeginImageContextWithOptions

2012-03-27 Thread David Duncan
On Mar 27, 2012, at 12:38 AM, Ray wrote: > Now, when I generate a new image on an iPhone with a retina screen, in which > case the above UIGraphicsBeginImageContextWithOptions uses a scale of 2.0, > the image in the table view shows too big. This is because [UIImage > imageWithData:item.listIma

Re: Question about UIImage, scaling, and UIGraphicsBeginImageContextWithOptions

2012-03-27 Thread David Duncan
On Mar 27, 2012, at 2:57 AM, Giacomo Tufano wrote: > That's what I use to generate a thumbnail of sideSize side lenght in iOS3.x > code. > It uses iOS4+ functions for retina displays (I remember that you can assume > iOS4+ with retina displays). > > CGSize newSize = CGSizeMake(sideSize, sideSiz

Re: File types...

2012-03-27 Thread Kyle Sluder
On Mar 27, 2012, at 9:13 AM, Randy Widell wrote: > Yup, that was it. public.data has to be the first item in the array. I > tried: > > * public.database (item 0) only: fail. > * public.database (item 0), public.data (item 1): fail. > * no conformance declarations: fail. > * public.data (item

Re: File types...

2012-03-27 Thread Randy Widell
Eh. Looks like you're right. I reconfigured the Info.plist with public.database as Item 0 and public.data as Item 1 and it worked this time around. Originally, I added public.data, cleaned and rebuilt, and the files were still showing as gray in the open panel. But, I cannot reproduce that

Re: Question about UIImage, scaling, and UIGraphicsBeginImageContextWithOptions

2012-03-27 Thread Andreas Mayer
Am 27.03.2012 um 19:19 schrieb Ray: > Edit: I just checked and they say they do this for compatibility reasons. > It's around the 9'40'' mark, session 134 - Optimize your iPhone App for the > Retina Display (WWDC 2010, I assume you have access)... I'll check this out, thanks. Andreas ___

Re: Question about UIImage, scaling, and UIGraphicsBeginImageContextWithOptions

2012-03-27 Thread Andreas Mayer
Am 27.03.2012 um 19:29 schrieb David Duncan: > Simplest solution is to save the scale along side the image itself That's what I just implemented. But I still think PNG images should retain the scale factor. Why saving that information elsewhere when the format explicitly supports this? Andr

NSTextFinder - don't use an NSView subclass for the client

2012-03-27 Thread Eric Slosser
Don't use a subclass of NSView for the object that you pass as 'client'. The NSTextFinderClient protocol's -(BOOL)isEditable method will be called from -[NSView inputContext] as your view's window is being dealloc'd, and you may crash. ___ Cocoa-dev m

mogenerator and key path error

2012-03-27 Thread Ayers, Joseph
I have a CoreData entity named Tapes. I used mogenerator to create: _Tapes.h where: @interface Tapes : _Tapes {} and Tapes.h where @interface _Tapes : NSManagedObject {} I declare an instance tapes in AppDelegate.h as: @property (nonatomic, retain) Tapes* tapes; and in AppDelegate.m

Re: Question about UIImage, scaling, and UIGraphicsBeginImageContextWithOptions

2012-03-27 Thread David Duncan
On Mar 27, 2012, at 10:59 AM, Andreas Mayer wrote: > > Am 27.03.2012 um 19:29 schrieb David Duncan: > >> Simplest solution is to save the scale along side the image itself > > That's what I just implemented. But I still think PNG images should retain > the scale factor. Why saving that inform

Re: Can't delete file on device

2012-03-27 Thread Mike Abdullah
Well error code 4 is NSFileNoSuchFileError. I think you're trying to delete a file that doesn't exist! On 27 Mar 2012, at 03:22, Rick Mann wrote: > I'm trying to delete some image files I cache. Here's what I'm getting: > > 2012-03-26 19:20:14.330 MyApp[5765:707] File exists: > /var/mobile/App

Re: Can't delete file on device

2012-03-27 Thread Rick Mann
Yet, I check for the existence of the file before to verify its there, as you can see in the output. Sent from my iPhone On Mar 27, 2012, at 11:15, Mike Abdullah wrote: > Well error code 4 is NSFileNoSuchFileError. I think you're trying to delete a > file that doesn't exist! > > On 27 Mar 2

Re: How to throttle rate of NSInputStream?

2012-03-27 Thread Andreas Grosam
On Mar 27, 2012, at 1:13 AM, Jens Alfke wrote: > [I posted this to macnetworkprog earlier today, but 3 hours later it hasn’t > shown up yet, so I’m trying here too.] > > I’m using an async NSInputStream to read from a TCP socket. Given a good > connection, the data comes in faster than an iOS

Re: Can't delete file on device

2012-03-27 Thread Roland King
and the fact it works on the sim and not on the device makes me think you have a case issue, device is case sensitive, sim is not. On Mar 28, 2012, at 2:15 AM, Mike Abdullah wrote: > Well error code 4 is NSFileNoSuchFileError. I think you're trying to delete a > file that doesn't exist! > > O

Re: mogenerator and key path error

2012-03-27 Thread Quincey Morris
On Mar 27, 2012, at 11:12 , Ayers, Joseph wrote: > In mainMenu.xib I have a NSArrayController. TapesController:NSArrayController > With ObjectController mode set to EntityName > and the EntityName set to tapes The entity name should be "Tapes", not "tapes". _

Re: Can't delete file on device

2012-03-27 Thread Rick Mann
The file is generated and deleted by code; it's the same string passed around, at least certainly in the existence check just before the attempted delete. Surely that existence check would fail, too? -- Rick On Mar 27, 2012, at 11:31 , Roland King wrote: > and the fact it works on the sim and

Re: Can't delete file on device

2012-03-27 Thread Mike Abdullah
Show us some code. On 27 Mar 2012, at 19:47, Rick Mann wrote: > The file is generated and deleted by code; it's the same string passed > around, at least certainly in the existence check just before the attempted > delete. Surely that existence check would fail, too? > > -- > Rick > > On Mar

Re: mogenerator and key path error

2012-03-27 Thread Quincey Morris
On Mar 27, 2012, at 11:56 , Ayers, Joseph wrote: > 2012-03-27 14:39:38.533 Roboplasm[74089:403] Cocoa Bindings: Error accessing > value for key path tapes of object (from bound > object [entity: tapes, number of selected > objects: 0]): [ valueForUndefinedKey:]: this > class is not key value

Re: Question about UIImage, scaling, and UIGraphicsBeginImageContextWithOptions

2012-03-27 Thread Andreas Mayer
Am 27.03.2012 um 20:13 schrieb David Duncan: > Primarily because people abuse the resolution field, and as such it cannot be > trusted for this particular function. In a perfect world, we would only ever > see 72 (1x) or 144 (2x) in the resolution field, but instead the value tends > to be pra

NSScrollView automatically changes scroller styles?

2012-03-27 Thread Nick Zitzmann
I've searched around but didn't see anything relevant. Why would an NSScrollView suddenly change its scroller style behind the application's back during a resize? I noticed that, when running an app on a laptop with no external pointer connected and the system default set to show scroll bars au

Re: Question about UIImage, scaling, and UIGraphicsBeginImageContextWithOptions

2012-03-27 Thread David Duncan
On Mar 27, 2012, at 1:04 PM, Andreas Mayer wrote: > > Am 27.03.2012 um 20:13 schrieb David Duncan: > >> Primarily because people abuse the resolution field, and as such it cannot >> be trusted for this particular function. In a perfect world, we would only >> ever see 72 (1x) or 144 (2x) in th

Re: Can't delete file on device

2012-03-27 Thread Rick Mann
On Mar 27, 2012, at 12:05 , Mike Abdullah wrote: > Show us some code. NSURL* url = [NSURL URLWithString: ci.diskURI]; if ([fm fileExistsAtPath: url.absoluteString]) { NSLog(@"File exists: %@", url.absoluteString); } NSError* err = nil; [fm removeItemAtURL: ur

Re: Can't delete file on device

2012-03-27 Thread David Duncan
On Mar 27, 2012, at 1:50 PM, Rick Mann wrote: >NSURL* url = [NSURL URLWithString: ci.diskURI]; Does ci.diskURI include the "file://" prefix or is it just a path? If the latter, then you should be using +fileURLWithString:. -- David Duncan ___ Co

Re: NSScrollView automatically changes scroller styles?

2012-03-27 Thread Nick Zitzmann
On Mar 27, 2012, at 2:09 PM, Nick Zitzmann wrote: > I've searched around but didn't see anything relevant. Why would an > NSScrollView suddenly change its scroller style behind the application's back > during a resize? I still wish I knew why this was happening, but I did find a workaround on

Re: Can't delete file on device

2012-03-27 Thread Conrad Shultz
On 3/27/12 1:50 PM, Rick Mann wrote: > > On Mar 27, 2012, at 12:05 , Mike Abdullah wrote: > >> Show us some code. > > NSURL* url = [NSURL URLWithString: ci.diskURI]; > if ([fm fileExistsAtPath: url.absoluteString]) > { > NSLog(@"File exists: %@", url.absoluteString); > }

Re: Can't delete file on device

2012-03-27 Thread Rick Mann
On Mar 27, 2012, at 14:16 , Conrad Shultz wrote: > As David already pointed out you should probably be using file URLs. I made that change, and it behaves the same way. Even so, I don't see why that particular difference would allow it to work on the sim and not on the device. > There are a co

Re: Can't delete file on device

2012-03-27 Thread Kyle Sluder
On Mar 27, 2012, at 2:23 PM, Rick Mann wrote: > > On Mar 27, 2012, at 14:16 , Conrad Shultz wrote: > >> As David already pointed out you should probably be using file URLs. > > I made that change, and it behaves the same way. Even so, I don't see why > that particular difference would allow it

Re: Can't delete file on device

2012-03-27 Thread Gregory Weston
Rick Mann wrote: > The file is generated and deleted by code; it's the same string passed > around, at least certainly in the existence check just before the attempted > delete. Surely that existence check would fail, too? Not necessarily. The problem with patterns like "check if transient reso

Re: Example implementation of NSAnimatablePropertyContainer?

2012-03-27 Thread Gideon King
I'd be interested in this too. In the past, I have created a subclass of NSView and just used the animation capabilities without ever inserting it in a view hierarchy, and that worked, but that was just a quick and dirty hack project - I'd like to know how to do it properly… Regards Gideon

Re: How to throttle rate of NSInputStream?

2012-03-27 Thread jonat...@mugginsoft.com
On 27 Mar 2012, at 00:13, Jens Alfke wrote: > > This seems to hinge on the way the stream calls my event handler. When I get > the NSStreamEventHasBytesAvailable, I only read 8k bytes of data at a time, > then return. What seems to happen is that, if that didn’t consume all of the > available d

Re: Can't delete file on device

2012-03-27 Thread Wade Tregaskis
> Okay, I made that change, but it seems blatantly incorrect to create an error > return if it is also going to return true. It only returns you something if it says it did, by indicating that an error occurred. Otherwise, the contents of the error parameter are undefined. There are definitely

Re: Can't delete file on device

2012-03-27 Thread Mike Abdullah
On 27 Mar 2012, at 22:23, Rick Mann wrote: >> There are a couple other issues: >> >> 1) You shouldn't handle errors by testing (err != nil). This might work >> (since you initialized err to nil) assuming that removeItemAtURL: isn't >> fiddling with err anyway, but it's not guaranteed. The pref

Is there a list solely for ObjC/compiler language issues?

2012-03-27 Thread William Squires
Just curious... :) ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: htt

Re: Is there a list solely for ObjC/compiler language issues?

2012-03-27 Thread Wade Tregaskis
> Just curious... :) ObjC: objc-langu...@lists.apple.com (https://lists.apple.com/mailman/listinfo/objc-language) Clang: cfe-...@cs.uiuc.edu (http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev) ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Ple

Re: How to throttle rate of NSInputStream?

2012-03-27 Thread Steve Sisak
At 10:36 PM +0100 3/27/12, jonat...@mugginsoft.com wrote: You probably already have this sorted but it occurred to me that when you receive NSStreamEventHasBytesAvailable you don't have to read the data there and then. Quinn (DTS) gave Jens the following complete answer on macnetworkp...@list