Intel XDKでHTML5アプリケーションを作成するので、計算はJavascriptで行われます。Javascript ByteBufferからbase64に文字列を戻しません
ケース:サーバーから(google)protobufメッセージを受信しています。オブジェクトを解析する。そこにはイメージがあります。 GonneはそれをHTMLに入れました。ねえ、あなたはそれのためにbase64を使うことができます... Androidでこれをしました。そこにはBitmapFactoryを使用することができます。
Bitmap bitmap = android.graphics.BitmapFactory.decodeStream(document.getDocBlob().newInput());
一部のGoogle-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);