I've made a screen capture program, and I have a program to play back the captured clips (right now there's no sound). All of the data is stored like so:
Frames per second, as a Byte
Width of each bitmap, as an Integer
Height of each bitmap, as an Integer
All of the bitmaps' data (24 bits per pixel)
In the playback form, I have a function to read the next bitmap from the file, using the stored width and height:
I get an error on the Marshal.Copy line: "AccessViolation exception was unhandled: Attempted to read or write protected memory. This is often an indication that other memory is corrupt." I suppose that this means that I'm writing too much data to the area in memory specified by the pointer, but I don't see how. The b() array seems to be in working order. Can anyone help? The file saves just fine.vb.net Code:
Private Sub LoadNextBitmap() Try If m_Deserializer.PeekChar() = -1 Then Exit Sub Catch ex As Exception End Try m_CurBitmap = New Bitmap(w, h, PixelFormat.Format24bppRgb) Dim bpbmp As Integer = w * h * 3 Dim bdata As BitmapData = m_CurBitmap.LockBits(New Rectangle(0, 0, w, h), ImageLockMode.ReadWrite, PixelFormat.Format24bppRgb) ' ^ I've also tried ImageLockMode.ReadOnly, no success. Dim b(bpbmp - 1) As Integer For i As Integer = 0 To bpbmp - 1 b(i) = m_Deserializer.ReadByte() Next Marshal.Copy(b, 0, bdata.Scan0, bpbmp) '<-- error here m_CurBitmap.UnlockBits(bdata) End Sub




Reply With Quote