kun-galgame-vue/src/utils/dataURItoBlob.ts

10 lines
320 B
TypeScript
Raw Normal View History

2023-10-19 17:08:53 +00:00
export const dataURItoBlob = (dataURI: string) => {
const byteString = atob(dataURI.split(',')[1])
const ab = new ArrayBuffer(byteString.length)
const ia = new Uint8Array(ab)
for (let i = 0; i < byteString.length; i++) {
ia[i] = byteString.charCodeAt(i)
}
return new Blob([ab], { type: 'image/jpeg' })
}