當前位置: 首頁>>代碼示例>>Java>>正文


Java Config類代碼示例

本文整理匯總了Java中android.graphics.Bitmap.Config的典型用法代碼示例。如果您正苦於以下問題:Java Config類的具體用法?Java Config怎麽用?Java Config使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Config類屬於android.graphics.Bitmap包,在下文中一共展示了Config類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: roundBitmap

import android.graphics.Bitmap.Config; //導入依賴的package包/類
public static Bitmap roundBitmap(Bitmap bitmap, int i, int i2, float f, float f2, float f3,
                                 float f4) throws Throwable {
    int width = bitmap.getWidth();
    int height = bitmap.getHeight();
    Rect rect = new Rect(0, 0, width, height);
    Bitmap createBitmap = (width == i && height == i2) ? Bitmap.createBitmap(bitmap.getWidth
            (), bitmap.getHeight(), Config.ARGB_8888) : Bitmap.createBitmap(i, i2, Config
            .ARGB_8888);
    Canvas canvas = new Canvas(createBitmap);
    Paint paint = new Paint();
    Rect rect2 = new Rect(0, 0, i, i2);
    paint.setAntiAlias(true);
    canvas.drawARGB(0, 0, 0, 0);
    paint.setColor(-12434878);
    float[] fArr = new float[]{f, f, f2, f2, f3, f3, f4, f4};
    ShapeDrawable shapeDrawable = new ShapeDrawable(new RoundRectShape(fArr, new RectF(0.0f,
            0.0f, 0.0f, 0.0f), fArr));
    shapeDrawable.setBounds(rect2);
    shapeDrawable.draw(canvas);
    paint.setXfermode(new PorterDuffXfermode(Mode.SRC_IN));
    canvas.drawBitmap(bitmap, rect, rect2, paint);
    return createBitmap;
}
 
開發者ID:JackChan1999,項目名稱:boohee_v5.6,代碼行數:24,代碼來源:BitmapHelper.java

示例2: drawableToBitmap

import android.graphics.Bitmap.Config; //導入依賴的package包/類
public static Bitmap drawableToBitmap(Drawable drawable) {
    if (drawable == null) {
        return null;
    }
    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 (IllegalArgumentException e) {
        e.printStackTrace();
        return null;
    }
}
 
開發者ID:JackChan1999,項目名稱:boohee_v5.6,代碼行數:20,代碼來源:SelectableRoundedImageView.java

示例3: combineImages

import android.graphics.Bitmap.Config; //導入依賴的package包/類
/**
 * 合並Bitmap
 *
 * @param bgd 背景Bitmap
 * @param fg  前景Bitmap
 * @return 合成後的Bitmap
 */
public static Bitmap combineImages(Bitmap bgd, Bitmap fg) {
    Bitmap bmp;

    int width = bgd.getWidth() > fg.getWidth() ? bgd.getWidth() : fg
            .getWidth();
    int height = bgd.getHeight() > fg.getHeight() ? bgd.getHeight() : fg
            .getHeight();

    bmp = Bitmap.createBitmap(width, height, Config.ARGB_8888);
    Paint paint = new Paint();
    paint.setXfermode(new PorterDuffXfermode(Mode.SRC_ATOP));

    Canvas canvas = new Canvas(bmp);
    canvas.drawBitmap(bgd, 0, 0, null);
    canvas.drawBitmap(fg, 0, 0, paint);

    return bmp;
}
 
開發者ID:youth5201314,項目名稱:XFrame,代碼行數:26,代碼來源:XBitmapUtils.java

示例4: createQRCode

import android.graphics.Bitmap.Config; //導入依賴的package包/類
public static Bitmap createQRCode(String str, int size) throws WriterException {
	Hashtable<EncodeHintType, String> hints = new Hashtable<EncodeHintType, String>();
	hints.put(EncodeHintType.CHARACTER_SET, "utf-8");
	BitMatrix matrix = new MultiFormatWriter().encode(str, BarcodeFormat.QR_CODE, size, size);
	int width = matrix.getWidth();
	int height = matrix.getHeight();
	int[] pixels = new int[width * height];
	for(int x = 0; x < width; x ++){
		for(int y = 0; y < height; y ++){
			if(matrix.get(x, y)){
				pixels[y * width + x] = BLACK;
			}
		}
	}
	Bitmap bitmap = Bitmap.createBitmap(width, height, Config.ARGB_8888);
	bitmap.setPixels(pixels, 0, width, 0, 0, width, height);
	return bitmap;
}
 
開發者ID:yun2win,項目名稱:tvConnect_android,代碼行數:19,代碼來源:EncodingHandler.java

示例5: MapClusterOptionsProvider

