Tuesday, April 1, 2014

Splitting GIF into frames on Android via giflib

PREAMBLE: the app where this technique originated is no longer using it. I've integrated GifFileDecoder by Google and never looked back. Had to patch it somewhat, though - my GIFs are small, makes more sense to read them into memory rather than display progressively.

UPDATE: it's now a Gist.

This is a followup to my answer at StackOverflow regarding animated GIFs on Android. Folks want code - I've got some. The general idea is - use giflib to get RGB(A) pixel data for each frame in a format that's compatible with Android's, feed the pixels to bitmaps, display the bitmaps.

Thursday, March 27, 2014

Inflating a bicycle tire with a potato

The inimitable Raymond Chen of Old New Thing fame once wrote a blog post about using inappropriate tools for the job. It came to my mind the other day when I needed to do a timestamp-based conditional in a batch file. The underlying cause was rather vanilla - file H is generated from file X, so if file X was modified later than H was, the batch needs to rebuild H.

Wednesday, March 26, 2014

SEH for fun and profit

PREAMBLE: this technique is no longer necessary. As of Visual Studio 2015 Update 2, one can mix C++ exceptions with SEH.

The built-in crash reporting of Windows Phone 8 sucks. It doesn't report registers, stack, what modules were loaded at crash time... Definitely not something you can debug from.

Friday, June 4, 2010

Not a real boy

Of all mobile software platforms, I have extensive development experience with three: Windows Mobile, BlackBerry and iPhone. For all three, there's a simulator for ease of debugging. And here's my expert opinion: the Microsoft Device Emulator is the best. The BB simulator does not support multiple debugging sessions in a row - if you change and recompile, you have to restart the simulator, and that takes a nontrivial amount of time. The iPhone simulator is not that bad, but it has considerable differences with the real device. Also, you cannot run arbitrary software on it - the simulator does not actually simulate the ARM CPU of a real iPhone, it runs compiled Intel code.

Microsoft Device Emulator, on the other hand, emulates ARM instruction set to a tee, supports debugger reconnection, and on top of that, approximates real device performance reasonably well. Hats off to MSFT. Apple Computer and RIM - you officially suck.

Monday, March 29, 2010

Bug-o-rama, encore...

Another day, another beautiful C++ bug. My program is a shareware Windows Mobile application. And it uses a unique device ID for the purposes of licensing and user identification.

Monday, November 23, 2009

Commentary

More from the exotic C++ bugs department:
Under GCC, the \ character at the end of a single-line comment extends the comment to the next line.

A similar behavior is well-known and oft-used for the preprocessor directives (#define etc.), but for the comments? No such behavior under MSVC; the code in question was ported from Windows, where it worked like a charm. And the worst part is, the IDE (Apple Xcode in my case) did not know about that either - the second, commented out line was not colored as one.

You learn something new every day.