【发布时间】:2014-06-02 05:22:27
【问题描述】:
我想在 KineticJS 中缩小 PNG/JPG 图像的大小而不降低质量。
我做了以下,但导致质量很差:
var stage = new Kinetic.Stage({
container: 'container',
width: 1000,
height: 1000
});
var layer = new Kinetic.Layer();
var imageObj = new Image();
imageObj.onload = function () {
var someImage = new Kinetic.Image({
image: imageObj,
});
// add the shape to the layer
layer.add(someImage);
// add the layer to the stage
stage.add(layer);
someImage.scale({
x: 500,
y: 500
});
layer.draw();
};
imageObj.src = // some image;
【问题讨论】:
-
由于 PNG 图像由 像素 - 离散点组成 - 缩小它们会总是 降级图像。只有当您想象一个 100x100 的白色正方形,其中心有一个 50x50 的红色正方形时,“不失质量”才有意义;这可以“不损失质量”缩小到其原始尺寸的 1/2、1/5、1/10 和 1/25。
标签: javascript html canvas kineticjs