微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

android.graphics.Shader.TileMode的实例源码

项目:airgram    文件ColorPicker.java    @H_404_5@
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,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,colorWheelPaint);

        return bitmap;

    }
@H_404_5@ @H_404_5@
项目:airgram    文件multicolorPicker.java    @H_404_5@
private Bitmap createColorWheelBitmap(int width,colorWheelPaint);

        return bitmap;

    }
@H_404_5@ @H_404_5@
项目:planetcon    文件ColorPicker.java    @H_404_5@
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,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,centerColor,edgeColor,TileMode.CLAMP);
    mColorPaint.setShader(radialGradient);
    canvas.drawCircle(radius,mColorPaint);

    return bitmap;
}
@H_404_5@ @H_404_5@
项目:planetcon    文件ColorPicker.java    @H_404_5@
private void drawColorSquare(Canvas canvas) {
    int pureColor,brightColor,darkColor,transparentColor;

    // pureColor
    mHSV[0] = mColorHSV[0];
    mHSV[1] = 1; mHSV[2] = 1;
    pureColor = Color.HSVToColor(mHSV);
    // brightColor
    mHSV[1] = 0; mHSV[2] = 1;
    brightColor = Color.HSVToColor(mHSV);
    // darkColor
    mHSV[1] = 1; mHSV[2] = 0;
    darkColor = Color.HSVToColor(255,mHSV);
    // alphaColor
    mHSV[1] = 0; mHSV[2] = 0;
    transparentColor = Color.HSVToColor(0,mHSV);

    // drawn without compose shader,but looks worse
    Shader gradient1 = new LinearGradient(mSquareRect.right,mSquareRect.bottom,mSquareRect.right,mSquareRect.top,pureColor,TileMode.CLAMP);
    Shader gradient2 = new LinearGradient(mSquareRect.right,mSquareRect.left,transparentColor,TileMode.CLAMP);

    mColorPaint.setShader(gradient1);
    canvas.drawRect(mSquareRect,mColorPaint);
    mColorPaint.setShader(gradient2);
    canvas.drawRect(mSquareRect,mColorPaint);
}
@H_404_5@ @H_404_5@
项目:NoticeDog    文件CircleTransform.java    @H_404_5@
public Bitmap transform(Bitmap source) {
    int size = Math.min(source.getWidth(),source.getHeight());
    Bitmap squaredBitmap = Bitmap.createBitmap(source,(source.getWidth() - size) / 2,(source.getHeight() - size) / 2,size,size);
    if (squaredBitmap != source) {
        source.recycle();
    }
    Bitmap bitmap = Bitmap.createBitmap(size,source.getConfig());
    Canvas canvas = new Canvas(bitmap);
    Paint paint = new Paint();
    paint.setShader(new BitmapShader(squaredBitmap,TileMode.CLAMP,TileMode.CLAMP));
    paint.setAntiAlias(true);
    float r = ((float) size) / 2.0f;
    canvas.drawCircle(r,r,paint);
    squaredBitmap.recycle();
    return bitmap;
}
@H_404_5@ @H_404_5@
项目:buildAPKsApps    文件ColorPicker.java    @H_404_5@
private Bitmap createColorWheelBitmap(int width,colorWheelPaint);

        return bitmap;

    }
@H_404_5@ @H_404_5@
项目:buildAPKsApps    文件multicolorPicker.java    @H_404_5@
private Bitmap createColorWheelBitmap(int width,colorWheelPaint);

        return bitmap;

    }
@H_404_5@ @H_404_5@
项目:boohee_v5.6    文件CircleImageView.java    @H_404_5@
private void setup() {
    if (!this.mReady) {
        this.mSetupPending = true;
    } else if (this.mBitmap != null) {
        this.mBitmapShader = new BitmapShader(this.mBitmap,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();
    }
}
@H_404_5@ @H_404_5@
项目:boohee_v5.6    文件CircleBitmapdisplayer.java    @H_404_5@
public CircleDrawable(Bitmap bitmap,Integer strokeColor,float strokeWidth) {
    this.radius = (float) (Math.min(bitmap.getWidth(),bitmap.getHeight()) / 2);
    this.bitmapShader = new BitmapShader(bitmap,TileMode.CLAMP);
    this.mBitmapRect = new RectF(0.0f,(float) bitmap.getWidth(),(float) bitmap
            .getHeight());
    this.paint = new Paint();
    this.paint.setAntiAlias(true);
    this.paint.setShader(this.bitmapShader);
    this.paint.setFilterBitmap(true);
    this.paint.setDither(true);
    if (strokeColor == null) {
        this.strokePaint = null;
    } else {
        this.strokePaint = new Paint();
        this.strokePaint.setStyle(Style.stroke);
        this.strokePaint.setColor(strokeColor.intValue());
        this.strokePaint.setstrokeWidth(strokeWidth);
        this.strokePaint.setAntiAlias(true);
    }
    this.strokeWidth = strokeWidth;
    this.strokeRadius = this.radius - (strokeWidth / 2.0f);
}
@H_404_5@ @H_404_5@
项目:boohee_v5.6    文件SelectableRoundedImageView.java    @H_404_5@
public SelectableRoundedCornerDrawable(Bitmap bitmap,Resources r) {
    this.mBitmap = bitmap;
    this.mBitmapShader = new BitmapShader(bitmap,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,(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);
}
@H_404_5@ @H_404_5@
项目:boohee_v5.6    文件RoundRectDrawableWithShadow.java    @H_404_5@
private void buildShadowCorners() {
    RectF innerBounds = new RectF(-this.mCornerRadius,-this.mCornerRadius,this.mCornerRadius,this.mCornerRadius);
    RectF outerBounds = new RectF(innerBounds);
    outerBounds.inset(-this.mShadowSize,-this.mShadowSize);
    if (this.mCornerShadowPath == null) {
        this.mCornerShadowPath = new Path();
    } else {
        this.mCornerShadowPath.reset();
    }
    this.mCornerShadowPath.setFillType(FillType.EVEN_ODD);
    this.mCornerShadowPath.moveto(-this.mCornerRadius,0.0f);
    this.mCornerShadowPath.rLineto(-this.mShadowSize,0.0f);
    this.mCornerShadowPath.arcTo(outerBounds,180.0f,90.0f,false);
    this.mCornerShadowPath.arcTo(innerBounds,270.0f,-90.0f,false);
    this.mCornerShadowPath.close();
    float startRatio = this.mCornerRadius / (this.mCornerRadius + this.mShadowSize);
    this.mCornerShadowPaint.setShader(new RadialGradient(0.0f,this.mCornerRadius + this.mShadowSize,new int[]{this.mShadowStartColor,this.mShadowStartColor,this.mShadowEndColor},new float[]{0.0f,startRatio,1.0f},TileMode.CLAMP));
    this.mEdgeShadowPaint.setShader(new LinearGradient(0.0f,(-this.mCornerRadius) + this.mShadowSize,(-this.mCornerRadius) - this.mShadowSize,0.5f,TileMode.CLAMP));
    this.mEdgeShadowPaint.setAntiAlias(false);
}
@H_404_5@ @H_404_5@
项目:boohee_v5.6    文件ShadowDrawableWrapper.java    @H_404_5@
private void buildShadowCorners() {
    RectF innerBounds = new RectF(-this.mCornerRadius,false);
    this.mCornerShadowPath.close();
    float shadowRadius = -outerBounds.top;
    if (shadowRadius > 0.0f) {
        float startRatio = this.mCornerRadius / shadowRadius;
        float midratio = startRatio + ((1.0f - startRatio) / 2.0f);
        this.mCornerShadowPaint.setShader(new RadialGradient(0.0f,shadowRadius,new int[]{0,this.mShadowMiddleColor,midratio,TileMode.CLAMP));
    }
    this.mEdgeShadowPaint.setShader(new LinearGradient(0.0f,innerBounds.top,outerBounds.top,SHADOW_HORIZ_SCALE,TileMode.CLAMP));
    this.mEdgeShadowPaint.setAntiAlias(false);
}
@H_404_5@ @H_404_5@
项目:decoy    文件ZQRoundovalImageView.java    @H_404_5@
/**
 * 设置BitmapShader
 */
private void setBitmapShader() {
    Drawable drawable = getDrawable();
    if (null == drawable) {
        return;
    }
    Bitmap bitmap = drawabletoBitmap(drawable);
    // 将bitmap作为着色器来创建一个BitmapShader
    mBitmapShader = new BitmapShader(bitmap,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);

}
@H_404_5@ @H_404_5@
项目:controllerformote-android    文件ColorPicker.java    @H_404_5@
private Bitmap createColorWheelBitmap(int width,colorWheelPaint);

        return bitmap;

    }
@H_404_5@ @H_404_5@
项目:PerfectShow    文件ColorPickerCircle.java    @H_404_5@
@SuppressLint("DrawAllocation")
@Override
protected void onDraw(Canvas canvas)
{
    super.onDraw(canvas);
    int width  = getMeasuredWidth();
    int height = getMeasuredHeight();

    int new_color = Color.HSVToColor(hsv);
    if(color != new_color)
    {
        Shader shader_x = new LinearGradient(0.0F,0.0F,width,Color.WHITE,new_color,TileMode.CLAMP);

        ComposeShader shader = new ComposeShader(shader_y,shader_x,PorterDuff.Mode.MULTIPLY);
        paint.setShader(shader);

        color = new_color;
    }
    canvas.drawRect(0.0F,paint);
}
@H_404_5@ @H_404_5@
项目:px-android    文件ColorPicker.java    @H_404_5@
private Bitmap createColorWheelBitmap(int width,Config.ARGB_8888);

        int colorCount = 12;
        int colorAngleStep = 360 / 12;
        int colors[] = new int[colorCount + 1];
        float hsv[] = new float[]{0f,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,colorWheelPaint);

        return bitmap;

    }
@H_404_5@ @H_404_5@
项目:Upkeep    文件AmbilWarnaKotak.java    @H_404_5@
@Override
protected void onDraw(final Canvas canvas) {
    super.onDraw(canvas);

    if (this.paint == null) {
        this.paint = new Paint();
        this.luar = new LinearGradient(0.f,0.f,this.ukuranUiPx,0xffffffff,0xff000000,TileMode.CLAMP);
    }

    this.tmp00[1] = this.tmp00[2] = 1.f;
    this.tmp00[0] = this.hue;
    int rgb = Color.HSVToColor(this.tmp00);

    this.dalam = new LinearGradient(0.f,rgb,TileMode.CLAMP);
    ComposeShader shader = new ComposeShader(this.luar,this.dalam,PorterDuff.Mode.MULTIPLY);

    this.paint.setShader(shader);

    canvas.drawRect(0.f,this.paint);
}
@H_404_5@ @H_404_5@
项目:IMKBaseFrameworkLibrary    文件Reflect3DImage.java    @H_404_5@
/**
 * 全倒影
 * 
 * @param originalImage
 * @return
 */
public static Bitmap createReflectedImage(Bitmap originalImage,int imageHeight) {
    int width = originalImage.getWidth();
    int height = originalImage.getHeight();
    Matrix matrix = new Matrix();
    matrix.preScale(1,-1);
    Bitmap reflectionImage = Bitmap.createBitmap(originalImage,height - imageHeight,imageHeight,matrix,false);
    Bitmap bitmapWithReflection = Bitmap.createBitmap(width,(height + imageHeight),Config.ARGB_8888);
    Canvas canvas = new Canvas(bitmapWithReflection);
    Paint defaultpPaint = new Paint();
    canvas.drawBitmap(originalImage,defaultpPaint);
    canvas.drawBitmap(reflectionImage,defaultpPaint);
    Paint paint = new Paint();
    LinearGradient shader = new LinearGradient(0,originalImage.getHeight(),bitmapWithReflection.getHeight(),0x70ffffff,0x00ffffff,TileMode.MIRROR);
    paint.setShader(shader);
    paint.setXfermode(new PorterDuffXfermode(Mode.DST_IN));
    canvas.drawRect(0,paint);
    reflectionImage.recycle();
    return bitmapWithReflection;
}
@H_404_5@ @H_404_5@
项目:BLE_ToolBox_Android    文件ColorPicker.java    @H_404_5@
private Bitmap createColorWheelBitmap(int width,colorWheelPaint);

        return bitmap;

    }
