XNA GIF动画库问题
嘿伙计们,我正在尝试使用我在网上找到的 XNA Gif 动画库,然后当我运行时,它不断给我一个异常,说“传入的数据大小对于该资源来说太大或太小。”对于 GifAnimationContentTypeReader 的
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[i] = 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[i].SetData<byte>(j, rect, data, 0, data.Length);
}
}
这一行“frames[i].SetData(j, rect, data, 0, data.Length);” 我不知道怎么回事,但数据长度确实很大,但
有人知道这是怎么发生的 谢谢
hey guys, i am trying to use the XNA Gif Animation Library that i found online, then when i running , it keep givving me an exception said "The size of the data passed in is too large or too small for this resource." for GifAnimationContentTypeReader
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[i] = 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[i].SetData<byte>(j, rect, data, 0, data.Length);
}
}
at this line "frames[i].SetData(j, rect, data, 0, data.Length);"
I donno how, but the data length is really huge though
Anyone know hows that happen
thx
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
字节数(在代码中:
count
和data.Length
)应等于width * height * bytesPerPixel
,其中>bytesPerPixel
取决于数据格式(默认的SurfaceFormat.Color
格式为 4)。如果不相等,则说明该纹理没有足够的数据(或数据太多)。
您在问题中没有提供足够的详细信息,因此我无法告诉您为什么您的值不相等。
The number of bytes (in your code:
count
anddata.Length
) should be equal towidth * height * bytesPerPixel
, where thebytesPerPixel
depends on the data format (for the defaultSurfaceFormat.Color
format it is 4).If it is not equal, you don't have enough data (or have too much data) for the that texture.
You haven't provided enough detail in your question for me to be able to tell you why your the values are not equal.
你的代码有错误。
使用此代码:
}
Your code has bug.
Use this code:
}