当前位置: 首页>>代码示例>>Java>>正文


Java TileMode.CLAMP属性代码示例

本文整理汇总了Java中android.graphics.Shader.TileMode.CLAMP属性的典型用法代码示例。如果您正苦于以下问题:Java TileMode.CLAMP属性的具体用法?Java TileMode.CLAMP怎么用?Java TileMode.CLAMP使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在android.graphics.Shader.TileMode的用法示例。


在下文中一共展示了TileMode.CLAMP属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createColorWheelBitmap

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:MLNO,项目名称:airgram,代码行数:26,代码来源:ColorPicker.java

示例2: createColorDiscBitmap

private Bitmap createColorDiscBitmap(int radius) {
    int centerColor, edgeColor;
    Bitmap bitmap = Bitmap.createBitmap(2 * radius, 2 * radius, Config.ARGB_8888);

    Canvas canvas = new Canvas(bitmap);
    mHSV[0] = 0; mHSV[1] = 1; mHSV[2] = 1;   //red
    SweepGradient sweepGradient = new SweepGradient(radius, radius, getColors(mHSV), null);
    mColorPaint.setShader(sweepGradient);
    canvas.drawCircle(radius, radius, radius, mColorPaint);

    mHSV[0] = 0; mHSV[1] = 0; mHSV[2] = 1;   //white
    centerColor = Color.HSVToColor(255, mHSV);
    edgeColor = Color.HSVToColor(0, mHSV);
    RadialGradient radialGradient = new RadialGradient(radius, radius, radius, centerColor, edgeColor, TileMode.CLAMP);
    mColorPaint.setShader(radialGradient);
    canvas.drawCircle(radius, radius, radius, mColorPaint);

    return bitmap;
}
 
开发者ID:dftec-es,项目名称:planetcon,代码行数:19,代码来源:ColorPicker.java

示例3: setBitmapShader

/**
 * 设置BitmapShader
 */
private void setBitmapShader() {
    Drawable drawable = getDrawable();
    if (null == drawable) {
        return;
    }
    Bitmap bitmap = drawableToBitmap(drawable);
    // 将bitmap作为着色器来创建一个BitmapShader
    mBitmapShader = new BitmapShader(bitmap, TileMode.CLAMP, TileMode.CLAMP);
    float scale = 1.0f;
    if (mType == TYPE_CIRCLE) {
        // 拿到bitmap宽或高的小值
        int bSize = Math.min(bitmap.getWidth(), bitmap.getHeight());
        scale = mWidth * 1.0f / bSize;

    } else if (mType == TYPE_ROUND || mType == TYPE_OVAL) {
        // 如果图片的宽或者高与view的宽高不匹配,计算出需要缩放的比例;缩放后的图片的宽高,一定要大于我们view的宽高;所以我们这里取大值;
        scale = Math.max(getWidth() * 1.0f / bitmap.getWidth(), getHeight() * 1.0f / bitmap.getHeight());
    }
    // shader的变换矩阵,我们这里主要用于放大或者缩小
    mMatrix.setScale(scale, scale);
    // 设置变换矩阵
    mBitmapShader.setLocalMatrix(mMatrix);
    mPaint.setShader(mBitmapShader);

}
 
开发者ID:newDeepLearing,项目名称:decoy,代码行数:28,代码来源:ZQRoundOvalImageView.java

示例4: SelectableRoundedCornerDrawable

public SelectableRoundedCornerDrawable(Bitmap bitmap, Resources r) {
    this.mBitmap = bitmap;
    this.mBitmapShader = new BitmapShader(bitmap, TileMode.CLAMP, TileMode.CLAMP);
    if (bitmap != null) {
        this.mBitmapWidth = bitmap.getScaledWidth(r.getDisplayMetrics());
        this.mBitmapHeight = bitmap.getScaledHeight(r.getDisplayMetrics());
    } else {
        this.mBitmapHeight = -1;
        this.mBitmapWidth = -1;
    }
    this.mBitmapRect.set(0.0f, 0.0f, (float) this.mBitmapWidth, (float) this.mBitmapHeight);
    this.mBitmapPaint = new Paint(1);
    this.mBitmapPaint.setStyle(Style.FILL);
    this.mBitmapPaint.setShader(this.mBitmapShader);
    this.mBorderPaint = new Paint(1);
    this.mBorderPaint.setStyle(Style.STROKE);
    this.mBorderPaint.setColor(this.mBorderColor.getColorForState(getState(), -16777216));
    this.mBorderPaint.setStrokeWidth(this.mBorderWidth);
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:19,代码来源:SelectableRoundedImageView.java

示例5: setup

private void setup() {
    if (!this.mReady) {
        this.mSetupPending = true;
    } else if (this.mBitmap != null) {
        this.mBitmapShader = new BitmapShader(this.mBitmap, TileMode.CLAMP, TileMode.CLAMP);
        this.mBitmapPaint.setAntiAlias(true);
        this.mBitmapPaint.setShader(this.mBitmapShader);
        this.mBorderPaint.setStyle(Style.STROKE);
        this.mBorderPaint.setAntiAlias(true);
        this.mBorderPaint.setColor(this.mBorderColor);
        this.mBorderPaint.setStrokeWidth((float) this.mBorderWidth);
        this.mBitmapHeight = this.mBitmap.getHeight();
        this.mBitmapWidth = this.mBitmap.getWidth();
        this.mBorderRect.set(0.0f, 0.0f, (float) getWidth(), (float) getHeight());
        this.mBorderRadius = Math.min((this.mBorderRect.height() - ((float) this.mBorderWidth)) / 2.0f, (this.mBorderRect.width() - ((float) this.mBorderWidth)) / 2.0f);
        this.mDrawableRect.set((float) this.mBorderWidth, (float) this.mBorderWidth, this.mBorderRect.width() - ((float) this.mBorderWidth), this.mBorderRect.height() - ((float) this.mBorderWidth));
        this.mDrawableRadius = Math.min(this.mDrawableRect.height() / 2.0f, this.mDrawableRect.width() / 2.0f);
        updateShaderMatrix();
        invalidate();
    }
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:21,代码来源:CircleImageView.java

示例6: setUpShader

/**
 * 初始化BitmapShader
 */
private void setUpShader()
{
	Drawable drawable = getDrawable();
	if (drawable == null)
	{
		Log.e("view", "ok");
		return;
	}

	Bitmap bmp = drawableToBitamp(drawable);
	// 将bmp作为着色器,就是在指定区域内绘制bmp
	mBitmapShader = new BitmapShader(bmp, TileMode.CLAMP, TileMode.CLAMP);
	float scale = 1.0f;
	int bSize = Math.min(bmp.getWidth(), bmp.getHeight());
	scale = getWidth() * 1.0f / bSize;
	// shader的变换矩阵,我们这里主要用于放大或者缩小
	matrix.setScale(scale, scale);
	// 设置变换矩阵
	mBitmapShader.setLocalMatrix(matrix);
	// 设置shader
	paint.setShader(mBitmapShader);
}
 
开发者ID:liudabao,项目名称:Evisa,代码行数:25,代码来源:CircleView.java

示例7: createReflectionImageWithOrigin

public static Bitmap createReflectionImageWithOrigin(Bitmap bitmap){
	final int reflectionGap = 4;
	int width = bitmap.getWidth();
	int height = bitmap.getHeight();
	Matrix matrix = new Matrix();
	matrix.preScale(1, -1);
	Bitmap reflectionImage = Bitmap.createBitmap(bitmap, 0, height/2, width, height/2, matrix, false);
	Bitmap bitmapWithReflection = Bitmap.createBitmap(width, (height + height/2), Config.ARGB_8888);
	Canvas canvas = new Canvas(bitmapWithReflection);
	canvas.drawBitmap(bitmap, 0, 0, null);
	Paint deafalutPaint = new Paint();
	canvas.drawRect(0, height,width,height + reflectionGap, deafalutPaint);
	canvas.drawBitmap(reflectionImage, 0, height + reflectionGap, null);
	Paint paint = new Paint();
	LinearGradient shader = new LinearGradient(0, bitmap.getHeight(), 0, bitmapWithReflection.getHeight()
			+ reflectionGap, 0x70ffffff, 0x00ffffff, TileMode.CLAMP);
	paint.setShader(shader);
	paint.setXfermode(new PorterDuffXfermode(Mode.DST_IN));

	canvas.drawRect(0, height, width, bitmapWithReflection.getHeight()
			+ reflectionGap, paint);
	return bitmapWithReflection;
}
 
开发者ID:javalovercn,项目名称:j2se_for_android,代码行数:23,代码来源:ImageUtil.java

示例8: createReflectionImageWithOrigin

/**
 * 获得带倒影的图片方法
 *
 * @param bitmap 源图片
 * @return 带倒影图片
 */
public static Bitmap createReflectionImageWithOrigin(Bitmap bitmap) {
    final int reflectionGap = 4;
    int width = bitmap.getWidth();
    int height = bitmap.getHeight();
    Matrix matrix = new Matrix();
    matrix.preScale(1, -1);
    Bitmap reflectionImage = HSBitmapUtil.createBitmap(bitmap, 0,
            height / 2, width, height / 2, matrix, false);
    Bitmap bitmapWithReflection = HSBitmapUtil.createBitmap(width,
            (height + height / 2), Config.ARGB_8888);
    Canvas canvas = new Canvas(bitmapWithReflection);
    canvas.drawBitmap(bitmap, 0, 0, null);
    Paint deafalutPaint = new Paint();
    canvas.drawRect(0, height, width, height + reflectionGap, deafalutPaint);
    canvas.drawBitmap(reflectionImage, 0, height + reflectionGap, null);
    Paint paint = new Paint();
    LinearGradient shader = new LinearGradient(0, bitmap.getHeight(), 0,
            bitmapWithReflection.getHeight() + reflectionGap, 0x70ffffff,
            0x00ffffff, TileMode.CLAMP);
    paint.setShader(shader);
    paint.setXfermode(new PorterDuffXfermode(Mode.DST_IN));
    canvas.drawRect(0, height, width, bitmapWithReflection.getHeight()
            + reflectionGap, paint);
    return bitmapWithReflection;
}
 
开发者ID:WangGanxin,项目名称:Codebase,代码行数:31,代码来源:BitmapUtil.java

示例9: generate

public GVRBitmapTexture generate(GVRContext context, int[] colors, float[] stops) {
    Bitmap bitmap = Bitmap.createBitmap(WIDTH, HEIGHT, Bitmap.Config.ARGB_8888);
    Canvas canvas = new Canvas(bitmap);

    Shader shader = new LinearGradient(0,0, 0, HEIGHT,
        colors, stops,
        TileMode.CLAMP);

    Paint paint = new Paint();
    paint.setShader(shader);

    canvas.drawRect(new Rect(0, 0, WIDTH, HEIGHT), paint);

    GVRBitmapTexture texture = new GVRBitmapTexture(context, bitmap);

    return texture;
}
 
开发者ID:mrgrimnevil,项目名称:browser-vr,代码行数:17,代码来源:Background.java

示例10: drawAlphaPanel

private void drawAlphaPanel(Canvas canvas) {
    if (!mShowAlphaPanel || mAlphaRect == null || mAlphaPattern == null) {
        return;
    }

    final RectF rect = mAlphaRect;

    if (BORDER_WIDTH_PX > 0) {
        mBorderPaint.setColor(mBorderColor);
        canvas.drawRect(rect.left - BORDER_WIDTH_PX,
                rect.top - BORDER_WIDTH_PX,
                rect.right + BORDER_WIDTH_PX,
                rect.bottom + BORDER_WIDTH_PX,
                mBorderPaint);
    }

    mAlphaPattern.draw(canvas);

    float[] hsv = new float[] {
            mHue, mSat, mVal
    };
    int color = Color.HSVToColor(hsv);
    int acolor = Color.HSVToColor(0, hsv);

    mAlphaShader = new LinearGradient(rect.left, rect.top, rect.right, rect.top,
            color, acolor, TileMode.CLAMP);

    mAlphaPaint.setShader(mAlphaShader);

    canvas.drawRect(rect, mAlphaPaint);

    if (mAlphaSliderText != null && mAlphaSliderText != "") {
        canvas.drawText(mAlphaSliderText, rect.centerX(), rect.centerY() + 4 * mDensity,
                mAlphaTextPaint);
    }

    float rectWidth = 4 * mDensity / 2;
    Point p = alphaToPoint(mAlpha);

    RectF r = new RectF();
    r.left = p.x - rectWidth;
    r.right = p.x + rectWidth;
    r.top = rect.top - RECTANGLE_TRACKER_OFFSET;
    r.bottom = rect.bottom + RECTANGLE_TRACKER_OFFSET;

    canvas.drawRoundRect(r, 2, 2, mHueTrackerPaint);
}
 
开发者ID:ric96,项目名称:lineagex86,代码行数:47,代码来源:ColorPickerView.java

示例11: setColor

public void setColor(int color) {
	int[] colors = new int[] {
			color,
			color,
			Color.argb(0, Color.red(color), Color.green(color),
					Color.blue(color)) };
	float[] points = new float[] { 0.0f, 1.0f, 1.0f };

	points[points.length - 2] = lastPOint;
	LinearGradient Lg = new LinearGradient(0, 2, 379, 2, colors, points,
			TileMode.CLAMP);
	Lg.setLocalMatrix(matrix);
	P0.setShader(Lg);
}
 
开发者ID:KishanV,项目名称:Android-Canvas-Shape-Exporter-From-Flash-Symbol,代码行数:14,代码来源:textImg.java

示例12: draw

public void draw(@NonNull Canvas canvas) {
    if (this.mRebuildShader) {
        BitmapShader bitmapShader = new BitmapShader(this.mBitmap, this.mTileModeX, this
                .mTileModeY);
        if (this.mTileModeX == TileMode.CLAMP && this.mTileModeY == TileMode.CLAMP) {
            bitmapShader.setLocalMatrix(this.mShaderMatrix);
        }
        this.mBitmapPaint.setShader(bitmapShader);
        this.mRebuildShader = false;
    }
    if (this.mOval) {
        if (this.mBorderWidth > 0.0f) {
            canvas.drawOval(this.mDrawableRect, this.mBitmapPaint);
            canvas.drawOval(this.mBorderRect, this.mBorderPaint);
            return;
        }
        canvas.drawOval(this.mDrawableRect, this.mBitmapPaint);
    } else if (any(this.mCornersRounded)) {
        float radius = this.mCornerRadius;
        if (this.mBorderWidth > 0.0f) {
            canvas.drawRoundRect(this.mDrawableRect, radius, radius, this.mBitmapPaint);
            canvas.drawRoundRect(this.mBorderRect, radius, radius, this.mBorderPaint);
            redrawBitmapForSquareCorners(canvas);
            redrawBorderForSquareCorners(canvas);
            return;
        }
        canvas.drawRoundRect(this.mDrawableRect, radius, radius, this.mBitmapPaint);
        redrawBitmapForSquareCorners(canvas);
    } else {
        canvas.drawRect(this.mDrawableRect, this.mBitmapPaint);
        if (this.mBorderWidth > 0.0f) {
            canvas.drawRect(this.mBorderRect, this.mBorderPaint);
        }
    }
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:35,代码来源:RoundedDrawable.java

示例13: RoundedDrawable

public RoundedDrawable(Bitmap bitmap, int cornerRadius, int margin) {
    this.cornerRadius = (float) cornerRadius;
    this.margin = margin;
    this.bitmapShader = new BitmapShader(bitmap, TileMode.CLAMP, TileMode.CLAMP);
    this.mBitmapRect = new RectF((float) margin, (float) margin, (float) (bitmap.getWidth() - margin), (float) (bitmap.getHeight() - margin));
    this.paint = new Paint();
    this.paint.setAntiAlias(true);
    this.paint.setShader(this.bitmapShader);
}
 
开发者ID:JackChan1999,项目名称:letv,代码行数:9,代码来源:RoundedBitmapDisplayer.java

示例14: draw

public void draw(Canvas canvas) {
    if (this.mRebuildShader) {
        BitmapShader bitmapShader = new BitmapShader(this.mBitmap, this.mTileModeX, this.mTileModeY);
        if (this.mTileModeX == TileMode.CLAMP && this.mTileModeY == TileMode.CLAMP) {
            bitmapShader.setLocalMatrix(this.mShaderMatrix);
        }
        this.mBitmapPaint.setShader(bitmapShader);
        this.mRebuildShader = false;
    }
    if (this.mOval) {
        if (this.mBorderWidth > 0.0f) {
            canvas.drawOval(this.mDrawableRect, this.mBitmapPaint);
            canvas.drawOval(this.mBorderRect, this.mBorderPaint);
            return;
        }
        canvas.drawOval(this.mDrawableRect, this.mBitmapPaint);
    } else if (any(this.mCornersRounded)) {
        float radius = this.mCornerRadius;
        if (this.mBorderWidth > 0.0f) {
            canvas.drawRoundRect(this.mDrawableRect, radius, radius, this.mBitmapPaint);
            canvas.drawRoundRect(this.mBorderRect, radius, radius, this.mBorderPaint);
            redrawBitmapForSquareCorners(canvas);
            redrawBorderForSquareCorners(canvas);
            return;
        }
        canvas.drawRoundRect(this.mDrawableRect, radius, radius, this.mBitmapPaint);
        redrawBitmapForSquareCorners(canvas);
    } else {
        canvas.drawRect(this.mDrawableRect, this.mBitmapPaint);
        if (this.mBorderWidth > 0.0f) {
            canvas.drawRect(this.mBorderRect, this.mBorderPaint);
        }
    }
}
 
开发者ID:JackChan1999,项目名称:letv,代码行数:34,代码来源:RoundedPagerDrawable.java

示例15: onBoundsChange

protected void onBoundsChange(Rect bounds) {
    super.onBoundsChange(bounds);
    RadialGradient vignette = new RadialGradient(this.mRect.centerX(), (this.mRect
            .centerY() * 1.0f) / 0.7f, this.mRect.centerX() * 1.3f, new int[]{0, 0,
            2130706432}, new float[]{0.0f, 0.7f, 1.0f}, TileMode.CLAMP);
    Matrix oval = new Matrix();
    oval.setScale(1.0f, 0.7f);
    vignette.setLocalMatrix(oval);
    this.paint.setShader(new ComposeShader(this.bitmapShader, vignette, Mode.SRC_OVER));
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:10,代码来源:RoundedVignetteBitmapDisplayer.java


注:本文中的android.graphics.Shader.TileMode.CLAMP属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。