Moin,
Ich hab n Programm geschrieben , dass ne Textur laden soll , doch es spuckt mir immer an der stelle ne OutofBoundsException aus.
Ich hol mir den Stream aus nem ZipArchiv
Es ligt definitiv nich an der id-Variable , das hab ich überprüft.
Wäre nett wenn einer ne Antwort wüste.
Ich hab n Programm geschrieben , dass ne Textur laden soll , doch es spuckt mir immer an der stelle ne OutofBoundsException aus.
Code:
textures[id] = TextureLoader.FromStream(device, ZipReader.getStream(pak, file));
Ich hol mir den Stream aus nem ZipArchiv
Code:
internal static Stream getStream(string file, string streamObject)
{
Stream ret = null;
try
{
/*string[] s = streamObject.Split('/');
streamObject = "";
for (int i = 0; i < s.Length; i++)
{
streamObject = streamObject + s[i];
if (i < s.Length - 1)
streamObject = streamObject + "\\";
}*/
ZipInputStream zis = new ZipInputStream(File.OpenRead(file));
ZipEntry ressource;
int nBytes = 2048;
byte[] data = new byte[2048];
while ((ressource = zis.GetNextEntry()) != null)
{
if (ressource.IsFile && ressource.Name.Equals(streamObject))
{
MemoryStream ms = new MemoryStream();
while ((nBytes = zis.Read(data, 0, data.Length)) > 0)
{
ms.Write(data, 0, nBytes);
}
ret = ms;
}
}
}
catch (Exception e)
{
MessageBox.Show(e.Message);
}
return ret;
}
Es ligt definitiv nich an der id-Variable , das hab ich überprüft.
Wäre nett wenn einer ne Antwort wüste.