android.graphics.PaintFlagsDrawFilter#android.graphics.Bitmap.Config源码实例Demo

下面列出了android.graphics.PaintFlagsDrawFilter#android.graphics.Bitmap.Config 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

private Bitmap bitMatrix2Bitmap(BitMatrix matrix) {
    int w = matrix.getWidth();
    int h = matrix.getHeight();
    int[] rawData = new int[w * h];
    for (int i = 0; i < w; i++) {
        for (int j = 0; j < h; j++) {
            int color = Color.WHITE;
            if (matrix.get(i, j)) {
                color = Color.BLACK;
            }
            rawData[i + (j * w)] = color;
        }
    }

    Bitmap bitmap = Bitmap.createBitmap(w, h, Config.RGB_565);
    bitmap.setPixels(rawData, 0, w, 0, 0, w, h);
    return bitmap;
}
 
源代码2 项目: barterli_android   文件: PhotoUtils.java
private static Bitmap compressManageAspect(final int height,
                final int width, final Bitmap originalImage) {
    final Bitmap compressedBitmap = Bitmap
                    .createBitmap(width, height, Config.ARGB_8888);
    final float originalWidth = originalImage.getWidth(), originalHeight = originalImage
                    .getHeight();
    final Canvas canvas = new Canvas(compressedBitmap);
    final float scale = width / originalWidth;
    final float xTranslation = 0.0f, yTranslation = (height - (originalHeight * scale)) / 2.0f;
    final Matrix transformation = new Matrix();
    transformation.postTranslate(xTranslation, yTranslation);
    transformation.preScale(scale, scale);
    final Paint paint = new Paint();
    paint.setFilterBitmap(true);
    canvas.drawBitmap(originalImage, transformation, paint);
    return compressedBitmap;
}
 
源代码3 项目: glide-support   文件: RawFileDecoder.java
@Override public @Nullable Resource<Bitmap> decode(File file, int w, int h, Options options) throws IOException {
	ByteBuffer buffer = ByteBuffer.allocate(w * h * 4);
	FileInputStream stream = new FileInputStream(file);
	try {
		stream.getChannel().read(buffer);
	} finally {
		stream.close();
	}
	Bitmap result = Bitmap.createBitmap(w, h, Config.ARGB_8888);
	try {
		buffer.rewind();
		result.copyPixelsFromBuffer(buffer);
		return BitmapResource.obtain(result, pool);
	} catch (RuntimeException ex) {
		result.recycle();
		throw ex;
	}
}
 
源代码4 项目: XFrame   文件: XBitmapUtils.java
/**
 * 生成水印图片 水印在右下角
 *
 * @param src       the bitmap object you want proecss
 * @param watermark the water mark above the src
 * @return return a bitmap object ,if paramter's length is 0,return null
 */
public static Bitmap createWatermarkBitmap(Bitmap src, Bitmap watermark) {
    if (src == null) {
        return null;
    }

    int w = src.getWidth();
    int h = src.getHeight();
    int ww = watermark.getWidth();
    int wh = watermark.getHeight();
    // create the new blank bitmap
    Bitmap newb = Bitmap.createBitmap(w, h, Config.ARGB_8888);// 创建一个新的和SRC长度宽度一样的位图
    Canvas cv = new Canvas(newb);
    // draw src into
    cv.drawBitmap(src, 0, 0, null);// 在 0,0坐标开始画入src
    // draw watermark into
    cv.drawBitmap(watermark, w - ww + 5, h - wh + 5, null);// 在src的右下角画入水印
    // save all clip
    cv.save(Canvas.ALL_SAVE_FLAG);// 保存
    // store
    cv.restore();// 存储
    return newb;
}
 
源代码5 项目: CircularImageView   文件: PicassoRoundTransform.java
@Override
public Bitmap transform(final Bitmap source)
{
    final Paint paint = new Paint();
    paint.setAntiAlias(true);
    paint.setShader(new BitmapShader(source, Shader.TileMode.CLAMP, Shader.TileMode.CLAMP));

    Bitmap output = Bitmap.createBitmap(source.getWidth(), source.getHeight(), Config.ARGB_8888);
    Canvas canvas = new Canvas(output);
    canvas.drawRoundRect(new RectF(margin, margin, source.getWidth() - margin, source.getHeight() - margin), radius, radius, paint);

    if (source != output) {
        source.recycle();
    }

    return output;
}
 
