0

This is quite a project-specific question, to do with my implementation of svg-edit..

I've implemented the updated 'ext-server_opensave.js' (from this issue) so that the user is able to upload raster images from their file system.

The code snippet I'm having an issue with from 'ext-server_opensave.js' is the following:

    function importImage(url) {
        var newImage = svgCanvas.addSvgElementFromJson({
            "element": "image",
            "attr": {
                "x": 0,
                "y": 0,
                "width": 0,
                "height": 0,
                "id": svgCanvas.getNextId(),
                "style": "pointer-events:inherit"
            }
        });
        svgCanvas.clearSelection();
        svgCanvas.addToSelection([newImage]);
        svgCanvas.setImageURL(url);
    }

The width and height attributes don't work when setting them there, the other attributes do work. It's a weird bug - the first image upload uploads the file in its original size, then every subsequent image upload resizes to 48x48. If I set the width and height values in that method I pasted above, I see the image in those dimensions for a split second and then it resizes back to 48x48. Basically, there's some handler/method down the chain that is resizing the image after svgCanvas.addSvgElementFromJson and svgCanvas.addToSelection, and I can't figure out where, after hours of debugging the javascript.

4

1 に答える 1

0

ワイルドショットですが、おそらく128行目に追加します...

case 'import_img':
        svgCanvas.setGoodImage(str64);
        importImage(str64);
        break;

setGoodImage()新しい画像を挿入するときのデフォルトの画像サイズを設定します。表示されている 48x48 のサイズは、SVG Edit のロゴのサイズです。

于 2012-10-13T08:54:37.103 に答える