why canvas toDataURL/save method NOT WORK correctly in android?
Unsolved
QML and Qt Quick
-
CANVAS base64data must less than 1018 ?
My qml code:
Canvas { id: canvas width: 150 height: 150 onPaint: { var ctx = getContext("2d"); ctx.fillStyle = Qt.rgba(1, 0, 0, 1); ctx.fillRect(0, 0, width, height); } } Button{ text: "save" onClicked: { console.log(canvas.toDataURL()) var res = canvas.save(localUrl + "/savedImage.png") //.... } }
the param
localUrl
set androidgetExternalFilesDir
in android orQDir::currentPath()
in win10when i click the BUTTON in win10, my program run normally, image is saved to my computer, and the file is correct. file size is 1.05kb.
Application output
tab output:base64 length: 1475
qml: data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAASwAAAEsCAYAAAB5fY51AAAACXBIWXMAAA7EAAAOxAGVKw4bAAAD7klEQVR4nO3UQQ0AIBDAMMC/58MCP7KkVbDX9syaBRBwfgcAvDIsIMOwgAzDAjIMC8gwLCDDsIAMwwIyDAvIMCwgw7CADMMCMgwLyDAsIMOwgAzDAjIMC8gwLCDDsIAMwwIyDAvIMCwgw7CADMMCMgwLyDAsIMOwgAzDAjIMC8gwLCDDsIAMwwIyDAvIMCwgw7CADMMCMgwLyDAsIMOwgAzDAjIMC8gwLCDDsIAMwwIyDAvIMCwgw7CADMMCMgwLyDAsIMOwgAzDAjIMC8gwLCDDsIAMwwIyDAvIMCwgw7CADMMCMgwLyDAsIMOwgAzDAjIMC8gwLCDDsIAMwwIyDAvIMCwgw7CADMMCMgwLyDAsIMOwgAzDAjIMC8gwLCDDsIAMwwIyDAvIMCwgw7CADMMCMgwLyDAsIMOwgAzDAjIMC8gwLCDDsIAMwwIyDAvIMCwgw7CADMMCMgwLyDAsIMOwgAzDAjIMC8gwLCDDsIAMwwIyDAvIMCwgw7CADMMCMgwLyDAsIMOwgAzDAjIMC8gwLCDDsIAMwwIyDAvIMCwgw7CADMMCMgwLyDAsIMOwgAzDAjIMC8gwLCDDsIAMwwIyDAvIMCwgw7CADMMCMgwLyDAsIMOwgAzDAjIMC8gwLCDDsIAMwwIyDAvIMCwgw7CADMMCMgwLyDAsIMOwgAzDAjIMC8gwLCDDsIAMwwIyDAvIMCwgw7CADMMCMgwLyDAsIMOwgAzDAjIMC8gwLCDDsIAMwwIyDAvIMCwgw7CADMMCMgwLyDAsIMOwgAzDAjIMC8gwLCDDsIAMwwIyDAvIMCwgw7CADMMCMgwLyDAsIMOwgAzDAjIMC8gwLCDDsIAMwwIyDAvIMCwgw7CADMMCMgwLyDAsIMOwgAzDAjIMC8gwLCDDsIAMwwIyDAvIMCwgw7CADMMCMgwLyDAsIMOwgAzDAjIMC8gwLCDDsIAMwwIyDAvIMCwgw7CADMMCMgwLyDAsIMOwgAzDAjIMC8gwLCDDsIAMwwIyDAvIMCwgw7CADMMCMgwLyDAsIMOwgAzDAjIMC8gwLCDDsIAMwwIyDAvIMCwgw7CADMMCMgwLyDAsIMOwgAzDAjIMC8gwLCDDsIAMwwIyDAvIMCwgw7CADMMCMgwLyDAsIMOwgAzDAjIMC8gwLCDDsIAMwwIyDAvIMCwgw7CADMMCMgwLyDAsIMOwgAzDAjIMC8gwLCDDsIAMwwIyDAvIMCwgw7CADMMCMgwLyDAsIMOwgAzDAjIMC8gwLCDDsIAMwwIyDAvIMCwgw7CADMMCMgwLyDAsIMOwgAzDAjIMC8gwLCDDsIAMwwIyDAvIMCwgw7CAjAvoKgVVifzkRQAAAABJRU5ErkJggg==
BUT , when my program run in android, something go wrong, image file is not correct. file size is 0kb
Application output
tab output:
base64 length: 1018D libOnlineBoard_arm64-v8a.so: qml: data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAcIAAAHCCAYAAAB8GMlFAAAACXBIWXMAAAsTAAALEwEAmpwYAAAGtUlEQVR4nO3VMQEAIAzAMMC/5yFjRxMF/XpnzhwAiHrbAQCwyQgBSDNCANKMEIA0IwQgzQgBSDNCANKMEIA0IwQgzQgBSDNCANKMEIA0IwQgzQgBSDNCANKMEIA0IwQgzQgBSDNCANKMEIA0IwQgzQgBSDNCANKMEIA0IwQgzQgBSDNCANKMEIA0IwQgzQgBSDNCANKMEIA0IwQgzQgBSDNCANKMEIA0IwQgzQgBSDNCANKMEIA0IwQgzQgBSDNCANKMEIA0IwQgzQgBSDNCANKMEIA0IwQgzQgBSDNCANKMEIA0IwQgzQgBSDNCANKMEIA0IwQgzQgBSDNCANKMEIA0IwQgzQgBSDNCANKMEIA0IwQgzQgBSDNCANKMEIA0IwQgzQgBSDNCANKMEIA0IwQgzQgBSDNCANKMEIA0IwQgzQgBSDNCANKMEIA0IwQgzQgBSDNCANKMEIA0IwQgzQgBSDNCANKMEIA0IwQgzQgBSDNCANKMEIA0IwQgzQgBSDNCANKMEIA0IwQgzQgBSDNCANKMEIA0IwQgzQgBSDNCANKMEIA0IwQgzQgBSDNCANKMEIA0IwQgzQgBSDNCANKMEIA0IwQgzQgBSDNCANKMEIA0IwQgzQgBSDNCANKMEIA0IwQgzQgBSDNCANKMEIA0IwQgzQgBSDNCANKMEIA0IwQgzQgBSDNCANKMEIA0IwQgzQgBSDNCANKMEIA0IwQgzQgBSDNCANKMEIA0IwQgzQgBSDNCANKMEIA0IwQgzQgBSDNCANKMEIA0IwQgzQgBSDNCANKMEIA0IwQgzQgBSDNCANKMEIA0IwQgzQgBSDNCANKMEIA0IwQgzQgBSDNCANKMEIA0IwQgzQgBSDNCANKMEIA0IwQgzQgBSDNCANKMEIA0IwQgzQgBSDNCANKM
In this case in android, I change my code many times, i find program run well when the CANVAS base64data less than 1018, and the max length is 1018.
when the length over than 1018, go wrong.how can i fix this problem?
thx!