Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using stbi_load_gif_from_memory results in incorrect image data for each frame of the GIF #1688

Closed
pudding186 opened this issue Sep 22, 2024 · 6 comments · May be fixed by #1702
Closed

Using stbi_load_gif_from_memory results in incorrect image data for each frame of the GIF #1688

pudding186 opened this issue Sep 22, 2024 · 6 comments · May be fixed by #1702

Comments

@pudding186
Copy link

After rendering each frame of the GIF, I noticed that some images are not correct.
horse-1237_256
frame

@pudding186
Copy link
Author

@cocoa-xu thanks for your help, I applied your patch, but it seems that the issue still persists. You can try it with my horse GIF.

@pudding186
Copy link
Author

@cocoa-xu Thank you so much. The problem is solved. I hope the author @nothings can merge your pull request soon.

@pudding186 pudding186 reopened this Oct 8, 2024
@pudding186
Copy link
Author

@cocoa-xu Thank you again for your help. In my program, I merge each frame's texture into a large texture, and then use UV coordinates based on the delay time read from the GIF to display the animation. I found that the following code seems to be necessary for correct display:

if (dispose == 3) {
// background is what out is after the undoing of the previous frame;
memcpy(g->background, g->out, 4 * g->w * g->h);
}
Please try this

@cocoa-xu
Copy link

cocoa-xu commented Oct 8, 2024

@cocoa-xu Thank you again for your help.

Not a problem!

In my program, I merge each frame's texture into a large texture, and then use UV coordinates based on the delay time read from the GIF to display the animation. I found that the following code seems to be necessary for correct display:

if (dispose == 3) {
// background is what out is after the undoing of the previous frame;
memcpy(g->background, g->out, 4 * g->w * g->h);
}
Please try this

Ah I wasn't really sure about this, but I did get the same results when using if (dispose == 3) {.

I wonder if you happen to have any example file(s) that you can share for this case, which gives wrong data if we use if (dispose == 2 || dispose == 3) { while returning the correct data when we do if (dispose == 3) {.

@pudding186
Copy link
Author

pudding186 commented Oct 9, 2024

@cocoa-xu Thank you again for your help.

Not a problem!

In my program, I merge each frame's texture into a large texture, and then use UV coordinates based on the delay time read from the GIF to display the animation. I found that the following code seems to be necessary for correct display:
if (dispose == 3) {
// background is what out is after the undoing of the previous frame;
memcpy(g->background, g->out, 4 * g->w * g->h);
}
Please try this

Ah I wasn't really sure about this, but I did get the same results when using if (dispose == 3) {.

I wonder if you happen to have any example file(s) that you can share for this case, which gives wrong data if we use if (dispose == 2 || dispose == 3) { while returning the correct data when we do if (dispose == 3) {.

horse-1237_512
Yes, you can try this GIF file. In my program, I found that there are still incorrect frames when it is equal to 2 or equal to 3.
This is a screenshot of each frame from my program.
Snipaste_2024-10-09_11-44-42

@cocoa-xu
Copy link

cocoa-xu commented Oct 9, 2024

Okay gotcha, I've updated the PR! Thanks for sending the test file! ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants