Nick Bowler [Tue, 17 Dec 2013 04:49:30 +0000 (23:49 -0500)]
lbximg: Fix wart in frame scanline header format
The format of frame scanlines has been a little weird since day 1: We
had 2 "types" of scanline headers disambiguated by some non-trivial
logic, including whether or not it was the first decoded scanline in
the frame.
Here's a new, simpler approach, which has only one type of scanline
header, consistent meanings to the header fields, and by interpreting
the first 4 bytes as a "frame header" we get rid of the special case
for the first scanline, too.
Add a document in English which describes the LBX image file format, to
be used as the baseline format specification going forward.
Finally, update the contrived test cases for the new format. All the
test cases using actual MOO2 data still pass.
Nick Bowler [Tue, 17 Dec 2013 01:01:57 +0000 (20:01 -0500)]
lbximg: Return failure if there was a decoding error.
If any frame was not decoded because liblbx returned an error, we should
return a non-zero exit status from the tool. Previously this would only
happen if *all* frames failed.
Nick Bowler [Fri, 21 Jun 2013 14:22:48 +0000 (10:22 -0400)]
liblbx: Fix framebuffer allocation for 0x0 images.
The allocation strategy for the framebuffer is the "array2" method from
c-faq: an array of row pointers into a single large array containing all
rows. This was not being freed correctly in the case with 0 rows, since
there would be no pointer to the row data at all in order to free it.
Fix that up by simply allocating a 1x1 framebuffer when it would
otherwise be empty. While we're at it, also add an overflow check
on the multiplication.
Nick Bowler [Wed, 19 Jun 2013 01:07:51 +0000 (21:07 -0400)]
lbximg: Add an option to control the output filenames.
This will be needed for postmortem analysis of test cases that extract
multiple images, since otherwise there is no easy way to prevent the
tool from overwriting the earlier outputs.
This was clearly intended to be a user setting from the start but for
some reason it was never wired up to a command-line option.
Nick Bowler [Fri, 14 Jun 2013 22:15:25 +0000 (18:15 -0400)]
lbximg: Make libpng a soft dependency.
Now that we have Netpbm output formats which do not depend on
any external libraries, we can make it possible to build lbximg
without libpng. Adjust the build system so that lbximg is built
unconditionally and PNG output can be selectively disabled.
Nick Bowler [Fri, 14 Jun 2013 22:11:46 +0000 (18:11 -0400)]
lbximg: Add support for Netpbm output.
These netpbm formats are extremely simple image formats which can
be written with a very small amount of code. Implement the ASCII
PBM and PPM formats for eventual use in test scripts, and PAM as a
fully-featured format so that we can make libpng optional.
Nick Bowler [Fri, 14 Jun 2013 01:57:11 +0000 (21:57 -0400)]
liblbx: Don't scale palette values internally.
Output the 18-bit palette values unadulterated, leaving it up to the
users to do conversion if necessary. Push the conversion down into the
consumers (currently PNG output and the GTK GUI) where a 24-bit palette
is required.
While we're at it, adjust the conversion to scale to the full output
range of [0, 255]. This is a slight change to the output, so all the
image hashes need to be adjusted in the regression test.
Nick Bowler [Fri, 14 Jun 2013 01:23:52 +0000 (21:23 -0400)]
lbximg: Fix printf format string in identify mode.
One of the flag strings would never be printed because there was
simply not enough conversion specifiers in this format string. Fix
that up, and also adjust the length modifiers to match the actual
passed integer types.
Nick Bowler [Fri, 14 Jun 2013 01:16:36 +0000 (21:16 -0400)]
lbximg: Push no-palette mode down into the PNG writer.
This allows the writer to select the most appropriate output format to
support this mode. Switch the PNG writer to emit true grayscale images
in this case.
Nick Bowler [Wed, 12 Jun 2013 01:07:30 +0000 (21:07 -0400)]
liblbx: Properly report errors in lbx_(img_)fopen.
The lbx_fopen and lbx_img_fopen functions were not properly pushing an
error code when they failed, leading to extremely helpful messages of
the form:
lbximg: failed to open image: Success.
It further turns out that pushing negative errors (i.e., -errno) was
documented but never actually tested or used, so fix that up, too.
It is likely that many other sites are lacking appropriate calls to
lbx_error_raise, which can be added later.
Nick Bowler [Tue, 11 Jun 2013 22:29:07 +0000 (18:29 -0400)]
lbximg: Add a new PNG writing routine.
This splits out the PNG output from the rest of the lbximg processing,
so that it will be easier to add additional output formats (in par-
ticular, it would be nice to have some sort of text-based format to
facilitate automated testing).
Take this opportunity to vastly improve the error handling.
Nick Bowler [Thu, 11 Feb 2010 05:06:54 +0000 (00:06 -0500)]
lbxgui: Implement frame dropping for animation.
Currently, if it takes longer than 1/15th of a second to draw a frame,
the next frame will be queued before it has a chance to finish, which
then takes longer than 1/15th of a second to draw, so the next one gets
queued, ad infinitum.
We do two things to solve this problem. First, the timer runs at a
low priority so that a redraw doesn't get queued while a redraw is in
progress. Second, the timer skips queueing any frames that have missed
their time.
Nick Bowler [Thu, 11 Feb 2010 00:08:25 +0000 (19:08 -0500)]
build: Implement a better GTK+ detection macro.
This macro uses the same ideas behind the libpng detection, does not
suffer from the POSIXLY_CORRECT nonsense, doesn't duplicate checks
for pkg-config, supports caching, and properly fails when it should.
Nick Bowler [Wed, 10 Feb 2010 06:24:37 +0000 (01:24 -0500)]
lbxgui: Fix pointer type error.
The XBM format is an array of unsigned char, yet for some reason
unknown to me, the gdk_bitmap_create_from_data function wants a
char pointer. Add the appropriate cast.
Nick Bowler [Wed, 10 Feb 2010 05:40:17 +0000 (00:40 -0500)]
lbxgui: Compile in the glade UI description.
I don't think it makes any sense to try and jump through hoops to find
this data at runtime, given that the data and the code are so intimately
connected.
Nick Bowler [Tue, 9 Feb 2010 05:27:30 +0000 (00:27 -0500)]
liblbx: Add support for "chunked" images.
It appears that the frame count fields aren't actually two 16-bit
fields, but rather four 8-bit fields. The images in monster.lbx
appear to have "chunks" of animation and what was previously thought to
be the most significant byte of the lead-in now seems to be the length
of a "chunk".
These images are much like any other, except that the first frame of
every chunk is drawn on a clean slate. Examples are found in
monster.lbx.
Nick Bowler [Tue, 9 Feb 2010 04:14:16 +0000 (23:14 -0500)]
liblbx: Add support for "raw" LBX images.
There is a new image format in town. If a particular flag bit is set,
then there are no row headers and data for every pixel of a frame is
simply stored in row-major order. An example of such an image is
starbg.lbx.009, as well as several others in the same archive.
Don't you just *love* the designers of this format?
Nick Bowler [Mon, 8 Feb 2010 04:24:06 +0000 (23:24 -0500)]
liblbx: Add new flag.
Building images have a previously-unknown flag, 0x0800. The images have
a part that looks like a shadow, but it does not have any palette entry.
I suspect that this flag is related to that shadow.
Nick Bowler [Sun, 7 Feb 2010 22:11:26 +0000 (17:11 -0500)]
liblbx: Add a field to lbx_colour indicating which entries are used.
An LBX palette might not contain values for all 256 entries. Currently,
there is no way to tell which entries were assigned when the palette is
retrieved from an image. This patch adds an extra marker which can be
used to skip over unused palette entries.
Nick Bowler [Thu, 4 Feb 2010 19:02:44 +0000 (14:02 -0500)]
lbxtool: Remove - as a synonym for stdin.
Modern Unix-like systems have interfaces such as /dev/stdin which mean
the same thing. Furthermore, the tools read from stdin by default.
Lastly, -f some_file -f - doesn't work anyway.
Nick Bowler [Thu, 4 Feb 2010 16:47:18 +0000 (11:47 -0500)]
liblbx: Don't ignore whence parameter in pipe_seek.
The code from which this derived only supported SEEK_SET-like
operations, so SEEK_CUR was forgotten when converting it.
SEEK_END obviously cannot be supported on pipes.