@H_404_5@ @H_404_5@
项目:Evisa    文件CircleView.java    @H_404_5@
/**
 * 初始化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);
    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);
}
@H_404_5@ @H_404_5@
项目:MyViews    文件LinearGradientView.java    @H_404_5@
public LinearGradientView(Context context) {
    super(context);
    // ��һ�ڶ���������ʾ������㣬���������ڶԽǵ�����λ�ã��������ĸ�������ʾ�����յ㣻�����������ʾ������ɫ��
    // ��������������Ϊ�գ���ʾ����ֵΪ0-1 new float[] {0.25f,0.75f,1 }  ���Ϊ�գ���ɫ���ȷֲ������ݶ��ߡ�
    mLinearGradient11 = new LinearGradient(0,200,new int[] { Color.RED,Color.GREEN,Color.BLUE,Color.BLACK },null,TileMode.CLAMP);
    mLinearGradient12 = new LinearGradient(0,300,new float[] { 0,0.1f,0.5f },TileMode.CLAMP);
    mLinearGradient13 = new LinearGradient(0,400,Color.BLUE },TileMode.CLAMP);

    mLinearGradient21 = new LinearGradient(0,320,320 + 200,TileMode.MIRROR);
    mLinearGradient22 = new LinearGradient(0,320 + 100,TileMode.MIRROR);
    mLinearGradient23 = new LinearGradient(0,TileMode.MIRROR);

    mLinearGradient31 = new LinearGradient(0,640,640 + 200,TileMode.REPEAT);
    mLinearGradient32 = new LinearGradient(0,640 + 100,TileMode.REPEAT);
    mLinearGradient33 = new LinearGradient(0,TileMode.REPEAT);
    mPaint = new Paint();
}
@H_404_5@ @H_404_5@
项目:FingerColoring-Android    文件ColorPicker.java    @H_404_5@
private Bitmap createColorWheelBitmap(int width,colorWheelPaint);

        return bitmap;

    }
@H_404_5@ @H_404_5@
项目:UofT-TiMetable    文件ColorPicker.java    @H_404_5@
private Bitmap createColorWheelBitmap(int width,colorWheelPaint);

        return bitmap;

    }
@H_404_5@ @H_404_5@
项目:Tower-develop    文件AttitudeIndicator.java    @H_404_5@
@Override
protected void onSizeChanged(int w,int h,int oldw,int oldh) {
    super.onSizeChanged(w,h,oldw,oldh);
    halfheight = h / 2f;
    halfWidth = w / 2f;

    radiusExternal = Math.min(halfheight,halfWidth) / YAW_ARROW_SIZE;
    radiusInternal = radiusExternal * INTERNAL_RADIUS;

    internalBounds = new RectF(-radiusInternal,-radiusInternal,radiusInternal,radiusInternal);

    skyPaint.setShader(new LinearGradient(0,Color
            .parseColor("#0082d6"),Color.parseColor("#2cb1e1"),TileMode.CLAMP));

    groundPaint.setShader(new LinearGradient(0,Color
            .parseColor("#4bbba1"),Color.parseColor("#008f63"),TileMode.CLAMP));

}
@H_404_5@ @H_404_5@
项目:ToastUI    文件ColorPickerView.java    @H_404_5@
private void drawSatValPanel(Canvas canvas) {
    RectF rect = this.mSatValRect;
    this.mBorderPaint.setColor(this.mBorderColor);
    canvas.drawRect(this.mDrawingRect.left,this.mDrawingRect.top,BORDER_WIDTH_PX + rect.right,BORDER_WIDTH_PX + rect.bottom,this.mBorderPaint);
    if (this.mValShader == null) {
        this.mValShader = new LinearGradient(rect.left,rect.top,rect.left,rect.bottom,-1,ViewCompat.MEASURED_STATE_MASK,TileMode.CLAMP);
    }
    this.mSatShader = new LinearGradient(rect.left,rect.right,Color.HSVToColor(new float[]{this.mHue,BORDER_WIDTH_PX,BORDER_WIDTH_PX}),TileMode.CLAMP);
    this.mSatValPaint.setShader(new ComposeShader(this.mValShader,this.mSatShader,Mode.MULTIPLY));
    canvas.drawRect(rect,this.mSatValPaint);
    Point p = satValToPoint(this.mSat,this.mVal);
    this.mSatValTrackerPaint.setColor(ViewCompat.MEASURED_STATE_MASK);
    canvas.drawCircle((float) p.x,(float) p.y,this.PALETTE_CIRCLE_TRACKER_RADIUS - (BORDER_WIDTH_PX * this.mDensity),this.mSatValTrackerPaint);
    this.mSatValTrackerPaint.setColor(0xffdddddd);
    canvas.drawCircle((float) p.x,this.PALETTE_CIRCLE_TRACKER_RADIUS,this.mSatValTrackerPaint);
}
@H_404_5@ @H_404_5@
项目:ToastUI    文件ColorPickerView.java    @H_404_5@
private void drawHuePanel(Canvas canvas) {
    RectF rect = this.mHueRect;
    this.mBorderPaint.setColor(this.mBorderColor);
    canvas.drawRect(rect.left - BORDER_WIDTH_PX,rect.top - BORDER_WIDTH_PX,rect.right + BORDER_WIDTH_PX,this.mBorderPaint);
    if (this.mHueShader == null) {
        this.mHueShader = new LinearGradient(rect.left,buildHueColorArray(),TileMode.CLAMP);
        this.mHuePaint.setShader(this.mHueShader);
    }
    canvas.drawRect(rect,this.mHuePaint);
    float rectHeight = (4.0f * this.mDensity) / 2.0f;
    Point p = huetoPoint(this.mHue);
    RectF r = new RectF();
    r.left = rect.left - this.RECTANGLE_TRACKER_OFFSET;
    r.right = rect.right + this.RECTANGLE_TRACKER_OFFSET;
    r.top = ((float) p.y) - rectHeight;
    r.bottom = ((float) p.y) + rectHeight;
    canvas.drawRoundRect(r,2.0f,this.mHueTrackerPaint);
}
@H_404_5@ @H_404_5@
项目:ToastUI    文件ColorPickerView.java    @H_404_5@
private void drawAlphaPanel(Canvas canvas) {
    if (this.mShowAlphaPanel && this.mAlphaRect != null && this.mAlphaPattern != null) {
        RectF rect = this.mAlphaRect;
        this.mBorderPaint.setColor(this.mBorderColor);
        canvas.drawRect(rect.left - BORDER_WIDTH_PX,this.mBorderPaint);
        this.mAlphaPattern.draw(canvas);
        float[] hsv = new float[]{this.mHue,this.mSat,this.mVal};
        this.mAlphaShader = new LinearGradient(rect.left,Color.HSVToColor(hsv),Color.HSVToColor(0,hsv),TileMode.CLAMP);
        this.mAlphaPaint.setShader(this.mAlphaShader);
        canvas.drawRect(rect,this.mAlphaPaint);
        if (!(this.mAlphaSliderText == null || this.mAlphaSliderText == "")) {
            canvas.drawText(this.mAlphaSliderText,rect.centerX(),rect.centerY() + (4.0f * this.mDensity),this.mAlphaTextPaint);
        }
        float rectWidth = (4.0f * this.mDensity) / 2.0f;
        Point p = alphaToPoint(this.mAlpha);
        RectF r = new RectF();
        r.left = ((float) p.x) - rectWidth;
        r.right = ((float) p.x) + rectWidth;
        r.top = rect.top - this.RECTANGLE_TRACKER_OFFSET;
        r.bottom = rect.bottom + this.RECTANGLE_TRACKER_OFFSET;
        canvas.drawRoundRect(r,this.mHueTrackerPaint);
    }
}
@H_404_5@ @H_404_5@
项目:j2se_for_android    文件ImageUtil.java    @H_404_5@
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,height/2,(height + height/2),Config.ARGB_8888);
    Canvas canvas = new Canvas(bitmapWithReflection);
    canvas.drawBitmap(bitmap,null);
    Paint deafalutPaint = new Paint();
    canvas.drawRect(0,height + reflectionGap,deafalutPaint);
    canvas.drawBitmap(reflectionImage,null);
    Paint paint = new Paint();
    LinearGradient shader = new LinearGradient(0,bitmap.getHeight(),bitmapWithReflection.getHeight()
            + reflectionGap,TileMode.CLAMP);
    paint.setShader(shader);
    paint.setXfermode(new PorterDuffXfermode(Mode.DST_IN));

    canvas.drawRect(0,paint);
    return bitmapWithReflection;
}
@H_404_5@ @H_404_5@
项目:material-components-android    文件CircularRevealHelper.java    @H_404_5@
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));
    }

    buildingCircularRevealCache = false;
    hasCircularRevealCache = true;
  }
}
@H_404_5@ @H_404_5@
项目:Codebase    文件BitmapUtil.java    @H_404_5@
/**
 * 获得带倒影的图片方法
 *
 * @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,false);
    Bitmap bitmapWithReflection = HSBitmapUtil.createBitmap(width,(height + height / 2),bitmapWithReflection.getHeight() + reflectionGap,TileMode.CLAMP);
    paint.setShader(shader);
    paint.setXfermode(new PorterDuffXfermode(Mode.DST_IN));
    canvas.drawRect(0,paint);
    return bitmapWithReflection;
}
@H_404_5@ @H_404_5@
项目:Codebase    文件CircleImageView.java    @H_404_5@
/**
 * 初始化BitmapShader
 */
