尝试将此作为临时解决方法:
首先添加以下类:
public static class PlurkInputStream extends FilterInputStream {
protected PlurkInputStream(InputStream in) {
super(in);
}
@Override
public int read(byte[] buffer, int offset, int count)
throws IOException {
int ret = super.read(buffer, offset, count);
for ( int i = 2; i < buffer.length; i++ ) {
if ( buffer[i - 2] == 0x2c && buffer[i - 1] == 0x05
&& buffer[i] == 0 ) {
buffer[i - 1] = 0;
}
}
return ret;
}
}
然后用 PlurkInputStream 包装你的原始流:
Bitmap bitmap = BitmapFactory.decodeStream(new PlurkInputStream(originalInputStream));
让我知道这是否对您有帮助。
编辑:
抱歉,请尝试以下版本:
for ( int i = 6; i < buffer.length - 4; i++ ) {
if ( buffer[i] == 0x2c ) {
if ( buffer[i + 2] == 0 && buffer[i + 1] > 0
&& buffer[i + 1] <= 48 ) {
buffer[i + 1] = 0;
}
if ( buffer[i + 4] == 0 && buffer[i + 3] > 0
&& buffer[i + 3] <= 48 ) {
buffer[i + 3] = 0;
}
}
}
请注意,这不是有效的代码,也不是完整/正确的解决方案。它适用于大多数情况,但不是全部。