Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

小程序 cax 渲染svg里边的image drawImage绘制图像的宽度和高度没有按照传入的图片width height绘制 #98

Open
gexin1 opened this issue Jul 3, 2020 · 2 comments

Comments

@gexin1
Copy link

gexin1 commented Jul 3, 2020

//cax/packages/cax/src/render/display/bitmap.js
 //22 行
        util.getImageInWx(img, (result) => {
          this.img = result.img
          if (!this.rect) {
            this.rect = [0, 0, result.width, result.height]
          }
        // 这里把传入的宽 高 设置为图片的宽高
        // 预期不应该修改传入的图片宽高
          this.width = result.width
          this.height = result.height
          onLoad && onLoad.call(this)
          Bitmap.cache[img] = result
        })
    
//cax/packages/cax/src/render/render/canvas-render.js
//122 行
ctx.drawImage(o.img, bRect[0], bRect[1], bRect[2], bRect[3], 0, 0, bRect[2], bRect[3])
// 预期应该按照传入的宽高裁剪
ctx.drawImage(o.img, bRect[0], bRect[1], bRect[2], bRect[3], 0, 0, this.width, this.height)
@gexin1
Copy link
Author

gexin1 commented Jul 3, 2020

请问一下是出于什么方面考虑的呢😥

@dongnanyanhai
Copy link

今晚也遇到这个问题,才代码来看,bitmap和Sprite都是以图片实际尺寸大小去渲染的,想控制展示时的大小,只能通过放大缩小了。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants