Pixen: Out with old, in with the nu

I’d been planning a Pixen update explaining my continued lack of progress for quite a while. That I was busy in my new role as an iOS developer for the company I’d been working at for over year. How I would surely make progress on Pixen by leveraging the skills I developed on the job. But then they decided to downsize their iOS team from 3 developers to 2 and I suddenly found myself unemployed. Luckily my night classes at the local community college have paid off and I’ve been admitted to the local university’s computer science program. So now instead of being to busy working to work on Pixen I’ll be too busy studying to work on Pixen. But fear not! I’ve found a solution: rewrite it. Yes, I know rewrites are usually a foolish waste of time and money, but fortunately being unpaid, all I’ll waste is time! Turns out that it’s much easier, at least for me, to create a pixel editor from scratch than it is to shoehorn Pixen’s current code into modern APIs. I call it nuPixen. It’s still in the prototype phase but it does enough to be worthy of a screenshot.

A bit simplistic?

It can edit pixels, I swear!

You may have noticed by the window controls that I am, in fact, developing on 10.7. This will eliminate any version specific code I need to write and allow me to take advantage of all of the Lion APIs without worrying about compatibility. nuPixen will be open source on my GitHub page but will not be available until sometime after Lion’s release. In the mean time I’ll be posting updates on my progress and questions for users of Pixen and Mac developers in general about how I should move forward. Like I said, I’m still in the prototype phase, so that means I’m still trying to grok the OS X imaging APIs and how to fundamentally write a pixel editor. As you can see from the screenshot though, I do have basic image input, editing, and output working, along with the ability to set your fill color and switch the pixel grid on and off.

This is where I’ve hit my first issue: my pixel grid is uneven. Here’s my current code:

This method both resizes the image (currently stored as an NSBitmapImageRep) while maintaining the aspect ratio and draws the pixel grid when when it’s turned on. As you may be able to tell from the screenshot, the pixel grid is uneven, or at least appears to be. So my question is this, Mac developers: what would be a better way to draw the grid? As well, I currently access the image data by using NSBitmapImageReps’ setColor:atX:y: and it seems to work fine, but is it the best way? I ask you so I can code and not worry that what I’m writing is stupidly wrong. I look forward to your input.

P.S. Does anyone know a good, free, code-friendly WordPress theme? Carrington is just too damn narrow.