私はこの問題(http://code.google.com/p/zxing/issues/detail?id=178)をフォローしており、コメント#46の指示に従いましたが、samsung galaxys2ではうまくいきませんでした。
DecodeHandler.javaで回転を行った後に受信した画像を記録しましたが、奇妙なことが起こります。画像は回転して修正されているように見えますが、その上に緑色のフィルターのようなものがあります(以下のファイルを確認してください)。
誰かがこれを経験したか、これに対する解決策を持っていますか?
byte[] rotatedData = new byte[data.length];
for (int y = 0; y < height; y++) {
for (int x = 0; x < width; x++)
rotatedData[x * height + height - y - 1] = data[x + y * width];
}
int tmp = width; // Here we are swapping, that's the difference to #11
width = height;
height = tmp;
data = rotatedData;
PS:ファイルに書き込むためのコード
- このコードは、ローテーションを実行する前にbyte[]を渡すとうまく機能します。
- 回転させた後、画像は緑色になります
コード
public void writeFile(byte[] data,
String fileName,
int width, int height)
throws IOException{
FileOutputStream out = new FileOutputStream(fileName);
YuvImage im = new YuvImage(data, ImageFormat.NV21, width,
height, null);
Rect r = new Rect(0,0,width,height);
im.compressToJpeg(r, 100, out);
out.write(data);
out.close();
}