I have a Galaxy Note device and I wrote an application that grabs uimages from the camera. I have set the layout to landscape and I am able to grab images with my device. The problem is when I run the same program on someone else's device. The program runs the same on the other device, but when saving a picture the content of the picture is wrong. You see slightly diagonal strpies instead of the image content. I think it's the result of the image being saved with the wrong pitch or resolution. The thumbnail of the "bugged" picture on the other device is for some kind of a reason corret. I have tried to find the difference between my device and the other device, but apart from one having a resolution of 1280x800 and the other of 800x480, I didn't find any difference. In both cases the Measur and Layout functions have a 90 degrees orientation and the correct landscape resolution. In both cases the image format is JPEG(by inquiring mCamera.getParameters().getPictureFormat()). I am stumped, I am don't know what to do, because everything seems the same except that one device spits the correct JPEG byte array, and the other gives me the correct data but with the wrong orientation. Or so it seems.
EDIT: I found that there is an issue even when I save the raw data straight into a JPEG file, so no display or decode is involved. I can see in the Gallery browser that the JPEG file has artifacts, is wrong somehow. My code for saving the camera data into a (JPEG) file is as following:
private File onJPGPreviewFrame(byte[] data, String Name) {
FileOutputStream outStream = null;
File f = null;
try {
if(Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) {
File externalRoot = Environment.getExternalStorageDirectory();
File tempDir = new File(externalRoot, Name);
tempDir.createNewFile();
outStream = new FileOutputStream(tempDir);
outStream.write(data);
outStream.close();
f = tempDir;
}
Log.d(TAG, "onPreviewFrame - wrote bytes: " + data.length);
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} finally {
}
return f;
}