/*
Attempt to set a picture from a Uri. Return true if it worked.
426678
private boolean  internalSetImageURI(Uri uri)
   {
      try
      {
         InputStream  is = getContext().getContentResolver().openInputStream(uri);
         new LoadURITask().execute(is);
         return true;
      }
      catch (FileNotFoundException e)
      {
         return false;
      }

   }
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);
    }
267091
function trustImages(from) {
    let trusted = prefStore.getState() || {};
    
    if (!trusted.images)
        trusted.images = [];
    
    trusted.images.push(from);
    prefStore.setState(trusted);
}
1124658
def set_image(self, image = None):
        
        
        if image is None or type(image) is not int:
            raise KPError("Need a new image number")
        else:
            self.image = image
            self.last_mod = datetime.now().replace(microsecond=0)
            return True
1288338
private static Observable<Bitmap> getThumbnailFromUri(final Context context, final Uri data) {
    return getThumbnailFromUriWithSizeAndKind(context, data, 0, 0,
        MediaStore.Images.Thumbnails.MINI_KIND);
  }
327325
def has_image(self, digest, mime_type, index, size=500):
        """"""
        cache_key = f"img:{index}:{size}:{digest}"
        return mime_type.startswith("image/") or cache_key in self.cache
529172
public static boolean isLocalCameraUri(Uri uri) {
    String uriString = uri.toString();
    return uriString.startsWith(MediaStore.Images.Media.EXTERNAL_CONTENT_URI.toString())
        || uriString.startsWith(MediaStore.Images.Media.INTERNAL_CONTENT_URI.toString());
  }
796360
function saveImage(data, success, fail) {
    var name = savePath + imgName();
    require('lib/webview').setSandbox(false);
    window.webkitRequestFileSystem(window.PERSISTENT, 0, function (fs) {
        fs.root.getFile(name, { create: true }, function (entry) {
            entry.createWriter(function (writer) {
                writer.onwriteend = function () {
                    success(name);
                };
                writer.onerror = fail;
                writer.write(dataURItoBlob(data));
            });
        }, fail);
    }, fail);
}
1107177
public static Observable<Bitmap> getThumbnail(Context context, Uri uri, int requiredWidth,
      int requiredHeight) {
    return getThumbnailFromUriWithSize(context, uri, requiredWidth, requiredHeight);
  }
949946
function(css, imageIndex){
    var urlVal = css.value[imageIndex];
    var image  = this._isSpriteImage(urlVal, imageIndex, css);
    var images = this.images;

    if (image){
      image = path.relative('./', image);
      image = image.replace(/\\+/g, '/');
      images[css.id] = image;
    }
  }
880941
public void setImage(final Image image) {
		LinkModel model = getOrCreateComponentModel();
		model.image = image;
		model.imageUrl = null;
	}
1353817
def set_url(self, url = None):
        
                
        if url is None or type(url) is not str:
            raise KPError("Need a new image number")
        else:
            self.url = url
            self.last_mod = datetime.now().replace(microsecond=0)
            return True
1120552
function(url) {
        var img = this.imgDiv;
        if (url) {
            img.style.visibility = 'hidden';
            img.style.opacity = 0;
            // don't set crossOrigin if the url is a data URL
            if (this.crossOriginKeyword) {
                if (url.substr(0, 5) !== 'data:') {
                    img.setAttribute("crossorigin", this.crossOriginKeyword);
                } else {
                    img.removeAttribute("crossorigin");
                }
            }
            img.src = url;
        } else {
            // Remove reference to the image, and leave it to the browser's
            // caching and garbage collection.
            this.stopLoading();
            this.imgDiv = null;
            if (img.parentNode) {
                img.parentNode.removeChild(img);
            }
        }
    }
1172858
public static Bitmap loadBitmap(Uri uri, Context context) throws ImageLoadException {
        return loadBitmap(new UriSource(uri, context));
    }
632573
function()
		{
			if ( this.undoable() )
			{
				this.save( true );

				var image = this.getNextImage( true );
				if ( image )
					return this.restoreImage( image ), true;
			}

			return false;
		}
751147
public static Observable<Bitmap> getThumbnail(Context context, Uri uri) {
    return getThumbnailFromUri(context, uri);
  }
594702
def set_image(self, img):
        ''''''
        self._bmp = wx.BitmapFromImage(img)
        self.SetMinSize((self._bmp.GetWidth(), self._bmp.GetHeight()))