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

fix: Some svg image sizes are drawn incorrectly #2977

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ppchart
Copy link

@ppchart ppchart commented Oct 17, 2022

When drawing some SVG images, Canvas's DrawImage Api (with 9 parameters) cannot draw the correct size

All the tests pass locally

Summary

This PR fixes/implements the following bugs/features

  • Some svg image sizes are drawn incorrectly

Explain the motivation for making this change. What existing problem does the pull request solve?
example tests/reftests/images/svg/background.html explain this bug that svg image size are drawn incorrectly

Origin:
image

Before:
image

After:
image

Although the size is correct, there are still some problems with the style, maybe another PR can solve the style difference of the pictures
#2904

Test plan (required)
The second svg image will draw the wrong style when using the original code in
tests/reftests/images/svg/background.html
tests/reftests/images/svg/base64.html

Closing issues
closes #2918

Fixes #

@ppchart ppchart force-pushed the master branch 3 times, most recently from 99390d2 to fe02ef0 Compare October 17, 2022 08:11
@@ -569,16 +559,12 @@ export class CanvasRenderer extends Renderer {
}

resizeImage(image: HTMLImageElement, width: number, height: number): HTMLCanvasElement | HTMLImageElement {
if (image.width === width && image.height === height) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are going to create a new canvas, even when the width and height are same. Maybe this is only required when image type is a SvgImageElement?

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

Successfully merging this pull request may close these issues.

pseudo-element background image svg + xml loss size style
2 participants