Intel XDK에서 HTML5 앱을 만들므로 자바 스크립트로 계산됩니다.Javascript ByteBuffer to base64 문자열을 반환하지 않습니다.
사례 : 서버에서 (google) protobuf 메시지 받기. 객체를 파싱합니다. 거기에 이미지가 있습니다, jpg. Gonne은 이것을 HTML에 넣었습니다. 이봐, 당신은 base64를 사용할 수 있습니다. 안드로이드에서 이것을했습니다. 거기 당신은 BitmapFactory 사용할 수 있습니다
Bitmap bitmap = android.graphics.BitmapFactory.decodeStream(document.getDocBlob().newInput());
일부 구글 - Fu는이 같은 물건을 발견 한 후 : 여기
var base64String = btoa(String.fromCharCode.apply(null, new Uint8Array(currentComment.Document.doc_blob.buffer)));
var ByteBuffer = ProtoBuf.ByteBuffer;
var base64String = ByteBuffer.btoa(currentComment.Document.doc_blob.buffer, currentComment.Document.doc_blob.littleEndian, currentComment.Document.doc_blob.noAssert);
는 난관이다를 이미지가 표시되지 않습니다 : 그것은 깨진 링크 이미지를 보여줍니다. 그러나 위의 첫 번째 함수를 사용하면 오류가 발생하지 않습니다. 내가 잘못 생각한 부분은 오프셋 된 부분입니다. 데이터 구조는 다음과 같습니다
buffer: ArrayBuffer
byteLength: 148199
__proto__: ArrayBuffer
limit: 69895
littleEndian: true
markedOffset: -1
noAssert: false
offset: 44278
view: DataView
HTML로 설정이과 같이 수행하고, 다른 base64로 문자열로 테스트 한 작동합니다
commentImage = document.getElementById("img-frame");
var source = "data:image/" + image_type + ";base64," + base64String;
commentImage.setAttribute("height", currentComment.Document.doc_height);
commentImage.setAttribute("width", currentComment.Document.doc_width);
commentImage.setAttribute("src", source);