title: Byte Array to 2D array
body: <p>What My code does . is take a snapshot of the map convert it to gray (opencv) and then make it to byte array. 
  Now what I dont know how to start doing is making this Bytearray to a 2D Array, </p>
  
  <p>here is a block of the code.</p>
  
  <pre><code>                    Date now = new Date();
                      android.text.format.DateFormat.format("yyyy-MM-dd_hh:mm:ss",now);
                      try {
                          StrictMode.ThreadPolicy old = StrictMode.getThreadPolicy();
                          StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder(old)
                                  .permitDiskWrites()
                                  .build());
                          String mPath = Environment.getExternalStorageDirectory().toString() + "/" + now + ".jpg";
                          File imageFile = new File(mPath);
                          FileOutputStream out = new FileOutputStream(imageFile);
                          bitmap.compress(Bitmap.CompressFormat.PNG,90,out);
                          Log.d("Image:","Saved Snashot. Starting covertion");
                          //show snapshot in imageview
                          ImageView imgview = (ImageView) findViewById(R.id.imageView);
                          Bitmap smyBitmap = BitmapFactory.decodeFile(mPath);
                          Bitmap myBitmap = BitmapFactory.decodeFile(mPath);
                          imgview.setImageBitmap(smyBitmap);
                          Mat mat = new Mat(myBitmap.getHeight(),myBitmap.getWidth(),CvType.CV_8UC3);
                          Mat mat1 = new Mat(myBitmap.getHeight(),myBitmap.getWidth(),CvType.CV_8UC1);
                          Imgproc.cvtColor(mat,mat1,Imgproc.COLOR_BGR2GRAY);
                          ImageView imgview2 = (ImageView) findViewById(R.id.imageView2);
                              Mat tmp = new Mat (myBitmap.getWidth(), myBitmap.getHeight(), CvType.CV_8UC1);
                              Utils.bitmapToMat(myBitmap, tmp);
                              Imgproc.cvtColor(tmp, tmp, Imgproc.COLOR_RGB2GRAY);
                              Utils.matToBitmap(tmp, myBitmap);
                            //  Utils.matToBitmap(mat1,img);
                          String mPathgray = Environment.getExternalStorageDirectory().toString() + "/" + now + "gray.jpg";
                          File imageFilegray = new File(mPathgray);
                          FileOutputStream gout = new FileOutputStream(imageFilegray);
  
                          bitmap.compress(Bitmap.CompressFormat.PNG,90,gout);
  
                          byte[] byteArray = bttobyte(myBitmap);
                          Log.d("location"," " + mPathgray);
                              imgview2.setImageBitmap(myBitmap);
  
                          Log.d("Activity", "Byte array: "+ Arrays.toString(byteArray));
  
                      }
  
                      catch (Exception e) {
                          e.printStackTrace();
                      }
                  }
              };
              mMap.snapshot(callback);
              Log.d("test","test2");
          }
      });
  
  }
  
  public byte[] bttobyte(Bitmap bitmap) {
      ByteArrayOutputStream stream = new ByteArrayOutputStream();
      bitmap.compress(Bitmap.CompressFormat.JPEG, 70, stream);
      return stream.toByteArray();
  }
  </code></pre>