카메라로 찍은 몇 개의 JPEG 파일을 서버에 보내야합니다. 물론 그들은 파일 스트림으로 간단히 처리 할 수 있습니다. 아웃 "Android : JPEG의 조기 말림
Object[] params3 = { bid, login, pass, struct3 };
Object response2 = client.send("my_function", params3);
내가 모두가 올바른지 작은 파일을 보내지 만 파일이있는 경우 더 큰 내가받은 : 나는 구조체를 보내 결국
struct3.put("type", "image/jpeg");
f = new File(fileName);
FileInputStream fis = new FileInputStream(f);
BufferedInputStream bis = new BufferedInputStream(fis);
byte[] buffer = new byte[(int)f.length()];
bis.read(buffer);
fis.close();
struct3.put("bits", buffer);
: (각 파일에 대한) 내 코드는 다음과 같습니다 of Memory Exception "을 참조하십시오.
그 내 솔루션 JPEG 파일을 압축하는 것입니다
struct3.put("type", "image/jpeg");
final Options opts = new Options();
opts.inSampleSize = 2;
Bitmap bitmap = BitmapFactory.decodeFile(fileName, opts);
ByteArrayOutputStream stream = new ByteArrayOutputStream();
bitmap.compress(Bitmap.CompressFormat.JPEG, 70, stream);
byte[] byteArray = stream.toByteArray();
struct3.put("bits", byteArray);
Object[] params3 = { bid, login, pass, struct3 };
Object response2 = client.send("my_function", params3);
하지만 그 방법은 서버 측에서 오류 발생 : "JPEG 파일의 조기 종료를".
JPEG 파일을 보내기 전에 수정하는 방법이 있습니까? 나는 EOI (0xff, 0xfd)로 끝나는 JPEG를 알고있다.
어떻게 확인하고 수정합니까?
이 코드는 당신이 우리 고양이 보고서를 기록 보내 주시기 바랍니다 수있는 JPEG 파일을 압축하지 않는 것을 의미한다. –
사진이 WordPress에 업로드되고 gdlib에서만 트랙 만 경고되므로 로그 고양이 보고서가 없습니다. 경고에는 "JPEG 파일의 조기 종료" – cronik