Run pngquant via a NativeProcess: C#, Unity & AS3/AIR

After our Unity runtime SpriteSheets generator, it is a good idea to optimize the generated pngs files.

pngquant is a command-line utility and a library for lossy compression of PNG images. The conversion reduces file sizes significantly (often as much as 70%) and preserves full alpha transparency. In other words this is a must have tool if you’re working with many pngs!

I used many times pngquant directly from the command line, but depending your project, you might need to run it directly inside your application! I didn’t find example for doing this, and it was way harder than I thought due to my lack of knowledge with batch and shell scripts! So here we go:

We use custom batch file (for Windows) and shell script (for Mac OS X) for launching pngquant. It will take the path to pngs to compress and overwrite them.

OS X:

#!/bin/sh
#!/usr/bin/env bash
#$ -N $2

DIR="$( cd "$( dirname "$0" )" && pwd )"

(cd "$DIR" && ./pngquant -f --ext .png "$1"/*.png)

Windows:

cd %~dp0
pngquant -f --ext .png "%~1"/*.png

Now a C# example for calling thoses scripts, note it works fine with Unity too:

System.Diagnostics.Process process = new  System.Diagnostics.Process();

string exec = "";
if (Application.platform == RuntimePlatform.WindowsEditor || Application.platform == RuntimePlatform.WindowsPlayer)
	exec = "pngquant-windows.cmd";
else if (Application.platform == RuntimePlatform.OSXEditor || Application.platform == RuntimePlatform.OSXPlayer)
	exec = "pngquant-osx";
else
	throw new Exception("Platform not supported");

process.StartInfo.FileName = Application.dataPath + "/../../" + exec;
process.StartInfo.Arguments = Application.dataPath + "/../../png-to-compress";

// if your path have blank spaces use:
//process.StartInfo.Arguments = "\"" + Application.dataPath + "/../../png compress\"";

process.StartInfo.CreateNoWindow = true;
process.StartInfo.UseShellExecute = false;

process.Start();

And finally an example with AS3 for AIR:

var process:NativeProcess = new NativeProcess();

var startupInfo:NativeProcessStartupInfo = new NativeProcessStartupInfo();
var file:File = File.applicationDirectory;

var exec:String = "";
if (Capabilities.os.indexOf("Windows") >= 0)
	exec = "pngquant-windows.cmd";
else if (Capabilities.os.indexOf("Mac") >= 0)
	exec = "pngquant-osx";
else
	throw new Error("doesn't work on " + Capabilities.os + " operating system");

file.nativePath = file.nativePath + "/../" + exec;
startupInfo.executable = file;

var processArgs:Vector.<String> = new Vector.<String>();
processArgs[0] = File.applicationDirectory.nativePath + "/../png-to-compress";
startupInfo.arguments = processArgs;

process.start(startupInfo);

Be sure to have a look to PngQuantNativeProcess’s git repository to be up to date!

Memovox, AIR still on top

Two years ago, we coded a beautiful app named Geophysic for the famous luxary watches brand Jaeger-LeCoultre. Made with the cross-platform technology Adobe AIR, and Starling & Feathers, we finished the dev diary asking which other technologies could have done the app, but didn’t get a strong answer.
Today, with Pixelfordinner agency, we’re proud to share this new app named Wake-Up Memovox, for the same client, available for iOS and Android.
It was developed with the same technology, and if it’s obvious the game development market moves in favour of Unity, AIR is still rocking for making apps! Let’s see the development part!

Continue reading Memovox, AIR still on top

“Zip zip” avatar creator and character animation capture

“Zipizator” is a mobile app created by Ludo and Hyperfiction we developed to accompany the Zip Zip french animated television series’s release on a french channel.

It was fully created with Adobe Air.
Continue reading “Zip zip” avatar creator and character animation capture

Encoding BitmapData using AS3 Worker

Though AS3 Worker class is available since a while, its introduction on iOS is recent: less than 6 months. With AS3 workers being available everywhere, it’s about time to create small libraries multi-threaded with just a few lines of code!

If you never played with Worker, you should give a look to this great series of blog post.

There are several ways to create Worker, but if you don’t want to fall in a pitfall while using ANEs in your project, I recommend to use them via a loaded SWF.

So here is a small example making a simple library for encoding bitmap data and save images on disk via a Worker:
Continue reading Encoding BitmapData using AS3 Worker

En Route, making an old school point ‘n click game

En Route, or on the way in english, is a new game offered by l’Institut pour la Ville en Mouvement (Institute for Moving City) and developed by Dowino.
En Route is the first video game learning mobility! A game that combines educational objectives at such crazy situations as realistic. It’s a game to understand his daily commute otherwise, to learn how to move in a complex urban space, to live a new experience of urban travel, to develop the personal skills of mobility with the means at hand, to expand its range of actions to defuse the sensations of panic and urgency, to overcome maze or ghetto feelings, to facilitate the learning mobility for adults in positions social and economic fragility…

The game is presented as an old school point ‘n click game. There are scenes, dialogs with multiple answers, interactive objects and even an inventory!

Available as a mobile application, desktop application and on the web thanks to Adobe AIR & Flash Player technologies, the game is not public because you need to register via an organization.

en-route-actions
Continue reading En Route, making an old school point ‘n click game

Learn more and in a fun way about cancer with “Hygee” !

In 2013, the regional center Hygée dedicated to the information, prevention and education about cancer, opened on the site of the hospital complex of Saint Etienne (in the south-west of Lyon).

Hygée Center logo

So as to raise awareness of the cancer disease among the young public, the Hygée center asked  Dowino to create a quiz game playable on tablets. Further to successful projects with us (A blind legend 3D audio game, Mission eau mobile game, Effia Synergies quiz, …), Dowino decided to call upon us one more time for the implementation part of the project. We have chosen to use Adobe Integrated Runtime (AIR) to create the application.

Your mission should you choose to accept it, is to help Hygée, the daughter of Asclepios, to perfect her knowledge about medicine (about cancer in fact) and so truly graduate to the rank of Goddess !

Hygée
Hygée, medicine god’s daughter in the Greek mythology

 

Continue reading Learn more and in a fun way about cancer with “Hygee” !