static void calculateInSampleSize(
     int paramInt1,
     int paramInt2,
     int paramInt3,
     int paramInt4,
     BitmapFactory.Options paramOptions,
     Request paramRequest) {
   int i = 1;
   if ((paramInt4 > paramInt2) || (paramInt3 > paramInt1)) {
     if (paramInt2 != 0) {
       break label43;
     }
   }
   for (i = (int) Math.floor(paramInt3 / paramInt1);
       ;
       i = (int) Math.floor(paramInt4 / paramInt2)) {
     paramOptions.inSampleSize = i;
     paramOptions.inJustDecodeBounds = false;
     return;
     label43:
     if (paramInt1 != 0) {
       break;
     }
   }
   paramInt2 = (int) Math.floor(paramInt4 / paramInt2);
   paramInt1 = (int) Math.floor(paramInt3 / paramInt1);
   if (paramRequest.centerInside) {}
   for (i = Math.max(paramInt2, paramInt1); ; i = Math.min(paramInt2, paramInt1)) {
     break;
   }
 }
Пример #2
0
  public DessertCaseView(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);

    final Resources res = getResources();

    mStarted = false;

    mCellSize = res.getDimensionPixelSize(R.dimen.dessert_case_cell_size);
    final BitmapFactory.Options opts = new BitmapFactory.Options();
    if (mCellSize < 512) { // assuming 512x512 images
      opts.inSampleSize = 2;
    }
    opts.inMutable = true;
    Bitmap loaded = null;
    for (int[] list : new int[][] {PASTRIES, RARE_PASTRIES, XRARE_PASTRIES, XXRARE_PASTRIES}) {
      for (int resid : list) {
        opts.inBitmap = loaded;
        loaded = BitmapFactory.decodeResource(res, resid, opts);
        final BitmapDrawable d = new BitmapDrawable(res, convertToAlphaMask(loaded));
        d.setColorFilter(new ColorMatrixColorFilter(ALPHA_MASK));
        d.setBounds(0, 0, mCellSize, mCellSize);
        mDrawables.append(resid, d);
      }
    }
    loaded = null;
    if (DEBUG) setWillNotDraw(false);
  }
Пример #3
0
  public Bitmap loadImage(String path) throws OutOfMemoryError {
    Bitmap bitsat;

    try {
      BitmapFactory.Options options = new BitmapFactory.Options();
      options.inPreferredConfig = Bitmap.Config.ARGB_8888;
      options.inJustDecodeBounds = true;
      Bitmap b = BitmapFactory.decodeFile(path, options);

      options.inSampleSize = Futils.calculateInSampleSize(options, px, px);

      // Decode bitmap with inSampleSize set
      options.inJustDecodeBounds = false;

      Bitmap bit;
      if (path.startsWith("smb:/")) bit = BitmapFactory.decodeStream(new SmbFileInputStream(path));
      else bit = BitmapFactory.decodeFile(path, options);

      bitsat =
          bit; // decodeFile(path);//.createScaledBitmap(bits,imageViewReference.get().getHeight(),imageViewReference.get().getWidth(),true);
    } catch (Exception e) {
      Drawable img = ContextCompat.getDrawable(mContext, R.drawable.ic_doc_image);
      Bitmap img1 = ((BitmapDrawable) img).getBitmap();
      bitsat = img1;
    }
    return bitsat;
  }
Пример #4
0
 public static Bitmap getSmallBitmap(String filePath, int reqWidth, int reqHeight) {
   BitmapFactory.Options options = new BitmapFactory.Options();
   options.inJustDecodeBounds = true;
   BitmapFactory.decodeFile(filePath, options);
   options.inSampleSize = calculateInSampleSize(options, reqWidth, reqHeight);
   options.inJustDecodeBounds = false;
   return BitmapFactory.decodeFile(filePath, options);
 }
 /**
  * @Method: decodeBitmap @Description: ���ļ��ж�ȡͼƬ
  *
  * @param path ͼƬ��·��
  * @return
  */
 Bitmap decodeBitmap(String path) {
   BitmapFactory.Options op = new BitmapFactory.Options();
   op.inJustDecodeBounds = true;
   Bitmap bmp = BitmapFactory.decodeFile(path, op);
   int wRatio = (int) Math.ceil(op.outWidth / 100); // ��ȡ�����С
   int hRatio = (int) Math.ceil(op.outHeight / 100);
   if (wRatio > 1 && hRatio > 1) { // ����ָ����С������С��Ӧ�ı���
     if (wRatio > hRatio) {
       op.inSampleSize = wRatio;
     } else {
       op.inSampleSize = hRatio;
     }
   }
   op.inJustDecodeBounds = false;
   bmp = BitmapFactory.decodeFile(path, op);
   return bmp;
 }
Пример #6
0
  /**
   * @Method: decodeBitmap @Description: ��ȡpath·���µ�ͼƬ��������
   *
   * @param path
   * @param rect
   * @return
   */
  Bitmap decodeBitmap(String path, int rect) {
    BitmapFactory.Options op = new BitmapFactory.Options();
    op.inJustDecodeBounds = true;
    op.inPreferredConfig = Bitmap.Config.ALPHA_8;
    Bitmap bmp = BitmapFactory.decodeFile(path, op);
    // ��ȡ�����С
    int wRatio = (int) Math.ceil(op.outWidth / rect);
    int hRatio = (int) Math.ceil(op.outHeight / rect);

    // ����ָ����С������С��Ӧ�ı���
    if (wRatio > 1 && hRatio > 1) {
      if (wRatio > hRatio) {
        op.inSampleSize = wRatio;
      } else {
        op.inSampleSize = hRatio;
      }
    }
    op.inPreferredConfig = Bitmap.Config.ALPHA_8;
    op.inJustDecodeBounds = false;
    bmp = BitmapFactory.decodeFile(path, op);
    return bmp;
  }