“Canvas Drawimage Redimensial Quality” Réponses codées

Comment arrêter le redimensionnement de la toile de redimensionner les images

//You just need to calculate the image aspect ratio:
var f = image.height / image.width;
var newHeight = canvas.width * f;
//And then draw using the recalculated height of image for destination:
ctx.drawImage(image, 0, 0, image.width, image.height, // source size
                     0, 0, canvas.width, newHeight);  // destination size
//Canvas will do the clipping for you.
//If you want to lets say center the destination vertical position you can do:
var destY = (canvas.height - image.height) / 2;
ctx.drawImage(image, 0, 0, image.width, image.height,    // source size
                     0, destY, canvas.width, newHeight); // destination size
Pandata

Canvas Drawimage Redimensial Quality

// If you're upscaling and image and its looking blurry, change this ctx value
ctx.imageSmoothingEnabled = false;
Black Butterfly

Réponses similaires à “Canvas Drawimage Redimensial Quality”

Questions similaires à “Canvas Drawimage Redimensial Quality”

Plus de réponses similaires à “Canvas Drawimage Redimensial Quality” dans JavaScript

Parcourir les réponses de code populaires par langue

Parcourir d'autres langages de code