Thursday, August 18, 2011

Finally! WPF support in mdcm!

As I have mentioned in several recent blog posts, I have forked Colby Dillion's excellent C# DICOM class library mdcm and implemented a Silverlight DICOM class library largely based on the original mdcm code.

When dealing with Silverlight imaging support, it was apparent that it would be very easy to also make a WPF port of the mdcm class library.

Well, consider it done!

As of today, I have uploaded an update of mdcm to the Github repository, containing a complete .NET 4 class library Wpf.Dicom where DICOM images are rendered using WPF rather than Windows Forms.

Apart from imaging, the Wpf.Dicom project provides the same functionality as the original Dicom and Dicom.Linq projects combined. There are parts of the implemented imaging code for WPF that still remains untested, more specifically image rotation and flipping as well as multilayered images. I plan to test this specific functionality as soon as possible to verify that the WPF implementation is indeed fully functional.

The Dicom.Codec and Dicom.Codec64 projects have previously referenced the original Dicom project. To enable full codec support in WPF, I have updated the codec projects to instead reference Wpf.Dicom, and at the same time I have excluded the Windows Forms-based project Dicom and associated applications from the Visual Studio solution. This is of course an easy thing to change back, if anyone so wishes.

Please feel free to download and use the source code from Github. Comments and improvement suggestions are more than welcome. Do not hesitate to report issues under the Issues tab in the Github repository.

Wednesday, August 17, 2011

Completed mobile adventure: here's the iPhone Unit Converter!

It is now proven without doubt: the csunits class library for units of measurement support in C# is portable without modification to all major mobile platforms: Windows Phone 7(.1), Android, and now iOS!

To enable C# development on the Mac, I have used the MonoTouch tools from Xamarin. The current user interface certainly does not meet Apple design guidelines, but this is what the simple unit converter application looks like in the iPhone simulator:

This being my first attempt at C# development on the Mac, I have experienced quite a number of pitfalls. At this point I am not sure if these problems are due to limitations and issues in the MonoTouch components, or whether the problems are due to my limited experience with the platform.

Nevertheless, the unit converter works as intended, providing immediate unit conversion for all quantities and units currently represented in the csunits library. The source code, including a MonoDevelop solution (csunits-monotouch.sln) and MonoDevelop projects, are available in the Github repository.

Actual deployment on a real iPhone or iPad has not yet been tested. Phone deployment is not for free. For this proof-of-concept, I considered running on the iOS Simulator to be enough.

Thursday, August 4, 2011

Bringing physical unit conversion to the (Android) masses!

Yes, it could be done! As speculated in a recent blog post, the csunits class library that provides units of measurement functionality to C# can be built and used without modification on the Android platform!

By using Mono for Android developed by Xamarin, I have been able to build the entire csunits class library, and as a proof-of-concept that the library is indeed usable on the Android platform I have created a tiny unit converter application (similar to the Silverlight and Windows Phone applications I have developed earlier).

Here is what the unit converter application looks like in an Android emulator:

So far I have only tested the functionality in an Android emulator. Deployment on a real phone or tablet device is not for free.

I did experience several caveats when developing. The most notable problem was that the mandatory signing of the application package did not work correctly when Java 7 was installed on the computer (mentioned in a byline here, for example). It took some time before I could figure out that this was the reason my Mono for Android applications were never deployed on the emulator...

Mono for Android is of course lagging behind the main (Java) Android. As far as my initial attempts have revealed, the Mono Android API is not entirely complete vis-à-vis the corresponding Java Android API. The Android Honeycomb API for tablets is also not yet available on Mono for Android. It would otherwise be interesting to see if the C# DICOM class library mdcm could be built for use on Android as well?

There is also the concern that Xamarin is simultaneously developing Monotouch for iOS devices (iPhone and iPad). Android and iOS might just be one platform too many to maintain for Xamarin?

By the way, csunits on Monotouch remains to be tested. Given the success with Mono for Android, csunits and Monotouch should be no issue at all. Current lack of development resources (read: a Mac computer) prevents me from testing this right away. Who knows, maybe there is someone else out there who would like to give it a try?