Reading single MNG image failed
winfried szukalski <[email protected]> Fri, 20 Aug 2021 12:17:42 +0200
| Newsgroups | gmane.comp.graphics.png.devel |
|---|---|
| Message-ID | <[email protected]> |
I use FLTK to show images. There exist CALLBACKS for stop, start, restart,
forward, backward, goto.
static void forward_cb(void)
{
if(!play.handle)
{
return;
}
if(play.running)
{
return;
}
mng_retcode ret;
mng_uint32 frame = mng_get_currentframe(play.handle);
ret = mng_display_goframe(play.handle, frame);
mng_display_freeze(play.handle);
}
MNG.cxx:183: forward_cb current_frame(2) delay(13)
flimage 1.13.1: error playing((null)) chunk[96]'MEND':
code(4099) severity(2) extra1(0) extra2(0)
text:'Framenr out of bounds'
//---------------
With APNG, 'forward_cb()' works:
static void forward_cb(void)
{
if(aplay.running)
{
return;
}
FLImage_backward_activate(1);
aplay.is_still_image = 1;
next_frame();
aplay.is_still_image = 0;
}//forward_cb()
static void next_frame()
{
int i;
if( !aplay.canvas) return;
if((i = FLImage_frame_selected()) >= 0)
{
aplay.cur_frame = i;
}
i = aplay.cur_frame;
if(i == aplay.num_frames)
{
i = 0;
}
#ifdef _WIN32
sprintf(aplay.end_of_path, "\\%d.png", i);
#else
sprintf(aplay.end_of_path, "/%d.png", i);
#endif
if(apng_buf)
{
free(apng_buf); apng_buf = NULL;
}
{
FILE *reader;
unsigned char *buf = (unsigned char*)calloc(1, aplay.rgb_size + 4);
reader = fopen(aplay.rgb_path, "rb");
fread(buf, 1, aplay.rgb_size, reader);
//-----------------------------------------------------------------------
FLImage_use_buffer(buf, aplay.width, aplay.height, aplay.channels);
//-----------------------------------------------------------------------
fclose(reader);
apng_buf = buf;
}
FLImage_show_frame(i, aplay.num_frames-1);
aplay.delay = apng_table[i].delay;
aplay.cur_frame = i + 1;
if(i == 0)
{
FLImage_backward_activate(0);
}
else
{
FLImage_backward_activate(1);
}
//============================================================
if(aplay.is_still_image) return;
//============================================================
Fl::repeat_timeout(aplay.delay, wait_cb, aplay.rgb_path);
}//next_frame()
static void wait_cb(void *v)
{
next_frame();
}
The APNG file has been dismantled into RGBA files:
root: ls /root/.png/
0.png 1.png etc.
Each of these files can be read: start_cb() , restart_cb() ;
or skipped: APNG_goto_frame(int i) ;
or shown as a single image: backward_cb, forward_cb
Q1: Is there no MNG function() to only read one image ?
Q2: Must I dismantle an MNG file into PNG RGBA files like in APNG ?
winfried
_______________________________________________
png-mng-implement mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/png-mng-implement