Returns a component that displays an image in a canvas.
172640
protected Component createContentPane() {
		Image image = getImage();
		if (image != null) {
			return new ImageCanvas(image);
		}
		return null;
	}
846548
function renderComponent() {
    d3.select('svg')
      .call(gridline);

    var canvas = d3.select('canvas').node();
    var ctx = canvas.getContext('2d');
    gridlineCanvas.context(ctx)();
}
933315
function getTextImage(imageId) {
    const width = SIZE;
    const height = SIZE;

    const tokens = imageId.substring(12).split(':');
    const l = tokens[0];
    const bg = tokens[1];
    const pixelData = createTextPixelData(l, bg);

    function getPixelData() {
      return pixelData;
    }

    const image = {
      imageId,
      minPixelValue: 0,
      maxPixelValue: 257,
      slope: 1.0,
      intercept: 0,
      windowCenter: 127,
      windowWidth: 256,
      render: cs.renderGrayscaleImage,
      getPixelData,
      rows: height,
      columns: width,
      height,
      width,
      color: false,
      columnPixelSpacing: 1.0,
      rowPixelSpacing: 1.0,
      invert: false,
      sizeInBytes: width * height
    };

    return {
      promise: new Promise((resolve) => {
        resolve(image);
      }),
      cancelFn: undefined
    };
  }
1032938
function(width, height){
    var canvas = document.createElement("canvas");
    canvas.width = width;
    canvas.height = height;
    var context = canvas.getContext("2d");
    var imageData = context.getImageData(0, 0, width, height);
    var buffer = new ArrayBuffer(width*height*4);
    var buffer8 = new Uint8ClampedArray(buffer);
    var buffer32 = new Uint32Array(buffer);
    return {
      canvas: canvas,
      context: context,
      width: width,
      height: height,
      imageData: imageData,
      buffer8: buffer8,
      buffer32: buffer32};
  }
374866
function getImageData (canvasId, x, y, width, height, done) {
  wx.canvasGetImageData({
    canvasId,
    x,
    y,
    width,
    height,
    success (res) {
      done(res, null)
    },
    fail (res) {
      done(null, res)
    }
  })
}
579721
public static String getImageSource(FacesContext context, UIComponent component) {
		Image image = (Image) component;
		ResourceHandler handler = context.getApplication().getResourceHandler();
		String resourceName = image.getName();
		String value = image.getValue();
		if (value != null && value.length() > 0) {
			if (resourceName != null && image.getLibrary() != null) {
				if (FacesContext.getCurrentInstance().isProjectStage(ProjectStage.Development)) {
					LOGGER.warning(
							"Please use either the 'value' attribute of b:image, or the 'name' and 'library' attribute pair. If all three attributes are provided, BootsFaces uses the 'value' attributes, ignoring both 'name' and 'library'.");
				}
			}
			if (handler.isResourceURL(value)) {
				return value;
			} else {
				value = context.getApplication().getViewHandler().getResourceURL(context, value);
				return (context.getExternalContext().encodeResourceURL(value));
			}
		}

		String library = image.getLibrary();
		Resource res = handler.createResource(resourceName, library);
		if (res == null) {
			if (context.isProjectStage(ProjectStage.Development)) {
				String msg = "Unable to find resource " + resourceName;
				FacesMessages.error(component.getClientId(context), msg, msg);
			}
			return "RES_NOT_FOUND";
		} else {
			return (context.getExternalContext().encodeResourceURL(res.getRequestPath()));
		}
	}
1294674
def image_url(self):
        """"""
        return construct_api_url(self.input, 'image', self.resolvers, False, self.get3d, False, **self.kwargs)
1018453
function (format) {
        if (!this.image || !this.size) return null;

        format = format || "image/png";
        var canvas = document.createElement("canvas");
        var context = canvas.getContext("2d");
        context.canvas.width = this.size.w;
        context.canvas.height = this.size.h;

        var imgData = context.createImageData(this.size.w, this.size.h);
        for (var i = 0; i < this.image.length; i++) {
            imgData.data[i] = this.image[i];
        }
        context.putImageData(imgData, 0, 0);
        
        return canvas.toDataURL(format);
    }
