한 파일에 여러개의 이미지 바이너리가 들어가 있고 파일 헤더에 바이너리 offset과 사이즈를 가지고 있어서 해당 위치에서
읽어 이미지를 디코드 하는 작업을 하고 있습니다..
private Bitmap imageDecoder(int offset, int size) {
DataInputStream in = null;
byte[] result = null;
Bitmap image = null;
try {
File readFile = new File(currentMemoInfo.fileName);
in = new DataInputStream(new FileInputStream(readFile));
//in.reset();
in.skipBytes(offset);
result = new byte[size];
in.readFully(result);
if (in.read(result) == result.length) {
/*
File saveFile = null;
saveFile = new File("/sdcard/fingerpop/imagetestAllfile.xml");
FileOutputStream out = new FileOutputStream(saveFile);
out.write(result);
out.close();*/
image = BitmapFactory.decodeStream(new ByteArrayInputStream(result));
}
} catch (IOException e) {
e.printStackTrace();
result = null;
}
finally {
try {
if (in != null)
in.close();
} catch (IOException e) {
e.printStackTrace();
}
}
return image;
}
대략 위의 함수에서 하는것과 같이 offset과 사이즈를 가지고 파일을 읽고 디코드 합니다..
그런데 offset값을 제대로 넣어도 읽은 바이트 따로 파일로 만들어서 보니까 잘못된 위치부터 읽습니다..
예를 들어 offset이 10이과 사이즈가 20이라면
10위치에서 읽어야 할 것을 30위치에서 20만큼의 길이를 읽습니다...ㅠㅠ 또 어떤것은 잙 읽기도 하는데.. 음.. 그러니까 헤더랑 다른
정보 다음 첫 바이너리는 위치를 잘 읽습니다.. 하지만 두번째 부터 말썽인데.. 첫 이미지 바이너리를 안읽고 두번째 위치부터 읽어도 말썽이네요..ㅠㅠ