c - What is wrong in this code: giflib library usage -


i have read giflib usage explanation , wrote following code:

giffiletype *giffile = dgifopenfilename("d:\\my.gif00.gif"); dgifslurp(giffile); int h = giffile->sheight; int w = giffile->swidth; int count = giffile->imagecount; gifpixeltype *mypixels = new gifpixeltype[w];   int errcode = dgifgetline(giffile, mypixels, 1); if (errcode == gif_ok) { } else {     printgiferror(); } 

as see there, file set dgifopenfilename function argument results in error, printgiferror() prints out following message:

gif-lib error: #pixels bigger width * height.

i can't understand wrong in code. want read gif file's pixels, edit them set gif file. issue?

as far can tell, seems indicate gif file corrupt.

the problem shouldn't using dgifgetline(). function dgifslurp() reads entire gif file giffile structure. internally, calls dgifgetline() (and fair few other things), , time returns, entire file has been processed. trying call dgifgetline() after doesn't make sense.

this dgif_lib.c says dgifslurp():

/******************************************************************************  routine reads entire gif core, hanging state info off  giffiletype pointer.  call dgifopenfilename() or dgifopenfilehandle()  first initialize i/o.  inverse egifspew(). *******************************************************************************/ 

Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

qt - Errors in generated MOC files for QT5 from cmake -