How to send part of a YUV image to a server?
<p>My application grabs a preview frame from the camera in YUV and sends it to a server.  I'm trying to change it so it will only send part of the image (a crop) to the server.  However I want to loop through the byte array and directly send the cropped image to the server, rather than creating a Bitmap class and cropping it that way.</p>

<p>My goal is to be as efficient as possible.</p>

<p>Does anyone have some pseudocode (or even better actual code) for cropping YUV images?</p>

<p>I'd like the code to work something like this:</p>

<pre><code>OutputStream out = clientSocket.getOutputStream();
byte[] preview = getCameraPreview();
//Crop half of the image
int x = (int)(getX()/2);
int y = (int)(getY()/2);
//Send the width, height, and image size to the server
out.write(intToByteArray(x));
out.write(intToByteArray(y));
out.write(intToByteArray((int)(x*y)));
//Start sending the picture to the server
for(int i = 0; i &lt; y; i++)
    for(int j = 0; j &lt; x; j++)
        out.write(preview[i+j]);
</code></pre>

<p>I know that code doesn't work at all, but hopefully you get the idea of what I'm trying to do.</p>

<p>Any help will be appreciated.</p>