public void buildCircularRevealCache() {
  if (STRATEGY == BITMAP_SHADER) {
    buildingCircularRevealCache = true;
    hasCircularRevealCache = false;

    view.buildDrawingCache();
    Bitmap bitmap = view.getDrawingCache();

    if (bitmap == null && view.getWidth() != 0 && view.getHeight() != 0) {
      bitmap = Bitmap.createBitmap(view.getWidth(), view.getHeight(), Config.ARGB_8888);
      Canvas canvas = new Canvas(bitmap);
      view.draw(canvas);
    }

    if (bitmap != null) {
      revealPaint.setShader(new BitmapShader(bitmap, TileMode.CLAMP, TileMode.CLAMP));
    }

    buildingCircularRevealCache = false;
    hasCircularRevealCache = true;
  }
}
 
源代码7 项目: letv   文件: RoundedPagerDrawable.java
public static Bitmap drawableToBitmap(Drawable drawable) {
    if (drawable instanceof BitmapDrawable) {
        return ((BitmapDrawable) drawable).getBitmap();
    }
    try {
        Bitmap bitmap = Bitmap.createBitmap(Math.max(drawable.getIntrinsicWidth(), 2), Math.max(drawable.getIntrinsicHeight(), 2), Config.ARGB_8888);
        Canvas canvas = new Canvas(bitmap);
        drawable.setBounds(0, 0, canvas.getWidth(), canvas.getHeight());
        drawable.draw(canvas);
        return bitmap;
    } catch (Exception e) {
        e.printStackTrace();
        Log.w(TAG, "Failed to create bitmap from drawable!");
        return null;
    }
}
 
源代码8 项目: PhotoEdit   文件: DrawMosaicView.java
/**
 * 返回马赛克最终结果
 * 
 * @return 马赛克最终结果
 */
public Bitmap getMosaicBitmap()
{
	if (bmMosaicLayer == null)
	{
		return null;
	}

	Bitmap bitmap = Bitmap.createBitmap(mImageWidth, mImageHeight,
			Config.ARGB_8888);
	Canvas canvas = new Canvas(bitmap);
	canvas.drawBitmap(bmBaseLayer, 0, 0, null);
	canvas.drawBitmap(bmMosaicLayer, 0, 0, null);
	canvas.save();
	return bitmap;
}
 
源代码9 项目: letv   文件: a.java
private static final boolean b(String str, int i, int i2) {
    if (TextUtils.isEmpty(str)) {
        return false;
    }
    Options options = new Options();
    options.inJustDecodeBounds = true;
    BitmapFactory.decodeFile(str, options);
    int i3 = options.outWidth;
    int i4 = options.outHeight;
    if (options.mCancel || options.outWidth == -1 || options.outHeight == -1) {
        return false;
    }
    int i5 = i3 > i4 ? i3 : i4;
    if (i3 >= i4) {
        i3 = i4;
    }
    f.b("AsynScaleCompressImage", "longSide=" + i5 + "shortSide=" + i3);
    options.inPreferredConfig = Config.RGB_565;
    if (i5 > i2 || i3 > i) {
        return true;
    }
    return false;
}
 
源代码10 项目: letv   文件: BlurUtils.java
@SuppressLint({"NewApi"})
public static void blur_3(Context context, Bitmap bkg, View view) {
    long startMs = System.currentTimeMillis();
    Display d = ((Activity) context).getWindowManager().getDefaultDisplay();
    Bitmap overlay = Bitmap.createBitmap((int) (((float) d.getWidth()) / 1.0f), (int) (((float) d.getHeight()) / 1.0f), Config.ARGB_8888);
    Canvas canvas = new Canvas(overlay);
    canvas.scale(1.0f / 1.0f, 1.0f / 1.0f);
    Paint paint = new Paint();
    paint.setFlags(2);
    canvas.drawBitmap(bkg, 0.0f, 0.0f, paint);
    overlay = FastBlur.doBlur(overlay, (int) 100.0f, true);
    if (LetvUtils.getSDKVersion() >= 16) {
        view.setBackground(new BitmapDrawable(context.getResources(), overlay));
    } else {
        view.setBackgroundDrawable(new BitmapDrawable(context.getResources(), overlay));
    }
}
 
