Img To Byte Array

Posts 12 of 2 · Page 1 of 1
Img To Byte Array
Any One Can you Give me a

File2ByteArray or Image To Byte Array
vb.net code, hope this helps. gives raw pixel data only. The two arrays.

Code:
    Public Shared Function IsImageInImageFast(ByRef bigImage As Bitmap, ByRef smallImage As Bitmap) As Point

        '' Lock the bitmap. Pin in memory.
        Dim _smallBmpData As System.Drawing.Imaging.BitmapData = smallImage.LockBits(New Rectangle(0, 0, smallImage.Width, smallImage.Height), Imaging.ImageLockMode.ReadOnly, smallImage.PixelFormat)
        Dim _bigBmpData As System.Drawing.Imaging.BitmapData = bigImage.LockBits(New Rectangle(0, 0, bigImage.Width, bigImage.Height), Imaging.ImageLockMode.ReadOnly, bigImage.PixelFormat)
        ''Calculate number of bytes in each image
        Dim _smallBmpLength As Int32 = _smallBmpData.Stride * _smallBmpData.Height
        Dim _bigBmpLength As Int32 = _bigBmpData.Stride * _bigBmpData.Height
        ''Crate arrays to copy the data to
        Dim _smallBmpBytes(_smallBmpLength - 1) As Byte
        Dim _bigBmpBytes(_bigBmpLength - 1) As Byte
        ''Copy the data to the arrays
        System.Runtime.InteropServices.Marshal.Copy(_smallBmpData.Scan0, _smallBmpBytes, 0, _smallBmpLength)
        System.Runtime.InteropServices.Marshal.Copy(_bigBmpData.Scan0, _bigBmpBytes, 0, _bigBmpLength)
        '' Restore (unlock) the bitmaps
        smallImage.UnlockBits(_smallBmpData)
        bigImage.UnlockBits(_bigBmpData)
        ''Work with the new arrays
        '' ...
Posts 12 of 2 · Page 1 of 1
This thread is closed for replies.

Similar Threads

Tags for this Thread

None

Need help?