fix a bug in dimg.c