LizardTech.com

Archive for October, 2008

Spooky!

Friday, October 31st, 2008

Bad company
Halloween spirit (pun intended) was rampant here in the LizardTech office today. We celebrated All Hallows Eve by bringing in lunch and holding a contest for best costume.

Dancing Queen

It was a difficult choice; Pooya’s faceless, hooded character was quite spooky and most in the spirit of the day. Ryan actually applied paint to his body, which scores high for dedication. John – always creative – had a half dozen dolls strapped to his torso. No one was able to guess what he was (I thought he was supposed to be a “babe magnet”) until he explained that Brad Pitt has adopted six infants. Kelly came as a rocker, and note that a guitar is also called an “axe”, so extra points for conceptually including a clever reference to a spooky thing there.

But in the end, Justyna won it with her dancing queen costume, possibly because she made several trips around the office dancing and singing ABBA. Pooya came in second, and Ryan third.

We also put candy at each desk, and in the afternoon Lizards brought their kids into the office so they could go around and collect treats and we could see them in their adorable little costumes.

Calling the SDK from C#

Tuesday, October 14th, 2008

Because we support multiple platforms (Windows, Solaris, Linux, Mac), our Decode SDK is written in C++.  Some years ago, our C++ APIs used to regularly lead to the question, “do you support Java?”.  The answer was always sorry, no, we’re not a Java shop and we don’t have any Java bindings… But we’ve always provided a relatively simple C API which we claimed could be wrapped using JNI, and for the most part that made people happy.

For the past year or so, though, all the Java requests seem to have disappeared, only to be replaced by the question, “do you support .NET?”  This usually means “do you have any C# bindings?”, although we do get the occasional VB.NET request.  Our response has been sorry, no, we’re not a C# shop and we don’t have any .NET bindings… But, again, we’ve told people that “it ought to be fairly easy to call out to our C API using P/Invoke, .NET’s Interop functionality”.

Well, recently some of the engineers here at LizardTech HQ have started programming in C# for reals, and so now we actually have just enough in-house expertise on the question to be able to provide some additional help on this one.  While the current DSDK release doesn’t provide any C# bindings, we have put together a very simple example app that shows how to use Interop to access the C API.

The code is, at heart, remarkably simple.  First, you declare your C functions so they can be accessed from within your C# class, like so:

      [DllImport("lti_dsdk_cdll.dll")] 
      static extern int ltic_openMrSIDImageFile(out 
            IntPtr image, string fileName); 

      [DllImport("lti_dsdk_cdll.dll")] 
      static extern uint ltic_getWidth(IntPtr image);

Then, you close your eyes, tap your ruby slippers together three times, and innocently call the functions just like they were real functions:

      // this is essentially our void* pointer 
      IntPtr image = IntPtr.Zero; 
      string infile = "..."; 

      sts = ltic_openMrSIDImageFile(out image, infile); 
      ... 
      uint width = ltic_getWidth(image); 
      ...

You can download the full example from here.

Yes, we know, it’d be nice to provide interop support for the C++ classes so as to give access to the whole SDK… but quite frankly, we’re not sure the market demand is really there yet.  At the very least, though, we’ll try to include interop support for the C API in the next release of the SDK.

Keep those cards and letters coming.

-mpg