1

XNA で Texture2D.FromStream() を使用して、ストリームの途中からテクスチャをロードできるかどうか疑問に思っていました。アイデアは、四肢のテクスチャを、タイミング、名前などの他の情報を含むファイルに直接保存するアニメーション システムがあるということです...私の問題は、ファイルをロードしようとしたときに発生します。テクスチャの読み込み。InvalidOperationExecption が表示されますが、実際の詳細はありません。これまでの私のコードは次のとおりです。

書き込み:

...         
//writes the name
binWriter.Write(name);

if (texture != null)
{
    binWriter.Write(true);
    //save the texture into the stream
    texture.SaveAsPng(binWriter.BaseStream, texture.Width, texture.Height);
}
else
    binWriter.Write(false);

//writes the ID of the parent limb
binWriter.Write(system.getParentID((Limb)parent));
...

読む:

...
string name = binReader.ReadString();

Texture2D tex = null;

//gets the texture if it exists
bool texture = binReader.ReadBoolean();
if (texture)
    tex = Texture2D.FromStream(graphics, binReader.BaseStream);

//finds the index of the parent limb
int parentID = binReader.ReadInt32();
...

何か案は?

-編集-解決!getData() および setData() メソッドを使用して、データを uint の配列として読み書きしました。

4

0 に答える 0