import android.graphics.Bitmap.Config; //導入依賴的package包/類
public MapClusterOptionsProvider(Resources resources) {
    int poiSize = resources.getDimensionPixelSize(R.dimen.map_poi_size);

    Drawable d = ResourcesCompat.getDrawable(resources, R.drawable.ic_wrapper_poi_cluster, null);
    d.setBounds(0, 0, poiSize, poiSize);
    Bitmap bitmap = Bitmap.createBitmap(poiSize, poiSize, Config.ARGB_8888);
    Canvas canvas = new Canvas(bitmap);
    d.draw(canvas);
    baseBitmap = bitmap;

    littleFontPaint.setColor(Color.BLACK);
    littleFontPaint.setTextAlign(Align.CENTER);
    littleFontPaint.setFakeBoldText(true);
    littleFontPaint.setTextSize(resources.getDimension(R.dimen.map_marker_cluster_text_size_small));
    bigFontPaint.setColor(Color.BLACK);
    bigFontPaint.setTextAlign(Align.CENTER);
    bigFontPaint.setFakeBoldText(true);
    bigFontPaint.setTextSize(resources.getDimension(R.dimen.map_marker_cluster_text_size_big));
}
 
開發者ID:mosquitolabs,項目名稱:referendum_1o_android,代碼行數:20,代碼來源:MapClusterOptionsProvider.java

示例6: getRoundedCornerBitmap

import android.graphics.Bitmap.Config; //導入依賴的package包/類
/**
 *圓角圖片
 * @param bitmap
 * @return
 */
public static Bitmap getRoundedCornerBitmap(Bitmap 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 = 12;

    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;

}
 
開發者ID:Evan-Galvin,項目名稱:FreeStreams-TVLauncher,代碼行數:28,代碼來源:ImageTools.java

示例7: initCanvas