源代码11 项目: UltimateAndroid   文件: ImageUtils_Deprecated.java
public static Bitmap getRoundedCornerBitmap(Bitmap bitmap) {

        if (null == bitmap) {
            return bitmap;
        }

        Bitmap output = Bitmap.createBitmap(bitmap.getWidth(), bitmap
                .getHeight(), Config.ARGB_8888);
        Canvas canvas = new Canvas(output);

        final int color = 0xff424242;
        final Paint paint = new Paint();
        final Rect rect = new Rect(0, 0, bitmap.getWidth(), bitmap.getHeight());
        final RectF rectF = new RectF(rect);
        final float roundPx = 10;

        paint.setAntiAlias(true);
        canvas.drawARGB(0, 0, 0, 0);
        paint.setColor(color);
        canvas.drawRoundRect(rectF, roundPx, roundPx, paint);

        paint.setXfermode(new PorterDuffXfermode(Mode.SRC_IN));
        canvas.drawBitmap(bitmap, rect, rect, paint);

        return output;
    }
 
源代码12 项目: XFrame   文件: XBitmapUtils.java
/**
 * 获得圆角的Bitmap
 *
 * @param bitmap  源Bitmap
 * @param roundPx 圆角大小
 * @return 期望Bitmap
 */
public static Bitmap getRoundedCornerBitmap(Bitmap bitmap, float roundPx) {

    Bitmap output = Bitmap.createBitmap(bitmap.getWidth(),
            bitmap.getHeight(), Config.ARGB_8888);
    Canvas canvas = new Canvas(output);

    final int color = 0xff424242;
    final Paint paint = new Paint();
    final Rect rect = new Rect(0, 0, bitmap.getWidth(), bitmap.getHeight());
    final RectF rectF = new RectF(rect);

    paint.setAntiAlias(true);
    canvas.drawARGB(0, 0, 0, 0);
    paint.setColor(color);
    canvas.drawRoundRect(rectF, roundPx, roundPx, paint);

    paint.setXfermode(new PorterDuffXfermode(Mode.SRC_IN));
    canvas.drawBitmap(bitmap, rect, rect, paint);

    return output;
}
 
源代码13 项目: CatVision-io-SDK-Android   文件: GameView.java
private Bitmap getResBitmap(int bmpResId) {
	Options opts = new Options();
	opts.inDither = false;

	Resources res = getResources();
	Bitmap bmp = BitmapFactory.decodeResource(res, bmpResId, opts);

	if (bmp == null && isInEditMode()) {
		// BitmapFactory.decodeResource doesn't work from the rendering
		// library in Eclipse's Graphical Layout Editor. Use this workaround instead.

		Drawable d = res.getDrawable(bmpResId);
		int w = d.getIntrinsicWidth();
		int h = d.getIntrinsicHeight();
		bmp = Bitmap.createBitmap(w, h, Config.ARGB_8888);
		Canvas c = new Canvas(bmp);
		d.setBounds(0, 0, w - 1, h - 1);
		d.draw(c);
	}

	return bmp;
}
 
@Override
public Bitmap onLoadBitmap(final Config pBitmapConfig) {
	final Picture picture = this.mPicture;
	if(picture == null) {
		Debug.e("Failed loading Bitmap in " + this.getClass().getSimpleName() + ".");
		return null;
	}

	final Bitmap bitmap = Bitmap.createBitmap(this.mTextureWidth, this.mTextureHeight, pBitmapConfig);
	final Canvas canvas = new Canvas(bitmap);

	final float scaleX = (float)this.mTextureWidth / this.mPicture.getWidth();
	final float scaleY = (float)this.mTextureHeight / this.mPicture.getHeight();
	canvas.scale(scaleX, scaleY, 0, 0);

	picture.draw(canvas);

	return bitmap;
}
 
