Jump to content
Larry Ullman's Book Forums
Sign in to follow this  
Necuima

Air Native Extension

Recommended Posts

Hi,

 

This is another of my 'lessons learned' posts that may be of use to someone attempting a similar endeavour.

 

After countless hours and a lot of help, I have managed to get an AIR Native Extension incorporating simple Image Magick functionality working.  Although, so far at least, I have not achieved my ultimate objective, I do have an AIR native extension incorporating simple Image Magick functionality working on my PC.

 

The 'ultimate objective' was to create a Windows exe file/application which could be installed on anyone's PC without the need for that PC to have Image Magick also installed - that has so far eluded me, but if that PC has Image Magick installed in the manner necessary, then the application will indeed work on another PC.

 

The basic development process is as follows:

 

1) build a dll which has both Image Magick and AIR native extension connectivity (I used MS Visual C++ 2010 Express Edition as my IDE).

2) build a library (I used Flash Builder 4.6) incorporating a class and then from that build an ane file.

3) build a Flash Builder AS3/Flex project to use the functionality developed in steps 1 and 2 which incorporates the ane file from step 2.

 

Detailed guidance for the AIR bits can be found at http://easynativeextensions.com/windows-tutorial-introduction/ which did not exist when I started this endeavour but many thanks to Radoslava Leseva for her invaluable help in this bit.

 

I used the Wand interface to Image Magick and guidance on that can be found at http://members.shaw.ca/el.supremo/MagickWand/ and http://www.imagemagick.org/discourse-server/viewtopic.php?t=11757

 

The application, via a simple user interface (UI - step3), allows the user to select a jpg image file for downsizing.  The UI also requests a new pixel size parameter as well as a jpg quality/compression factor.

 

The class (step 2) has an instance constructor and a method.  The UI calls the method passing it the full path name of the jpg image file to be downsized as well as the size and quality parameters.  The method then calls a resize function in the dll which in turn uses the Image Magick Wand interface to do the actual resizing.

 

I know that there are easier ways to downsize a jpg image but I wanted to learn how to develop an AIR native extension!

 

I am impressed with the quality of the downsized images.  As a test I downsized an 18Mb high quality image to a file about 150Kb in size and on my 24 inch screen I cannot detect any reduction in the visual quality of the image.  That of course is due to the Image Magick functionality.

 

I hope that this may be of help to someone!

 

Cheers from Oz.

Share this post


Link to post
Share on other sites

Hi Rui,

 

Sorry that I did not get back to you sooner.

 

For some reason I cannot copy and paste code into a reply such as this without typing it all in line by line.

 

If you ask Larry for my email address, it's OK if he lets you know what it is and then you can email me and I can attach the code in a reply.

 

Cheers, Necuima

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×