import android.graphics.Bitmap.Config; //導入依賴的package包/類
private void initCanvas() {
    mOriginalBitmapWidth = mOriginalBitmap.getWidth();
    mOriginalBitmapHeight = mOriginalBitmap.getHeight();

    // 初始狀態值
    mWaveOriginalY = mOriginalBitmapHeight;
    mWaveY = 1.2f * mWaveOriginalY;
    mBezierControlOriginalY = 1.25f * mWaveOriginalY;
    mBezierControlY = mBezierControlOriginalY;

    mXfermode = new PorterDuffXfermode(PorterDuff.Mode.SRC_IN);
    mBezierPath = new Path();

    mCanvas = new Canvas();
    mUltimateBitmap = Bitmap.createBitmap(mOriginalBitmapWidth, mOriginalBitmapHeight, Config.ARGB_8888);
    mCanvas.setBitmap(mUltimateBitmap);
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:18,代碼來源:BGAMoocStyleRefreshView.java

示例8: makeImageRequest

import android.graphics.Bitmap.Config; //導入依賴的package包/類
protected Request<Bitmap> makeImageRequest(String requestUrl, int maxWidth, int maxHeight,
        ScaleType scaleType, final String cacheKey) {
    return new ImageRequest(requestUrl, new Listener<Bitmap>() {
        @Override
        public void onResponse(Bitmap response) {
            onGetImageSuccess(cacheKey, response);
        }
    }, maxWidth, maxHeight, scaleType, Config.RGB_565, new ErrorListener() {
        @Override
        public void onErrorResponse(VolleyError error) {
            onGetImageError(cacheKey, error);
        }
    });
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:15,代碼來源:ImageLoader.java

示例9: drawableToBitmap

import android.graphics.Bitmap.Config; //導入依賴的package包/類
public static Bitmap drawableToBitmap(Drawable drawable) {
    if (drawable == null) return null;

    if (drawable instanceof BitmapDrawable) {
        return ((BitmapDrawable) drawable).getBitmap();
    }

    int width = drawable.getIntrinsicWidth();
    width = width > 0 ? width : 1;
    int height = drawable.getIntrinsicHeight();
    height = height > 0 ? height : 1;

    Bitmap bitmap = Bitmap.createBitmap(width, height, Config.ARGB_8888);
    Canvas canvas = new Canvas(bitmap);
    drawable.setBounds(0, 0, canvas.getWidth(), canvas.getHeight());
    drawable.draw(canvas);

    return bitmap;
}
 
開發者ID:WrBug,項目名稱:GravityBox,代碼行數:20,代碼來源:Utils.java

示例10: createColorWheelBitmap

import android.graphics.Bitmap.Config; //導入依賴的package包/類
private Bitmap createColorWheelBitmap(int width, int height) {

        Bitmap bitmap = Bitmap.createBitmap(width, height, Config.ARGB_8888);

        int colorCount = 12;
        int colorAngleStep = 360 / 12;
        int colors[] = new int[colorCount + 1];
        float hsv[] = new float[] { 0f, 1f, 1f };
        for (int i = 0; i < colors.length; i++) {
            hsv[0] = (i * colorAngleStep + 180) % 360;
            colors[i] = Color.HSVToColor(hsv);
        }
        colors[colorCount] = colors[0];

        SweepGradient sweepGradient = new SweepGradient(width / 2, height / 2, colors, null);
        RadialGradient radialGradient = new RadialGradient(width / 2, height / 2, colorWheelRadius, 0xFFFFFFFF, 0x00FFFFFF, TileMode.CLAMP);
        ComposeShader composeShader = new ComposeShader(sweepGradient, radialGradient, PorterDuff.Mode.SRC_OVER);

        colorWheelPaint.setShader(composeShader);

        Canvas canvas = new Canvas(bitmap);
        canvas.drawCircle(width / 2, height / 2, colorWheelRadius, colorWheelPaint);

        return bitmap;

    }
 
開發者ID:sdrausty,項目名稱:buildAPKsApps,代碼行數:27,代碼來源:ColorPicker.java

示例11: load_withColorDrawable_fixedSize_functionalBitmapTransform_doesNotRecycleOutput

import android.graphics.Bitmap.Config; //導入依賴的package包/類
@Test
public void load_withColorDrawable_fixedSize_functionalBitmapTransform_doesNotRecycleOutput()
    throws ExecutionException, InterruptedException {
  Drawable colorDrawable = new ColorDrawable(Color.RED);

  int width = 100;
  int height = 200;

  Drawable result = GlideApp.with(context)
      .load(colorDrawable)
      .circleCrop()
      .override(width, height)
      .submit()
      .get();

   BitmapSubject.assertThat(result).isNotRecycled();

  BitmapPool bitmapPool = Glide.get(context).getBitmapPool();
  // Make sure we didn't put the same Bitmap twice.
  Bitmap first = bitmapPool.get(width, height, Config.ARGB_8888);
  Bitmap second = bitmapPool.get(width, height, Config.ARGB_8888);

  assertThat(first).isNotSameAs(second);
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:25,代碼來源:DrawableTransformationTest.java

示例12: ensureExpandedTexture

import android.graphics.Bitmap.Config; //導入依賴的package包/類
private void ensureExpandedTexture() {
    if (this.mExpandedTitleTexture == null && !this.mExpandedBounds.isEmpty() && !TextUtils.isEmpty(this.mTextToDraw)) {
        calculateOffsets(0.0f);
        this.mTextureAscent = this.mTextPaint.ascent();
        this.mTextureDescent = this.mTextPaint.descent();
        int w = Math.round(this.mTextPaint.measureText(this.mTextToDraw, 0, this.mTextToDraw.length()));
        int h = Math.round(this.mTextureDescent - this.mTextureAscent);
        if (w > 0 && h > 0) {
            this.mExpandedTitleTexture = Bitmap.createBitmap(w, h, Config.ARGB_8888);
            new Canvas(this.mExpandedTitleTexture).drawText(this.mTextToDraw, 0, this.mTextToDraw.length(), 0.0f, ((float) h) - this.mTextPaint.descent(), this.mTextPaint);
            if (this.mTexturePaint == null) {
                this.mTexturePaint = new Paint(3);
            }
        }
    }
}
 
開發者ID:JackChan1999,項目名稱:boohee_v5.6,代碼行數:17,代碼來源:CollapsingTextHelper.java

示例13: toRoundCorner

import android.graphics.Bitmap.Config; //導入依賴的package包/類
/**
 * 將圖片變為圓角
 * @param bitmap 原Bitmap圖片
 * @param pixels 圖片圓角的弧度(單位:像素(px))
 * @return 帶有圓角的圖片(Bitmap 類型)
 */
public static Bitmap toRoundCorner(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;
}
 
開發者ID:CoderCF,項目名稱:TakePhoto,代碼行數:28,代碼來源:FileUtil.java

示例14: countBitmaps

import android.graphics.Bitmap.Config; //導入依賴的package包/類
@Override
public int countBitmaps(int width, int height, Config config) {
    int c = 0;
    synchronized (mCache) {
        Iterator<Bitmap> it = mCache.iterator();
        while (it.hasNext()) {
            Bitmap bmp = it.next();
            if (bmp.isRecycled()) {
                it.remove();
                continue;
            }
            if (bmp.getWidth() == width && bmp.getHeight() == height && bmp.getConfig() == config) {
                c++;
            }
        }
    }
    return c;
}
 
開發者ID:worldiety,項目名稱:homunculus,代碼行數:19,代碼來源:BitmapPoolFactory.java

示例15: recreateIcon

import android.graphics.Bitmap.Config; //導入依賴的package包/類
public synchronized Bitmap recreateIcon(Bitmap icon) {
    int[] offset = new int[2];
    Bitmap shadow = icon.extractAlpha(mBlurPaint, offset);
    Bitmap result = Bitmap.createBitmap(mIconSize, mIconSize, Config.ARGB_8888);
    mCanvas.setBitmap(result);

    // Draw ambient shadow
    mDrawPaint.setAlpha(AMBIENT_SHADOW_ALPHA);
    mCanvas.drawBitmap(shadow, offset[0], offset[1], mDrawPaint);

    // Draw key shadow
    mDrawPaint.setAlpha(KEY_SHADOW_ALPHA);
    mCanvas.drawBitmap(shadow, offset[0], offset[1] + KEY_SHADOW_DISTANCE * mIconSize, mDrawPaint);

    // Draw the icon
    mDrawPaint.setAlpha(255);
    mCanvas.drawBitmap(icon, 0, 0, mDrawPaint);

    mCanvas.setBitmap(null);
    return result;
}
 
開發者ID:enricocid,項目名稱:LaunchEnr,代碼行數:22,代碼來源:ShadowGenerator.java


注:本文中的android.graphics.Bitmap.Config類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。