private void setUpShader() {
    Drawable drawable = getDrawable();
    if (drawable == null) {
        return;
    }

    Bitmap bmp = drawabletoBitamp(drawable);
    // 将bmp作为着色器,就是在指定区域内绘制bmp
    mBitmapShader = new BitmapShader(bmp,TileMode.CLAMP);
    float scale = 1.0f;
    // 拿到bitmap宽或高的小值
    int bSize = Math.min(bmp.getWidth(),bmp.getHeight());
    scale = mWidth * 1.0f / bSize;

    // shader的变换矩阵,我们这里主要用于放大或者缩小
    mMatrix.setScale(scale,scale);
    // 设置变换矩阵
    mBitmapShader.setLocalMatrix(mMatrix);
    // 设置shader
    mBitmapPaint.setShader(mBitmapShader);
}
@H_404_5@ @H_404_5@
项目:AyoSunny    文件ColorPicker.java    @H_404_5@
private Bitmap createColorWheelBitmap(int width,colorWheelPaint);

        return bitmap;

    }
@H_404_5@ @H_404_5@
项目:info_demo    文件BitmapUtils.java    @H_404_5@
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,false);

    Bitmap bitmapWithReflection = Bitmap.createBitmap(width,Config.ARGB_8888);

    Canvas canvas = new Canvas(bitmapWithReflection);
    canvas.drawBitmap(bitmap,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,paint);
    return bitmapWithReflection;
}
@H_404_5@ @H_404_5@
项目:TvLauncher    文件ReflectView.java    @H_404_5@
/**
 * Set the bitmap reflection
 *
 * @param bitmap
 * @return
 */
