Using AsImageData from Bitmap

Rach
2014-04-13
2014-04-14
  • Rach

    Rach - 2014-04-13

    Hello,

    I am a beginner in C # , however I was able to compile version 1.6 to use a
    Windows CE project. I want to generate templates for finger from bitmap. I
    am unable to use the AsImageData property (because it is the only available
    in CF) .

    I do this : myfinger.AsImageData ConvertBitmap = ( flag ) ;
    But the program crashes immediately at runtime.

    How should we use to generate the fingerprint AsImageData ?

    ConvertBitmap () is a method to convert Bitmap as array of bytes .

    Below is the source of the method ConvertBitmap

        private byte [] ConvertBitmap ( Bitmap bitmap)
        {
            / / Code excerpted from Microsoft Robotics Studio v1.5
            Raw BitmapData = null; / / used to get attributes of the picture
            byte [] rawImage = null; / / the picture as a byte []
    
            try
            {
                / / Freeze the picture in memory
                Bitmap.LockBits raw = (
                    new Rectangle ( 0, 0, (int) Bitmap.Width , (int)
    

    bitmap.Height )
    ImageLockMode.ReadOnly ,
    PixelFormat.Format24bppRgb
    ) ;

                int size = * raw.Height raw.Stride ;
                rawImage = new byte [ size] ;
    
                / / Copy the picture into the byte []
                System.Runtime.InteropServices.Marshal.Copy ( raw.Scan0 ,
    

    rawImage , 0 , size) ;
    }
    finally
    {
    if ( raw! = null)
    {
    / / Unfreeze the memory for the picture
    bitmap.UnlockBits ( raw) ;
    }
    }
    rawImage return ;
    }

     
  • Robert Važan

    Robert Važan - 2014-04-14

    Is this question any different from your previous one?

     

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks