Attempt to find the specified image file in the <code>assets</code> folder and return a decoded Bitmap.
497278
@Override
   public Bitmap  resolveImage(String filename)
   {
      Log.i(TAG, "resolveImage("+filename+")");

      try
      {
         InputStream  istream = assetManager.open(filename);
         return BitmapFactory.decodeStream(istream);
      }
      catch (IOException e1)
      {
         return null;
      }
   }
523887
public CloseableImage decodeGif(
      final EncodedImage encodedImage,
      final int length,
      final QualityInfo qualityInfo,
      final ImageDecodeOptions options) {
    if (!options.forceStaticImage && mAnimatedGifDecoder != null) {
      return mAnimatedGifDecoder.decode(encodedImage, length, qualityInfo, options);
    }
    return decodeStaticImage(encodedImage, options);
  }
980494
def get_image(self, digest, blob, mime_type, index, size=500):
        """"""
        # Special case, for now (XXX).
        if mime_type.startswith("image/"):
            return ""

        cache_key = f"img:{index}:{size}:{digest}"
        return self.cache.get(cache_key)
916576
public static Image getImageFromResources(Class<?> clazz, String name, Toolkit toolkit) throws IOException {
		byte[] imageData;
		InputStream in = clazz.getResourceAsStream(name);
		if(in==null) throw new IOException("Unable to find resource: "+name);
		try {
			imageData = IoUtils.readFully(in);
		} finally {
			in.close();
		}
		return toolkit.createImage(imageData);
	}
1161874
private static Observable<Bitmap> getThumbnailFromUriWithSizeAndKind(final Context context,
      final Uri data, final int requiredWidth, final int requiredHeight, final int kind) {
    return Observable.fromCallable(new Func0<Bitmap>() {
      @Override
      public Bitmap call() {
        Bitmap bitmap = null;
        ParcelFileDescriptor parcelFileDescriptor;
        final BitmapFactory.Options options = new BitmapFactory.Options();
        if (requiredWidth > 0 && requiredHeight > 0) {
          options.inJustDecodeBounds = true;
          options.inSampleSize = calculateInSampleSize(options, requiredWidth, requiredHeight);
          options.inJustDecodeBounds = false;
        }
        if (!isMediaUri(data)) {
          logDebug("Not a media uri:" + data);
          if (isGoogleDriveDocument(data)) {
            logDebug("Google Drive Uri:" + data);
            DocumentFile file = DocumentFile.fromSingleUri(context, data);
            if (file.getType().startsWith(Constants.IMAGE_TYPE) || file.getType()
                .startsWith(Constants.VIDEO_TYPE)) {
              logDebug("Google Drive Uri:" + data + " (Video or Image)");
              try {
                parcelFileDescriptor = context.getContentResolver().
                    openFileDescriptor(data, Constants.READ_MODE);
                FileDescriptor fileDescriptor = parcelFileDescriptor.getFileDescriptor();
                bitmap = BitmapFactory.decodeFileDescriptor(fileDescriptor, null, options);
                parcelFileDescriptor.close();
                return bitmap;
              } catch (IOException e) {
                logError(e);
              }
            }
          } else if (data.getScheme().equals(Constants.FILE)) {
            logDebug("Dropbox or other DocumentsProvider Uri:" + data);
            try {
              parcelFileDescriptor = context.getContentResolver().
                  openFileDescriptor(data, Constants.READ_MODE);
              FileDescriptor fileDescriptor = parcelFileDescriptor.getFileDescriptor();
              bitmap = BitmapFactory.decodeFileDescriptor(fileDescriptor, null, options);
              parcelFileDescriptor.close();
              return bitmap;
            } catch (IOException e) {
              logError(e);
            }
          } else {
            try {
              parcelFileDescriptor = context.getContentResolver().
                  openFileDescriptor(data, Constants.READ_MODE);
              FileDescriptor fileDescriptor = parcelFileDescriptor.getFileDescriptor();
              bitmap = BitmapFactory.decodeFileDescriptor(fileDescriptor, null, options);
              parcelFileDescriptor.close();
              return bitmap;
            } catch (IOException e) {
              logError(e);
            }
          }
        } else {
          logDebug("Uri for thumbnail:" + data);
          String[] parts = data.getLastPathSegment().split(":");
          String fileId = parts[1];
          Cursor cursor = null;
          try {
            cursor = context.getContentResolver().query(data, null, null, null, null);
            if (cursor != null) {
              logDebug("Cursor size:" + cursor.getCount());
              if (cursor.moveToFirst()) {
                if (data.toString().contains(Constants.VIDEO)) {
                  bitmap = MediaStore.Video.Thumbnails.getThumbnail(context.getContentResolver(),
                      Long.parseLong(fileId), kind, options);
                } else if (data.toString().contains(Constants.IMAGE)) {
                  bitmap = MediaStore.Images.Thumbnails.getThumbnail(context.getContentResolver(),
                      Long.parseLong(fileId), kind, options);
                }
              }
            }
            return bitmap;
          } catch (Exception e) {
            logError(e);
          } finally {
            if (cursor != null) cursor.close();
          }
        }
        return bitmap;
      }
    });
  }
119277
def get_asset(self):
        
        # Implemented from template for osid.learning.Activity.get_objective
        if not bool(self._my_map['assetId']):
            raise errors.IllegalState('asset empty')
        mgr = self._get_provider_manager('REPOSITORY')
        if not mgr.supports_asset_lookup():
            raise errors.OperationFailed('Repository does not support Asset lookup')
        lookup_session = mgr.get_asset_lookup_session(proxy=getattr(self, "_proxy", None))
        lookup_session.use_federated_repository_view()
        return lookup_session.get_asset(self.get_asset_id())