3390
function (imagen, width, height, quality, type, ratio, centerCrop, resizeIf) {
    var deferred = $q.defer();
    var canvasElement = document.createElement('canvas');
    var imageElement = document.createElement('img');
    imageElement.setAttribute('style', 'visibility:hidden;position:fixed;z-index:-100000');
    document.body.appendChild(imageElement);

    imageElement.onload = function () {
      var imgWidth = imageElement.width, imgHeight = imageElement.height;
      imageElement.parentNode.removeChild(imageElement);
      if (resizeIf != null && resizeIf(imgWidth, imgHeight) === false) {
        deferred.reject('resizeIf');
        return;
      }
      try {
        if (ratio) {
          var ratioFloat = upload.ratioToFloat(ratio);
          var imgRatio = imgWidth / imgHeight;
          if (imgRatio < ratioFloat) {
            width = imgWidth;
            height = width / ratioFloat;
          } else {
            height = imgHeight;
            width = height * ratioFloat;
          }
        }
        if (!width) {
          width = imgWidth;
        }
        if (!height) {
          height = imgHeight;
        }
        var dimensions = calculateAspectRatioFit(imgWidth, imgHeight, width, height, centerCrop);
        canvasElement.width = Math.min(dimensions.width, width);
        canvasElement.height = Math.min(dimensions.height, height);
        var context = canvasElement.getContext('2d');
        context.drawImage(imageElement,
          Math.min(0, -dimensions.marginX / 2), Math.min(0, -dimensions.marginY / 2),
          dimensions.width, dimensions.height);
        deferred.resolve(canvasElement.toDataURL(type || 'image/WebP', quality || 0.934));
      } catch (e) {
        deferred.reject(e);
      }
    };
    imageElement.onerror = function () {
      imageElement.parentNode.removeChild(imageElement);
      deferred.reject();
    };
    imageElement.src = imagen;
    return deferred.promise;
  }
689129
def load_image(self, imagepath, width=None, height=None):
        """"""

        if width:
            self.width = width
            self.canvas["width"] = width
        if height:
            self.height = height
            self.canvas["height"] = height

        self.image = imagepath
        size = (self.width, self.height)
        load_image(self.canvas, self.image, bounds=size)
        self.canvas.update_idletasks()
464421
public static JComponent generateComponent(Image image) {

        if (image == null) {
            return new LabelUIResource("Image is null");
        }

        return SwingUtils.generateComponent(new ImageIcon(image));
    }
463841
def get_image(self, img, is_train):
        """"""
        img_arr = mx.image.imread(img)
        img_arr = transform(img_arr, 256, 256, is_train, self.boxes[img])
        return img_arr
443054
function supportsSvgPathArgument(window) {
  const canvas = window.document.createElement('canvas');
  const g = canvas.getContext('2d');
  const p = new window.Path2D('M0 0 L1 1');
  g.strokeStyle = 'red';
  g.lineWidth = 1;
  g.stroke(p);
  const imgData = g.getImageData(0, 0, 1, 1);
  return imgData.data[0] === 255; // Check if pixel is red
}
1287188
function _drawImageBitmap(evt, imageBitmap, alwaysVisible) {
  const eventData = evt.detail;
  const context = getNewContext(eventData.canvasContext.canvas);

  const canvasTopLeft = external.cornerstone.pixelToCanvas(eventData.element, {
    x: 0,
    y: 0,
  });

  const canvasTopRight = external.cornerstone.pixelToCanvas(eventData.element, {
    x: eventData.image.width,
    y: 0,
  });

  const canvasBottomRight = external.cornerstone.pixelToCanvas(
    eventData.element,
    {
      x: eventData.image.width,
      y: eventData.image.height,
    }
  );

  const cornerstoneCanvasWidth = external.cornerstoneMath.point.distance(
    canvasTopLeft,
    canvasTopRight
  );
  const cornerstoneCanvasHeight = external.cornerstoneMath.point.distance(
    canvasTopRight,
    canvasBottomRight
  );

  const canvas = eventData.canvasContext.canvas;
  const viewport = eventData.viewport;

  context.imageSmoothingEnabled = false;
  context.globalAlpha = getLayerAlpha(alwaysVisible);

  transformCanvasContext(context, canvas, viewport);

  const canvasViewportTranslation = {
    x: viewport.translation.x * viewport.scale,
    y: viewport.translation.y * viewport.scale,
  };

  context.drawImage(
    imageBitmap,
    canvas.width / 2 - cornerstoneCanvasWidth / 2 + canvasViewportTranslation.x,
    canvas.height / 2 -
      cornerstoneCanvasHeight / 2 +
      canvasViewportTranslation.y,
    cornerstoneCanvasWidth,
    cornerstoneCanvasHeight
  );

  context.globalAlpha = 1.0;

  resetCanvasContextTransform(context);
}
851763
Image fillImage() {
    if (fillImage == null) {
      CanvasImage image = platform.graphics().createImage(1, 1);
      image.canvas().setFillColor(0xFFFFFFFF).fillRect(0, 0, image.width(), image.height());
      fillImage = image;
    }
    return fillImage;
  }
388630
function drawToCanvas({data, width, height}) {
  if (typeof document === 'undefined') return null

    var canvas = document.createElement('canvas')
    canvas.width = width
    canvas.height = height
    var context = canvas.getContext('2d')
    var idata = context.createImageData(canvas.width, canvas.height)
    for (var i = 0; i < data.length; i++) {
      idata.data[i] = data[i]
    }
    context.putImageData(idata, 0, 0)
    return canvas
}
1007271
def _convert(self, image, output=None):
        """"""
        with Image.open(image) as im:
            width, height = im.size

            co = CanvasObjects()
            co.add(CanvasImg(image, 1.0, w=width, h=height))

            return WatermarkDraw(co, tempdir=self.tempdir, pagesize=(width, height)).write(output)