Set a padding percentage which allows the image to scale proportionally.
@param {ResponsiveImage} image The image data.
778219
function applyAspectRatioPadding(image) {
  var ratioPadding = (image.knownDimensions[1] / image.knownDimensions[0]) * 100.0;
  DOM.setStyle(image.element, 'paddingBottom', ratioPadding + '%');
}
16264
private void setDestPixel(int[] dstImage, int x, int y, int p)
    {
        dstImage[x + y * width * SCALE] = p;
    }
594702
def set_image(self, img):
        ''''''
        self._bmp = wx.BitmapFromImage(img)
        self.SetMinSize((self._bmp.GetWidth(), self._bmp.GetHeight()))
1020877
private void scaleToOutputResolution(Image image) {

        float factor = m_sharedContext.getDotsPerPixel();
        if (factor != 1.0f) {
            image.scaleAbsolute(image.getPlainWidth() * factor, image.getPlainHeight() * factor);
        }
    }
47013
def scale_image(self):
        """"""
        new_width = int(self.figcanvas.fwidth *
                        self._scalestep ** self._scalefactor)
        new_height = int(self.figcanvas.fheight *
                         self._scalestep ** self._scalefactor)
        self.figcanvas.setFixedSize(new_width, new_height)
5454
public void setImageGradient(Deriv derivX , Deriv derivY ) {
		this.imageDerivX.wrap(derivX);
		this.imageDerivY.wrap(derivY);
	}
138776
function setDivTag(image, img) {
  var setElemStyle = DOM.setStyle(image.element);
  setElemStyle('backgroundImage', 'url(' + img.src + ')');

  if (image.preserveAspectRatio) {
    var w, h;

    if (image.knownDimensions) {
      w = image.knownDimensions[0];
      h = image.knownDimensions[1];
    } else {
      w = img.width;
      h = img.height;
    }

    setElemStyle('backgroundSize', 'cover');

    if (image.isFlexible) {
      setElemStyle('paddingBottom', ((h / w) * 100.0) + '%');
    } else {
      setElemStyle('width', w + 'px');
      setElemStyle('height', h + 'px');
    }
  }
}
904117
function (element) {
            var p = this.padding,
                w = this.canvas.width,
                h = this.canvas.height * 0.5;

            // Convert padding percentage to actual padding
            p = p.map(function (a, i) {
                return a * ((i % 2) ? w : h);
            });

            return [
                this.prettify((parseInt($(element).css("left"), 10)    - p[3]) / (w + p[1] + p[3])),
                this.prettify((h - parseInt($(element).css("top"), 10) - p[2]) / (h - p[0] - p[2]))
            ];
        }
148790
public void setImage(final Image image) {
		ImageModel model = getOrCreateComponentModel();
		model.image = image;
		model.imageUrl = null;
	}
103551
public void update (Image image) {
    // if we're a repeating texture (or we want mipmaps) and this image is non-POT on the relevant
    // axes, we need to scale it before we upload it; we'll just do this on the CPU since it feels
    // like creating a second texture, a frame buffer to render into it, sending a GPU batch and
    // doing all the blah blah blah is going to be more expensive overall
    if (config.repeatX || config.repeatY || config.mipmaps) {
      int pixWidth = image.pixelWidth(), pixHeight = image.pixelHeight();
      int potWidth = config.toTexWidth(pixWidth), potHeight = config.toTexWidth(pixHeight);
      if (potWidth != pixWidth || potHeight != pixHeight) {
        Canvas scaled = gfx.createCanvasImpl(Scale.ONE, potWidth, potHeight);
        scaled.draw(image, 0, 0, potWidth, potHeight);
        scaled.image.upload(gfx, this);
        scaled.close();
      } else image.upload(gfx, this); // fast path, woo!
    }
    else image.upload(gfx, this); // fast path, woo!
    if (config.mipmaps) gfx.gl.glGenerateMipmap(GL_TEXTURE_2D);
  }
897242
function setCanvasSize (width, height) {
            canvas.setAttribute('width', width);
            canvas.setAttribute('height', height);
            canvas.style.width = width + 'px';
            canvas.style.height = height + 'px';
        }
436775
function(url, img) {
        var svgImage = document.createElementNS(SVG_NS_URL, 'image');
        svgImage.setAttributeNS(XLINK_NS_URL, 'xlink:href', url);
        svgImage.setAttribute('x', 0);
        svgImage.setAttribute('y', 0);
        svgImage.setAttribute('width', img.width);
        svgImage.setAttribute('height', img.height);
        return svgImage;
      }
195892
function(width) {
            // take into account pixel ratio
            this.width = this._canvas.width = width * this.pixelRatio;
            this._canvas.style.width = width + 'px';
        }
566408
public void setImage(BufferedImage image) {
		this.image = image;
		setPreferredSize(new Dimension(image.getWidth(), image.getHeight()));
		setSize(new Dimension(image.getWidth(), image.getHeight()));
		getParent().repaint(0);
	}
1172530
public void setIcon(final Image IMAGE) {
        if (null == icon) {
            _icon = IMAGE;
        } else {
            icon.set(IMAGE);
        }
    }
1169617
function resizePromise(img, width=0, height=0) {
    return new Promise((resolve, reject) => {
        let loaded = typeof img == 'string' // url
        let image
        if (loaded) {
            image = new Image
            image.onload = () => {
                if (image.width <= width || image.height <= height || (width == 0 && height == 0)) {
                    // nothing changes
                    resolve(scalingHelper(image, 1))
                }else {
                    resolve(resample(image, width, height))
                }
            }
            image.onerror = () => {
                console.error('image resize error here!!!')
                reject('resize error')
            }
            image.src = img
        } else {
            image = img
            if (image.width <= width || image.height <= height || (width == 0 && height == 0)) {
                // nothing changes
                resolve(scalingHelper(image, 1))
            }else {
                resolve(resample(image, width, height))
            }
        }
    })
}
818427
function(image) {
        var maskWidth = this._getMaskX(image.width);
        var maskHeight = this._getMaskY(image.height);
        var buf = this._getResizedImageBuffer(image, maskWidth, maskHeight);
        var mask = new Array(maskWidth * maskHeight);
        for (var y = 0; y < maskHeight; y++) {
            for (var x = 0; x < maskWidth; x++) {
                var idx = (y * maskWidth + x);
                var filled = this._checkFilledPixel(buf, idx);
                mask[idx] = filled ? 1 : 0;
            }
        }
        return mask;
    }