0

I want you to know the methods to get the image from array of bytes :

I'am using this code but it's throw an exception ,if the size is more than 100 or the length of the arary,and if it's less than 50 it save a messay image

Bitmap b = new Bitmap(@"C:/difflena.jpg");

             byte[] pixels = lolo(b);
          MemoryStream stream = new MemoryStream(pixels, 0, pixels.Length);
          Bitmap bitmap = new Bitmap(stream);
          Image<Gray, byte> image = new Image<Gray, byte>(60, 60);
          image.Bytes = pixels;
          image.Save(file + "face" + "t" + ".bmp");
          if (image != null) { Label1.Text = "yes";


 public byte[] lolo(Bitmap n)
      {

          /*ImageFormat imageFormat = n.RawFormat;

          byte[] Ret=null;
          try
          {
              using (MemoryStream ms = new MemoryStream())
              {
                  n.Save(ms, imageFormat);
                  Ret = ms.ToArray();
              }

          }
          catch (Exception) { Label1.Text = "no"; }

          return Ret;}
Shiva
  • 6,677
  • 4
  • 36
  • 61
user2310851
  • 11
  • 1
  • 3
  • You have tagged this question in EmguCV, but the code i see, is not of emgucv,why are you just not using the `capture` object to read/manipulate the image if you intend to write EMGU code? – Shiva Mar 03 '14 at 06:25
  • you can check this thread to find more about matrices in EmguCV http://stackoverflow.com/questions/7197153/work-with-matrix-in-emgu-cv – Shiva Mar 03 '14 at 06:26

0 Answers0