Out of Memory

gpmaker

Member
Joined
Jun 3, 2004
Messages
24
OK, I'm going crazy. I run this code in a program:
VB.NET:
[size=2][color=#0000ff]Dim[/color][/size][size=2] s1, s2 [/size][size=2][color=#0000ff]As[/color][/size][size=2] FileStream[/size]
[size=2][color=#0000ff]Dim[/color][/size][size=2] br [/size][size=2][color=#0000ff]As[/color][/size][size=2] BinaryReader[/size]
[size=2][color=#0000ff]Dim[/color][/size][size=2] bw [/size][size=2][color=#0000ff]As[/color][/size][size=2] BinaryWriter[/size]
[size=2][color=#0000ff]Dim[/color][/size][size=2] filename [/size][size=2][color=#0000ff]As [/color][/size][size=2][color=#0000ff]String
[/color][/size][size=2][color=#0000ff]If[/color][/size][size=2] OpenFileDialog1.ShowDialog() = DialogResult.OK [/size][size=2][color=#0000ff]Then[/color][/size]
[size=2]	filename = OpenFileDialog1.FileName[/size]
[size=2][color=#0000ff]End[/color][/size][size=2][color=#0000ff]If
[/color][/size][size=2]s1 = [/size][size=2][color=#0000ff]New[/color][/size][size=2] FileStream(filename, FileMode.Open, FileAccess.Read)[/size]
[size=2]s2 = [/size][size=2][color=#0000ff]New[/color][/size][size=2] FileStream("C:\test.gif", FileMode.CreateNew, FileAccess.Write)[/size]
[size=2]br = [/size][size=2][color=#0000ff]New[/color][/size][size=2] BinaryReader(s1)[/size]
[size=2]bw = [/size][size=2][color=#0000ff]New[/color][/size][size=2] BinaryWriter(s2)[/size]
[size=2]
[/size][size=2][color=#0000ff]Dim[/color][/size][size=2] y [/size][size=2][color=#0000ff]As [/color][/size][size=2][color=#0000ff]Integer[/color][/size]
[size=2][color=#0000ff]Dim[/color][/size][size=2] byteread [/size][size=2][color=#0000ff]As [/color][/size][size=2][color=#0000ff]Byte[/color][/size]
[size=2][color=#0000ff]Dim[/color][/size][size=2] i [/size][size=2][color=#0000ff]As [/color][/size][size=2][color=#0000ff]Boolean[/color][/size]
[size=2][color=#0000ff]
[/color][/size][size=2][color=#0000ff]For[/color][/size][size=2] y = 0 [/size][size=2][color=#0000ff]To[/color][/size][size=2] br.BaseStream.Length() - 1[/size]
[size=2]byteread = br.ReadByte[/size]
[size=2]i = [/size][size=2][color=#0000ff]Not[/color][/size][size=2] (i)[/size]
[size=2][color=#0000ff]If[/color][/size][size=2] i = [/size][size=2][color=#0000ff]True [/color][/size][size=2][color=#0000ff]Then[/color][/size]
[size=2]	 bw.Write(byteread)[/size]
[size=2][color=#0000ff]End [/color][/size][size=2][color=#0000ff]If[/color][/size]
[size=2][color=#0000ff]Next
[/color][/size][size=2]br.Close()
bw.Close()
[/size][size=2][color=#0000ff]Dim[/color][/size][size=2] temp [/size][size=2][color=#0000ff]As[/color][/size][size=2] Bitmap = Image.FromFile("C:\test.gif")[/size]
[size=2]MsgBox("Sucessful")
[/size]
Now I'm skipping every other character, because when I made the file, I added an extra 1 infront of every byte, so other programs couldn't read the file. Now, this works great, but when I run this exact same code as a function on my other program. It stops at Dim temp As Bitmap = Image.FromFile("C:\test.gif") and says Out Of Memory. I don't get it, it's the same code!

BTW:This is the first thing that runs on my other program where the code doesn't work
 

gpmaker

Member
Joined
Jun 3, 2004
Messages
24
Solved it. I forgot to update one of the files that's suppose to be decoded, so the program got stuck trying to decode the old file with the new system
 
Top Bottom