666222
def _get_image(self):
        
        if self.image is None:
            image_path = '%s/%s' % (current_app.static_folder, os.path.normpath(self.image_path))
            try:
                self.image = Image.open(image_path)
                self._reduce_opacity()
            except Exception as err:
                raise ValueError('Unsupported watermark format: %s' % str(err))

        return self.image
578580
public synchronized void returnBitmap(Bitmap bitmap) {
        if (bitmap == null || bitmapsBySize.contains(bitmap) ) {
            return;
        } else if(getBitmapSize(bitmap) > sizeLimit || !canBePooled(bitmap)) {
            return;
        }
        bitmapsByLastUse.add(bitmap);
        int pos = Collections.binarySearch(bitmapsBySize, bitmap, BITMAP_COMPARATOR);
        if (pos < 0) {
            pos = -pos - 1;
        }
        bitmapsBySize.add(pos, bitmap);
        currentSize += getBitmapSize(bitmap);
        trim();
    }
369751
private Bitmap loadFromLruCache(final String path, boolean tryFromDisk) {

        int key = getKey(path);

        Bitmap bitmap = mImagesCache.get(key); //try to retrieve from lruCache

        Log.d(TAG, "bitmap " + path + " from lruCache [" + key + "] " + bitmap);

        if (tryFromDisk && bitmap == null) {
            bitmap = loadFromDiskLruCache(key); //try to retrieve from disk cache

            Log.d(TAG, "bitmap " + path + " from diskLruCache " + bitmap);
            if (bitmap != null) { //if found on disk cache
                mImagesCache.put(key, bitmap); //save it into lruCache
            }
        }

        return bitmap;
    }
996630
public static Observable<Bitmap> getThumbnail(String filePath) {
    return getFileType(filePath).filter(new Func1<String, Boolean>() {
      @Override
      public Boolean call(String s) {
        return s != null;
      }
    }).flatMap(new Func1<String, Observable<Bitmap>>() {
      @Override
      public Observable<Bitmap> call(String s) {
        if (s.equalsIgnoreCase(Constants.VIDEO)) {
          return getVideoThumbnail(s);
        } else if (s.equalsIgnoreCase(Constants.IMAGE)) return getThumbnailFromPath(s);
        return null;
      }
    });
  }
1001295
public com.google.api.ads.admanager.axis.v201808.CreativeAsset getAsset() {
        return asset;
    }
568559
public static Image getImageFromResources(Class<?> clazz, String name) throws IOException {
		return getImageFromResources(clazz, name, Toolkit.getDefaultToolkit());
	}
1204411
@Override
    public InputStream getResourceAsStream(String name) {
        byte[] b = null;
        try {
            Asset resource = AssetCache.getAsset(mdwPackage.getName() + "/" + name);
            if (resource != null)
                b = resource.getRawContent();
            if (b == null)
                b = findInJarAssets(name);
            if (b == null)
                b = findInFileSystem(name);
        }
        catch (Exception ex) {
            logger.severeException(ex.getMessage(),  ex);
        }

        if (b == null)
            return super.getResourceAsStream(name);
        else
            return new ByteArrayInputStream(b);
    }
751441
public static Bitmap getThumbnail(Context context, Uri uri) {
        return getThumbnail(context, uri, getMimeType(context, uri));
    }
1196385
public static Bitmap getThumbnail(Context context, Uri uri, String mimeType) {
        if (DEBUG)
            Log.d(TAG, "Attempting to get thumbnail");

        if (!isMediaUri(uri)) {
            Log.e(TAG, "You can only retrieve thumbnails for images and videos.");
            return null;
        }

        Bitmap bm = null;
        if (uri != null) {
            final ContentResolver resolver = context.getContentResolver();
            Cursor cursor = null;
            try {
                cursor = resolver.query(uri, null, null, null, null);
                if (cursor.moveToFirst()) {
                    final int id = cursor.getInt(0);
                    if (DEBUG)
                        Log.d(TAG, "Got thumb ID: " + id);

                    if (mimeType.contains("video")) {
                        bm = MediaStore.Video.Thumbnails.getThumbnail(
                                resolver,
                                id,
                                MediaStore.Video.Thumbnails.MINI_KIND,
                                null);
                    }
                    else if (mimeType.contains(FileUtils.MIME_TYPE_IMAGE)) {
                        bm = MediaStore.Images.Thumbnails.getThumbnail(
                                resolver,
                                id,
                                MediaStore.Images.Thumbnails.MINI_KIND,
                                null);
                    }
                }
            } catch (Exception e) {
                if (DEBUG)
                    Log.e(TAG, "getThumbnail", e);
            } finally {
                if (cursor != null)
                    cursor.close();
            }
        }
        return bm;
    }
1352485
public static Bitmap decodeSampledBitmapFromByteArray(byte[] picture,
                                                          int reqWidth, int reqHeight) {

        // First decode with inJustDecodeBounds=true to check dimensions
        BitmapFactory.Options options = new BitmapFactory.Options();
        options.inJustDecodeBounds = true;
        BitmapFactory.decodeByteArray(picture, 0, picture.length, options);

        // Calculate inSampleSize
        options.inSampleSize = calculateInSampleSize(options, reqWidth, reqHeight);

        // Decode bitmap with inSampleSize set
        options.inJustDecodeBounds = false;
        return BitmapFactory.decodeByteArray(picture, 0, picture.length, options);
    }
1153415
def _serve_asset(self, path, gzipped_asset_bytes, request):
    """"""
    mimetype = mimetypes.guess_type(path)[0] or 'application/octet-stream'
    return http_util.Respond(
        request, gzipped_asset_bytes, mimetype, content_encoding='gzip')