AFNetworking/AFNetworking — pull request #115 by InScopeApps (2011-11-18 07:19:50+00:00)
Title: Adding code to set the responceImage to the correct size.

I've been working on a Dribbble framework and I just switched over to using AFNetworking and it's working great! One issue I ran into with my networking code, and now with AFNetworking, is that sometimes `NSImage` displays an image at the wrong size. The solution I found was to get a `CGImage` then set the width and height of the `NSImage` to what the `CGImage` says it is.

Some context from the docs on why this is happening and why the CGImage fixes it:

> An NSImage is potentially resolution independent, and may have representations that allow it to draw well in many contexts. A CGImage is more like a single pixel-based representation. This method produces a snapshot of how the NSImage would draw if it was asked to draw in the proposed rectangle in the graphics context.

Unfortunately the NSImage is not drawing well. Here is an example of what I'm seeing before and after this change:

![](http://f.cl.ly/items/3h1E1C0d2L2z1Y2C2V1e/beforeafter.png)

These are the urls from the Dribbble API I used for testing:

* http://dribbble.com/system/users/13774/screenshots/322302/_87_teaser.jpg?1321541774
* http://dribbble.com/system/users/4454/screenshots/322241/max100_20_teaser.jpg?1321537468