Position of frames in animated gif

Discussions on GFL SDK, the graphic library for reading and writing graphic files

Moderators: helmut, XnTriq, xnview

Post Reply
Alessandro

Position of frames in animated gif

Post by Alessandro »

Hi,

I thought I had solved my problems during the loading of animated gif files, instead lately I've found a file which I couldn't load properly.
Looks like some of the frames are smaller than frame 0 and I dunno where to place them inside the canvas because I don't find offset values in GFL_BITMAP or in other structures.
Right now I can only place them on top-left of canvas but of course the animation doesn't look good.

Thanks in advance for your reply.
Alessandro

Post by Alessandro »

Hi,
to position the frames inside the canvas I used a code like follows:

Code: Select all

int LeftOfNewFrame=(gflBmp->Origin & GFL_RIGHT)!=0 ? WidthOfFirstFrame- WidthOfNewFrame: 0;
int TopOfNewFrame=(gflBmp->Origin & GFL_BOTTOM)!=0 ? HeightOfFirstFrame-HeightOfNewFrame : 0;
but I still don't obtain the correct positions

I've also found out where the framerate is stored:

Code: Select all

typedef struct { // 6 bytes
	unsigned char iBlockSize;           // Must be 4
	unsigned char iTransparentColorFlag : 1;
	unsigned char iUserInputFlag : 1;
	unsigned char iDisposalMethod : 3;
	unsigned char iReserved : 3;
	unsigned short iDelayTime;
	unsigned char iTransparentColorIndex;
	unsigned char iBlockTerminator;     // Must be 0
} GIF_GRAPHIC_CONTROL_EXTENSION;
yet the positon of this tructure changes so I dunno how to find the offset from the start of the file....
Can you help me?
Please, at least say "I don't know"...if that's the case
Thanks.
User avatar
xnview
Author of XnView
Posts: 46236
Joined: Mon Oct 13, 2003 7:31 am
Location: France
Contact:

Re: Position of frames in animated gif

Post by xnview »

Alessandro wrote:Hi,

I thought I had solved my problems during the loading of animated gif files, instead lately I've found a file which I couldn't load properly.
Looks like some of the frames are smaller than frame 0 and I dunno where to place them inside the canvas because I don't find offset values in GFL_BITMAP or in other structures.
Right now I can only place them on top-left of canvas but of course the animation doesn't look good.
Currently there is no way to retrieve frame position...
Pierre.
Alessandro

Post by Alessandro »

Weird, xnview can show animated gif files properly...
User avatar
xnview
Author of XnView
Posts: 46236
Joined: Mon Oct 13, 2003 7:31 am
Location: France
Contact:

Post by xnview »

Alessandro wrote:Weird, xnview can show animated gif files properly...
Yes, but xnview doesn't use GFL (or internal library) to show animated gif
Pierre.
Alessandro

Post by Alessandro »

Do you plan to add the needed fields sooner or later or should I start to write a workaround myself (if I can find enough info of course)?
User avatar
xnview
Author of XnView
Posts: 46236
Joined: Mon Oct 13, 2003 7:31 am
Location: France
Contact:

Post by xnview »

Alessandro wrote:Do you plan to add the needed fields sooner or later or should I start to write a workaround myself (if I can find enough info of course)?
But perhaps better for you will be to load the merged frame?
Because in GIF, you have not only the offset, but the copy method, palette change, ...
Pierre.
Alessandro

Post by Alessandro »

Change of palette doesn't really matter since I convert frames to rgb32, anyway I read thoroughly the help file and I can't recall a way to load merged frames excluding frame 0 which is only one frame (and not enough then to show animations), but if such an option is available of course it IS be better to me to use it, so... how can I do it?
User avatar
xnview
Author of XnView
Posts: 46236
Joined: Mon Oct 13, 2003 7:31 am
Location: France
Contact:

Post by xnview »

Alessandro wrote:Change of palette doesn't really matter since I convert frames to rgb32, anyway I read thoroughly the help file and I can't recall a way to load merged frames excluding frame 0 which is only one frame (and not enough then to show animations), but if such an option is available of course it IS be better to me to use it, so... how can I do it?
You want only show animation?
Pierre.
Alessandro

Post by Alessandro »

yes, and I'd like to show it properly
User avatar
xnview
Author of XnView
Posts: 46236
Joined: Mon Oct 13, 2003 7:31 am
Location: France
Contact:

Post by xnview »

Alessandro wrote:yes, and I'd like to show it properly
Ok, i'll such feature
Pierre.
Alessandro

Post by Alessandro »

what can I say, I'm speechless... THANKS!!!
Post Reply