源代码15 项目: shinny-futures-android   文件: ImageUtils.java
public static Bitmap getRoundedCornerBitmap(Bitmap bitmap, int pixels) {
    Bitmap output = Bitmap.createBitmap(bitmap.getWidth(), bitmap
            .getHeight(), Config.ARGB_8888);
    Canvas canvas = new Canvas(output);

    final int color = 0xff424242;
    final Paint paint = new Paint();
    final Rect rect = new Rect(0, 0, bitmap.getWidth(), bitmap.getHeight());
    final RectF rectF = new RectF(rect);
    final float roundPx = pixels;

    paint.setAntiAlias(true);
    canvas.drawARGB(0, 0, 0, 0);
    paint.setColor(color);
    canvas.drawRoundRect(rectF, roundPx, roundPx, paint);

    paint.setXfermode(new PorterDuffXfermode(Mode.SRC_IN));
    canvas.drawBitmap(bitmap, rect, rect, paint);

    return output;
}
 
源代码16 项目: FlexibleRichTextView   文件: TeXFormula.java
public void createImage(Bitmap.CompressFormat format, int style,
		float size, String out, Integer bg, Integer fg, boolean transparency)
		throws IOException {
	TeXIcon icon = createTeXIcon(style, size);
	icon.setInsets(new Insets(1, 1, 1, 1));
	int w = icon.getIconWidth(), h = icon.getIconHeight();

	Bitmap image = Bitmap.createBitmap(w, h, Config.ARGB_8888);
	Canvas g2 = new Canvas(image);
	if (bg != null) {
		Paint st = new Paint();
		st.setStyle(Style.FILL_AND_STROKE);
		st.setColor(bg);
		g2.drawRect(0, 0, w, h, st);
	}

	icon.setForeground(fg == null ? Color.BLACK : fg);
	icon.paintIcon(g2, 0, 0);
	File file = new File(out);
	FileOutputStream imout = new FileOutputStream(file);
	image.compress(format, 90, imout);
	imout.flush();
	imout.close();
}
 
源代码17 项目: ClipCircleHeadLikeQQ   文件: RoundedDrawable.java
public static Bitmap drawableToBitmap(Drawable drawable) {
  if (drawable instanceof BitmapDrawable) {
    return ((BitmapDrawable) drawable).getBitmap();
  }

  Bitmap bitmap;
  int width = Math.max(drawable.getIntrinsicWidth(), 2);
  int height = Math.max(drawable.getIntrinsicHeight(), 2);
  try {
    bitmap = Bitmap.createBitmap(width, height, Config.ARGB_8888);
    Canvas canvas = new Canvas(bitmap);
    drawable.setBounds(0, 0, canvas.getWidth(), canvas.getHeight());
    drawable.draw(canvas);
  } catch (Exception e) {
    e.printStackTrace();
    Log.w(TAG, "Failed to create bitmap from drawable!");
    bitmap = null;
  }

  return bitmap;
}
 
源代码18 项目: droidddle   文件: ThemeListPreference.java
public static Bitmap getPreviewBitmap(float density, int color) {
    if (density == 0) {
        density = 1.5f;
    }
    int d = (int) (density * 31); // 30dip
    Bitmap bm = Bitmap.createBitmap(d, d, Config.ARGB_8888);
    int w = bm.getWidth();
    int h = bm.getHeight();
    int c = color;
    for (int i = 0; i < w; i++) {
        for (int j = i; j < h; j++) {
            c = (i <= 1 || j <= 1 || i >= w - 2 || j >= h - 2) ? Color.GRAY : color;
            bm.setPixel(i, j, c);
            if (i != j) {
                bm.setPixel(j, i, c);
            }
        }
    }

    return bm;
}
 