public static Bitmap createReflectedImage(Bitmap bitmap,int reflectHeight) {
    int width = bitmap.getWidth();
    int height = bitmap.getHeight();
    if (height <= reflectHeight) {
        return null;
    }
    Matrix matrix = new Matrix();
    matrix.preScale(1,height
            - reflectHeight,reflectHeight,true);
    Bitmap bitmapWithReflection = Bitmap.createBitmap(width,Config.ARGB_8888);
    Canvas canvas = new Canvas(bitmapWithReflection);
    canvas.drawBitmap(reflectionImage,null);
    LinearGradient shader = new LinearGradient(0,0x80ffffff,TileMode.CLAMP);
    Paint paint = new Paint();
    paint.setShader(shader);
    paint.setXfermode(new PorterDuffXfermode(Mode.DST_IN));
    canvas.drawRect(0,paint);
    return bitmapWithReflection;
}
@H_404_5@ @H_404_5@
项目:droidplanner-master    文件AttitudeIndicator.java    @H_404_5@
@Override
protected void onSizeChanged(int w,TileMode.CLAMP));

}
@H_404_5@ @H_404_5@
项目:umeng_community_android    文件RoundImageView.java    @H_404_5@
/**
 * 初始化BitmapShader
 */
private void setUpShader() {
    Drawable drawable = getDrawable();
    Bitmap bmp = drawabletoBitamp(drawable);
    if (drawable == null || bmp == null) {
        return;
    }

    // 将bmp作为着色器,就是在指定区域内绘制bmp
    mBitmapShader = new BitmapShader(bmp,scale);
    // 设置变换矩阵
    mBitmapShader.setLocalMatrix(mMatrix);
    // 设置shader
    mBitmapPaint.setShader(mBitmapShader);
}
@H_404_5@ @H_404_5@
项目:Domo-Android    文件ColorPicker.java    @H_404_5@
private Bitmap createColorWheelBitmap(int width,colorWheelPaint);

        return bitmap;

    }
