Jump to content
  • Advertisement
Sign in to follow this  

XNA Gif Library Help

This topic is 2556 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I've been trying to get GIF support in my XNA projects and the only XNA GIF Library I could find was this one.

First I tried the original code then I tried duplicating it (almost word for word), but I still get this error:

Argument Exception was unhandled
The size of the data passed in is too large or too small for this resource.

However, when I do the math myself, it should work fine.

My width is 550, height 400. That should be a size of 880000 as per the instructions I found here.

When I debug the locals they come out as such.

I'm not really sure what's going wrong.

The code with the error:

namespace AnimatedSprite
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;
using System;
using Microsoft.Xna.Framework;

public sealed class AnimatedSpriteContentTypeReader : ContentTypeReader<AnimatedSprite>
protected override AnimatedSprite Read(ContentReader input, AnimatedSprite existingInstance)
int num = input.ReadInt32();
Texture2D[] frames = new Texture2D[num];
IGraphicsDeviceService service = (IGraphicsDeviceService)input.ContentManager.ServiceProvider.GetService(typeof(IGraphicsDeviceService));
if (service == null)
throw new ContentLoadException();
GraphicsDevice graphicsDevice = service.GraphicsDevice;
if (graphicsDevice == null)
throw new ContentLoadException();
for (int i = 0; i < num; i++)
SurfaceFormat format = (SurfaceFormat)input.ReadInt32();
int width = input.ReadInt32();
int height = input.ReadInt32();
int numberLevels = input.ReadInt32();
frames = new Texture2D(graphicsDevice, width, height, false, format);
for (int j = 0; j < numberLevels; j++)
int count = input.ReadInt32();
byte[] data = input.ReadBytes(count);
Rectangle? rect = null;
frames.SetData<byte>(j, rect, data, 0, data.Length); // ERROR OCCURS ON THIS LINE
return AnimatedSprite.FromTextures(frames);

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!