源代码19 项目: dbclf   文件: ClassifierActivity.java
@Override
public void onPreviewSizeChosen(final Size size, final int rotation) {
    previewWidth = size.getWidth();
    previewHeight = size.getHeight();

    final int sensorOrientation = rotation - getScreenOrientation();

    rgbFrameBitmap = Bitmap.createBitmap(previewWidth, previewHeight, Config.ARGB_8888);
    croppedBitmap = Bitmap.createBitmap(INPUT_SIZE, INPUT_SIZE, Config.ARGB_8888);

    frameToCropTransform = ImageUtils.getTransformationMatrix(
            previewWidth, previewHeight,
            INPUT_SIZE, INPUT_SIZE,
            sensorOrientation, MAINTAIN_ASPECT);

    final Matrix cropToFrameTransform = new Matrix();
    frameToCropTransform.invert(cropToFrameTransform);
}
 
源代码20 项目: Roid-Library   文件: RLImgUtil.java
/**
 * @param bitmap
 * @return
 */
public static Bitmap createReflectionImageWithOrigin(Bitmap bitmap) {
    final int reflectionGap = 4;
    int w = bitmap.getWidth();
    int h = bitmap.getHeight();
    Matrix matrix = new Matrix();
    matrix.preScale(1, -1);
    Bitmap reflectionImage = Bitmap.createBitmap(bitmap, 0, h / 2, w, h / 2, matrix, false);
    Bitmap bitmapWithReflection = Bitmap.createBitmap(w, (h + h / 2), Config.ARGB_8888);
    Canvas canvas = new Canvas(bitmapWithReflection);
    canvas.drawBitmap(bitmap, 0, 0, null);
    Paint deafalutPaint = new Paint();
    canvas.drawRect(0, h, w, h + reflectionGap, deafalutPaint);
    canvas.drawBitmap(reflectionImage, 0, h + reflectionGap, null);
    Paint paint = new Paint();
    LinearGradient shader = new LinearGradient(0, bitmap.getHeight(), 0, bitmapWithReflection.getHeight()
            + reflectionGap, 0x70ffffff, 0x00ffffff, TileMode.CLAMP);
    paint.setShader(shader);
    // Set the Transfer mode to be porter duff and destination in
    paint.setXfermode(new PorterDuffXfermode(Mode.DST_IN));
    // Draw a rectangle using the paint with our linear gradient
    canvas.drawRect(0, h, w, bitmapWithReflection.getHeight() + reflectionGap, paint);
    return bitmapWithReflection;
}
 
源代码21 项目: AndroidStudyDemo   文件: BitmapUtil.java
/**
 * 将彩色图转换为黑白图
 *
 * @param bmp 位图
 * @return 返回转换好的位图
 */
public static Bitmap convertToBlackWhite(Bitmap bmp) {
    int width = bmp.getWidth();
    int height = bmp.getHeight();
    int[] pixels = new int[width * height];
    bmp.getPixels(pixels, 0, width, 0, 0, width, height);

    int alpha = 0xFF << 24; // 默认将bitmap当成24色图片
    for (int i = 0; i < height; i++) {
        for (int j = 0; j < width; j++) {
            int grey = pixels[width * i + j];

            int red = ((grey & 0x00FF0000) >> 16);
            int green = ((grey & 0x0000FF00) >> 8);
            int blue = (grey & 0x000000FF);

            grey = (int) (red * 0.3 + green * 0.59 + blue * 0.11);
            grey = alpha | (grey << 16) | (grey << 8) | grey;
            pixels[width * i + j] = grey;
        }
    }
    Bitmap newBmp = Bitmap.createBitmap(width, height, Config.RGB_565);
    newBmp.setPixels(pixels, 0, width, 0, 0, width, height);
    return newBmp;
}
 
