I am trying to save bitmaps from my propertygrid and compress them into an already created zip with sharpziplib. I have the zip file creation and compression routines working alright.
I convert the bitmap to a byte array with this:
The object in the property grid is of type system.drawing.image. The problem is the images are compressed in the zip correctly but you cannot open the images. They are corrupt every time. I am not using comrpession on the zip. Any help would be greatly appreciated.Code:Public Shared Function Bitmap_To_ByteArray(ByRef bmp As Bitmap) As Byte() Dim bdata As New BitmapData bdata = bmp.LockBits(New Rectangle(New Point(), bmp.Size), _ ImageLockMode.ReadOnly, PixelFormat.Format24bppRgb) Dim bcount As Integer = bdata.Stride * bmp.Height Dim bmpbytes(bcount) As Byte Marshal.Copy(bdata.Scan0, bmpbytes, 0, bcount) bmp.UnlockBits(bdata) Return bmpbytes End Function




Reply With Quote