我希望將畫布保存為 mySql blob 字段中的 blob (I am looking to save a canvas as a blob in mySql blob field)


問題描述

我希望將畫布保存為 mySql blob 字段中的 blob (I am looking to save a canvas as a blob in mySql blob field)

the toBlob method of canvas doesn't seem to work for me, so i have used toDataUrl and then sent the data it produces to a controller with ajax, i've then put this data in2 a byte [] to convert it 2 a blob but the data changes from data:image/png;base64,iVBORw0KGgoAAAANSUhEU.... like so to an array of numbers [100, 97, 116, 97, 58, 105, 109, 97, 103, 101, 47, 112, 110... like so, when calling the blob back i would like to change the byte [] of numbers back to the original data. is this possible and if so could somebody please give me some advise on how to do it, thanks

‑‑‑‑‑

參考解法

方法 1:

Please see what I wrote here on the matter. I'll paste it below for your convenience. The short answer is toBlob is too new to use, and just because something is in the spec doesn't mean its ready.

toBlob() is really new and I would not recommend using it in a consumer app unless you can explicitly ask them to use a particular browser (or else control the environment).

toBlob() Was added on May 12th and is of limited functionality as‑defined. It does not exist in the Chrome nightly, firefox nightly, nor IE9.

It is worth noting that Firefox does have a functional mozGetAsFile

There is yet to even be any discussion for adding it to Chrome.

The discussion for Firefox. They have decided to wait until the spec is more clear before they attempt an implementation.

The spec for toBlob() is very vague with a lot of internal questions still unresolved. They aren't even sure what params to allow for typical toBlobl() use yet.

(by user855613Simon Sarris)

參考文件

  1. I am looking to save a canvas as a blob in mySql blob field (CC BY‑SA 3.0/4.0)

#bytearray #blob #canvas #html






相關問題

更改創建 XML 閱讀器時使用的 XmlDictionaryReaderQuotas 對象的 MaxArrayLength 屬性 (Changing the MaxArrayLength property on the XmlDictionaryReaderQuotas object used when creating the XML reader)

將文件讀入 4 個字節的 ByteArrays (Read file into ByteArrays of 4 bytes)

使用套接字 (C#) 進行文件傳輸 - 接收到的文件不包含完整數據 (File transfer using sockets (C#) - received file doesn't contain full data)

將 Java 字節讀取器轉換為 InputStream (Converting a Java byte reader to an InputStream)

用 bigInteger 和其他方法重建字節數組 (Rebuild byte array with bigInteger and other method)

如何將字節數組作為參數發送到 HTML.Action? (How to send byte array as paramater to HTML.Action?)

如何將存儲在字節數組中的圖像加載到 WebView? (How to load an image stored in a byte array to WebView?)

我希望將畫布保存為 mySql blob 字段中的 blob (I am looking to save a canvas as a blob in mySql blob field)

將字節數組的部分轉換為整數值 (Converting sections of byte arrays to integer values)

從內存中釋放 jni 引用 (Freeing jni references from memory)

為什麼 JPGEncoded bytearray 從 AS3 發送到 AMFPHP 會導致圖像無效? (Why is JPGEncoded bytearray sent from AS3 to AMFPHP resulting in an invalid image?)

Java:字節到浮點數/整數 (Java: Bytes to floats / ints)







留言討論