源代码22 项目: AndroidMathKeyboard   文件: TeXFormula.java
public void createImage(Bitmap.CompressFormat format, int style,
		float size, String out, Integer bg, Integer fg, boolean transparency)
		throws IOException {
	TeXIcon icon = createTeXIcon(style, size);
	icon.setInsets(new Insets(1, 1, 1, 1));
	int w = icon.getIconWidth(), h = icon.getIconHeight();

	Bitmap image = Bitmap.createBitmap(w, h, Config.ARGB_8888);
	Canvas g2 = new Canvas(image);
	if (bg != null) {
		Paint st = new Paint();
		st.setStyle(Style.FILL_AND_STROKE);
		st.setColor(bg);
		g2.drawRect(0, 0, w, h, st);
	}

	icon.setForeground(fg == null ? Color.BLACK : fg);
	icon.paintIcon(g2, 0, 0);
	File file = new File(out);
	FileOutputStream imout = new FileOutputStream(file);
	image.compress(format, 90, imout);
	imout.flush();
	imout.close();
}
 
源代码23 项目: Auie   文件: UEImage.java
public UEImage transformRound(float radius){
	final int width = bitmap.getWidth();
	final int height = bitmap.getHeight();
	final int color = 0xff888888; 
	final Paint paint = new Paint();
	final Rect rect = new Rect(0, 0, width, height);
	final RectF rectF = new RectF(rect);
	if (radius == TRANSFORMROUND_CIRCLE) {
		radius = width > height ? width/2 : height/2;
	}
	Bitmap mBitmap = Bitmap.createBitmap(width, height, Config.ARGB_8888);
	Canvas canvas = new Canvas(mBitmap);
	paint.setAntiAlias(true);
	paint.setColor(color);
	canvas.drawARGB(0, 0, 0, 0);
	canvas.drawRoundRect(rectF, radius, radius, paint);
	paint.setXfermode(new PorterDuffXfermode(Mode.SRC_IN));
	canvas.drawBitmap(bitmap, rect, rect, paint);
	this.bitmap = mBitmap;
	return this;
}
 
源代码24 项目: CameraV   文件: ImageUtility.java
public static Bitmap drawableToBitmap(Drawable d) {
	if(d instanceof BitmapDrawable) {
		return ((BitmapDrawable) d).getBitmap();
	}
	
	int w = d.getIntrinsicWidth();
	w = w > 0 ? w : 1;
	
	int h = d.getIntrinsicHeight();
	h = h > 0 ? h : 1;
	
	Bitmap b = Bitmap.createBitmap(w, h, Config.ARGB_8888);
	Canvas c = new Canvas(b);
	d.setBounds(0, 0, c.getWidth(), c.getHeight());
	d.draw(c);
	
	return b;
}
 
源代码25 项目: Loop   文件: RoundedDrawable.java
public static Bitmap drawableToBitmap(Drawable drawable) {
    if (drawable instanceof BitmapDrawable) {
        return ((BitmapDrawable) drawable).getBitmap();
    }

    Bitmap bitmap;
    int width = Math.max(drawable.getIntrinsicWidth(), 2);
    int height = Math.max(drawable.getIntrinsicHeight(), 2);
    try {
        bitmap = Bitmap.createBitmap(width, height, Config.ARGB_8888);
        Canvas canvas = new Canvas(bitmap);
        drawable.setBounds(0, 0, canvas.getWidth(), canvas.getHeight());
        drawable.draw(canvas);
    } catch (Exception e) {
        e.printStackTrace();
        Log.w(TAG, "Failed to create bitmap from drawable!");
        bitmap = null;
    }

    return bitmap;
}
 
源代码26 项目: volley   文件: ImageRequestTest.java
private void verifyResize(
        NetworkResponse networkResponse,
        int maxWidth,
        int maxHeight,
        ScaleType scaleType,
        int expectedWidth,
        int expectedHeight) {
    ImageRequest request =
            new ImageRequest("", null, maxWidth, maxHeight, scaleType, Config.RGB_565, null);
    Response<Bitmap> response = request.parseNetworkResponse(networkResponse);
    assertNotNull(response);
    assertTrue(response.isSuccess());
    Bitmap bitmap = response.result;
    assertNotNull(bitmap);
    assertEquals(expectedWidth, bitmap.getWidth());
    assertEquals(expectedHeight, bitmap.getHeight());
}
 
源代码27 项目: PLDroidShortVideo   文件: StickerImageView.java
/**
 * 从 Drawable 中获取 Bitmap 对象
 */