@H_404_5@ @H_404_5@
项目:Domo-Android    文件multicolorPicker.java    @H_404_5@
private Bitmap createColorWheelBitmap(int width,colorWheelPaint);

        return bitmap;

    }
@H_404_5@ @H_404_5@
项目:WeatherStation    文件GaugeView.java    @H_404_5@
/**
 * Set default outer rim paint
 *
 * @return paint
 *          Paint for outer rim
 */
private Paint getDefaultOuterRimPaint() {
    /** Linear gradient to create the 3D effect */
    final LinearGradient verticalGradient = new LinearGradient(mOuterRimRect.left,mOuterRimRect.top,mOuterRimRect.left,mOuterRimRect.bottom,Color.rgb(255,255,255),Color.rgb(84,90,100),TileMode.REPEAT);

    /** Bitmap for outer rim */
    final Bitmap bitmap = BitmapFactory.decodeResource(getResources(),R.drawable.darkwood);
    /** Bitmap shader for the Metallic style */
    final BitmapShader outerRimTile = new BitmapShader(bitmap,TileMode.REPEAT,TileMode.REPEAT);
    /** Matrix for outer rim */
    final Matrix matrix = new Matrix();
    matrix.setScale(1.0f / bitmap.getWidth(),1.0f / bitmap.getHeight());
    outerRimTile.setLocalMatrix(matrix);

    /** Paint for outer rim */
    final Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);
    paint.setShader(new ComposeShader(verticalGradient,outerRimTile,PorterDuff.Mode.MULTIPLY));
    paint.setFilterBitmap(true);
    return paint;
}
@H_404_5@ @H_404_5@
项目:WeatherStation    文件GaugeView.java    @H_404_5@
/**
 * Set default inner rim paint
 *
 * @return paint
 *          Paint for inner rim
 */
private Paint getDefaultInnerRimPaint() {
    /** Linear gradient to create the 3D effect */
    final LinearGradient verticalGradient = new LinearGradient(mOuterRimRect.left,TileMode.REPEAT);

    /** Bitmap for inner rim */
    final Bitmap bitmap = BitmapFactory.decodeResource(getResources(),R.drawable.darkerwood);
    /** Bitmap shader for the Metallic style */
    final BitmapShader innerRimTile = new BitmapShader(bitmap,TileMode.REPEAT);
    /** Matrix for inner rim */
    final Matrix matrix = new Matrix();
    matrix.setScale(1.0f / bitmap.getWidth(),1.0f / bitmap.getHeight());
    innerRimTile.setLocalMatrix(matrix);

    /** Paint for outer rim */
    final Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);
    paint.setShader(new ComposeShader(verticalGradient,innerRimTile,PorterDuff.Mode.MULTIPLY));
    paint.setFilterBitmap(true);
    return paint;
}
@H_404_5@ @H_404_5@

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。