mirror of
https://github.com/palxiao/poster-design.git
synced 2025-07-15 16:02:19 +08:00
code: fix psd reading fail image
This commit is contained in:
parent
2878064b76
commit
cba825cdbf
@ -1,21 +1,25 @@
|
|||||||
/*
|
/*
|
||||||
* @Author: ShawnPhang
|
* @Author: ShawnPhang
|
||||||
* @Date: 2024-08-17 18:45:24
|
* @Date: 2024-08-17 18:45:24
|
||||||
* @Description:
|
* @Description:
|
||||||
* @LastEditors: ShawnPhang <https://m.palxp.cn>
|
* @LastEditors: ShawnPhang <https://m.palxp.cn>
|
||||||
* @LastEditTime: 2024-08-17 18:46:58
|
* @LastEditTime: 2024-08-18 20:49:49
|
||||||
*/
|
*/
|
||||||
export function createBase64(src: any, { width, height }: any) {
|
export function createBase64(src: any, { width, height }: any) {
|
||||||
const canvas = document.createElement('canvas')
|
let result = ''
|
||||||
canvas.width = width
|
if (src && width) {
|
||||||
canvas.height = height
|
const canvas = document.createElement('canvas')
|
||||||
const context: any = canvas.getContext('2d', { willReadFrequently: true })
|
canvas.width = width
|
||||||
const imageData = context.getImageData(0, 0, width, height)
|
canvas.height = height
|
||||||
const pixelData = imageData.data
|
const context: any = canvas.getContext('2d', { willReadFrequently: true })
|
||||||
const len = src.length
|
const imageData = context.getImageData(0, 0, width, height)
|
||||||
for (let i = 0; i < len; i++) {
|
const pixelData = imageData.data
|
||||||
pixelData[i] = src[i]
|
const len = src.length
|
||||||
|
for (let i = 0; i < len; i++) {
|
||||||
|
pixelData[i] = src[i]
|
||||||
|
}
|
||||||
|
context.putImageData(imageData, 0, 0)
|
||||||
|
result = canvas.toDataURL('image/png')
|
||||||
}
|
}
|
||||||
context.putImageData(imageData, 0, 0)
|
return result
|
||||||
return canvas.toDataURL('image/png')
|
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
* @Date: 2022-01-10 14:57:53
|
* @Date: 2022-01-10 14:57:53
|
||||||
* @Description: Psd文件解析
|
* @Description: Psd文件解析
|
||||||
* @LastEditors: ShawnPhang <https://m.palxp.cn>
|
* @LastEditors: ShawnPhang <https://m.palxp.cn>
|
||||||
* @LastEditTime: 2024-08-17 18:53:35
|
* @LastEditTime: 2024-08-18 21:06:05
|
||||||
-->
|
-->
|
||||||
<template>
|
<template>
|
||||||
<div id="page-design-index" ref="pageDesignIndex">
|
<div id="page-design-index" ref="pageDesignIndex">
|
||||||
|
Loading…
x
Reference in New Issue
Block a user