private Bitmap drawable2Bitmap(Drawable drawable) {
    try {
        if (drawable == null) {
            return null;
        }
        if (drawable instanceof BitmapDrawable) {
            return ((BitmapDrawable) drawable).getBitmap();
        }
        int intrinsicWidth = drawable.getIntrinsicWidth();
        int intrinsicHeight = drawable.getIntrinsicHeight();
        Bitmap bitmap = Bitmap.createBitmap(intrinsicWidth <= 0 ? DEFAULT_OTHER_DRAWABLE_WIDTH : intrinsicWidth, intrinsicHeight <= 0 ? DEFAULT_OTHER_DRAWABLE_HEIGHT : intrinsicHeight, Config.ARGB_8888);
        Canvas canvas = new Canvas(bitmap);
        drawable.setBounds(0, 0, canvas.getWidth(), canvas.getHeight());
        drawable.draw(canvas);
        return bitmap;
    } catch (OutOfMemoryError e) {
        return null;
    }
}
 
源代码28 项目: XERUNG   文件: Button.java
/**
 * @return 涟漪的bitmap
 */
public Bitmap makeCircle() {
	// 画涟漪时要考虑到按钮的边界区域,不要把按钮的阴影边界也填满了
	Bitmap output = Bitmap.createBitmap(
			getWidth() - Utils.dpToPx(6, getResources()), 
			getHeight() - Utils.dpToPx(7, getResources()), Config.ARGB_8888);
	return makeCircleFromBitmap(output);
}
 
源代码29 项目: VinylMusicPlayer   文件: ScalingUtil.java
/**
 * Utility function for creating a scaled version of an existing bitmap
 *
 * @param unscaledBitmap Bitmap to scale
 * @param dstWidth Wanted width of destination bitmap
 * @param dstHeight Wanted height of destination bitmap
 * @param scalingLogic Logic to use to avoid image stretching
 * @return New scaled bitmap object
 */
public static Bitmap createScaledBitmap(Bitmap unscaledBitmap, int dstWidth, int dstHeight,
        ScalingLogic scalingLogic) {
    Rect srcRect = calculateSrcRect(unscaledBitmap.getWidth(), unscaledBitmap.getHeight(),
            dstWidth, dstHeight, scalingLogic);
    Rect dstRect = calculateDstRect(unscaledBitmap.getWidth(), unscaledBitmap.getHeight(),
            dstWidth, dstHeight, scalingLogic);
    Bitmap scaledBitmap = Bitmap.createBitmap(dstRect.width(), dstRect.height(),
            Config.ARGB_8888);
    Canvas canvas = new Canvas(scaledBitmap);
    canvas.drawBitmap(unscaledBitmap, srcRect, dstRect, new Paint(Paint.FILTER_BITMAP_FLAG));

    return scaledBitmap;
}
 
源代码30 项目: TurboLauncher   文件: BitmapRegionTileSource.java
public boolean loadInBackground() {
    ExifInterface ei = new ExifInterface();
    if (readExif(ei)) {
        Integer ori = ei.getTagIntValue(ExifInterface.TAG_ORIENTATION);
        if (ori != null) {
            mRotation = ExifInterface.getRotationForOrientationValue(ori.shortValue());
        }
    }
    mDecoder = loadBitmapRegionDecoder();
    if (mDecoder == null) {
        mState = State.ERROR_LOADING;
        return false;
    } else {
        int width = mDecoder.getWidth();
        int height = mDecoder.getHeight();
        if (mPreviewSize != 0) {
            int previewSize = Math.min(mPreviewSize, MAX_PREVIEW_SIZE);
            BitmapFactory.Options opts = new BitmapFactory.Options();
            opts.inPreferredConfig = Bitmap.Config.ARGB_8888;
            opts.inPreferQualityOverSpeed = true;

            float scale = (float) previewSize / Math.max(width, height);
            opts.inSampleSize = BitmapUtils.computeSampleSizeLarger(scale);
            opts.inJustDecodeBounds = false;
            mPreview = loadPreviewBitmap(opts);
        }
        mState = State.LOADED;
        return true;
    }
}