I'm implementing a image renderer on an external device and want to
include GIF animation support. So far this is working fine, but I've
found a difficulty that comes from for image.Decode's file type
detection is registered.

What I have is shim type that wraps *gif.GIF but also implements
image.Image. Registering the decoder for this for "GIF8?a" does not
work because the registration function, image.RegisterFormat appends
the registration details to the existing registered formats. Since my
code depends on "image/gif", the package registration has already
happened during init and I don't see a way to ever beat the "image/gif"
registration call during init. The workaround is to seek to the start
of the file if image.Decode finds a gif, which is inefficient and will
not handle the case of a non-seekable io.Reader. The alternative is to
replicate the image.Decode functionality, including registration which
seems ugly.

The existing behaviour is somewhat surprising since there is no
indication in the docs that a new registration of the same magic bytes
will not work.

Is there a commonly used work-around for this? Would a change to
image.RegisterFormat that did a replacement of existing registrations
that are identical to a new registration rather than an append be
entertained (I can see good reasons for a no here)?

Dan

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/63152ea80145ea3076f68772e3d03156ba23f680.camel%40kortschak.io.

Reply via email to