title: Crop image from byte array
body: <p>My app let the user take a picture with the camera and return a byte array containing the image data (jpeg at the moment but can be modified).</p>
  
  <p>If we know the width and height of the picture, is it possible to use </p>
  
  <pre><code>BitmapFactory.decodeByteArray(data, offset, length)
  </code></pre>
  
  <p>To decode the picture from specified offset to get a squared picture ?</p>
  
  <p>The image is in high res (portrait) and I only need the squared bottom of this picture still in high res for image processing.</p>
  
  <pre><code>x offset = 0
  y offset = height - width
  width = width
  height = width
  </code></pre>
  
  <p>I have seen <a href="https://stackoverflow.com/questions/6818415/crop-image-directly-from-byte-array">this</a> answer but I still was wondering if this was possible. I could compress image data with another format if needed</p>
  
  <p>My guess was to compute the number of bytes used to store <code>n</code> rows of pixels (using known dimensions), where <code>n = maxRows - pictureWidth</code></p>
  
  <p>and then start from computed offset</p>