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


Java Paint.setARGB方法代碼示例

本文整理匯總了Java中android.graphics.Paint.setARGB方法的典型用法代碼示例。如果您正苦於以下問題:Java Paint.setARGB方法的具體用法?Java Paint.setARGB怎麽用?Java Paint.setARGB使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.graphics.Paint的用法示例。


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

示例1: MjpegViewThread

import android.graphics.Paint; //導入方法依賴的package包/類
public MjpegViewThread(SurfaceHolder surfaceHolder, View view){
    mSurfaceHolder = surfaceHolder;
    mRun = false;
    mCallback = null;
    dispWidth = view.getWidth();
    dispHeight = view.getHeight();
    prevdispWidth = dispWidth;
    prevdispHeight = dispHeight;
    destRect = new Rect(0,0,dispWidth,dispHeight);
    destSrc = null;
    displayMode = 1; // Default : SIZE_FIT_MODE
    prevdisplayMode = 1;

    bgColor = new Paint();
    bgColor.setStyle(Paint.Style.FILL);
    bgColor.setARGB(255, 0, 0, 0);
}
 
開發者ID:dydwo92,項目名稱:Android-Simple-MjpegViewer,代碼行數:18,代碼來源:MjpegViewThread.java

示例2: drawTextAndBgColorOnBitmap

import android.graphics.Paint; //導入方法依賴的package包/類
private Bitmap drawTextAndBgColorOnBitmap(Bitmap bitmap, FallbackGlideParams params) {
    Canvas canvas = new Canvas(bitmap);

    int rgb = calcUnknownContactColor(params.address);
    bitmap.eraseColor(rgb);

    String letter = calcUnknownContactLetter(params.address);

    Paint paint = new Paint();
    paint.setAntiAlias(true);
    paint.setStyle(Style.FILL);
    paint.setARGB(255, 255, 255, 255);
    paint.setTextSize(mPictureSizeInPx * 3 / 4); // just scale this down a bit
    Rect rect = new Rect();
    paint.getTextBounds(letter, 0, 1, rect);
    float width = paint.measureText(letter);
    canvas.drawText(letter,
            (mPictureSizeInPx / 2f) - (width / 2f),
            (mPictureSizeInPx / 2f) + (rect.height() / 2f), paint);

    return bitmap;
}
 
開發者ID:philipwhiuk,項目名稱:q-mail,代碼行數:23,代碼來源:ContactPictureLoader.java

示例3: setupFillPaint

import android.graphics.Paint; //導入方法依賴的package包/類
/**
 * Sets up {@link #mPaint} according to the props set on a shadow view. Returns {@code true}
 * if the fill should be drawn, {@code false} if not.
 */
protected boolean setupFillPaint(Paint paint, float opacity) {
  if (mFillColor != null && mFillColor.length > 0) {
    paint.reset();
    paint.setFlags(Paint.ANTI_ALIAS_FLAG);
    paint.setStyle(Paint.Style.FILL);
    int colorType = (int) mFillColor[0];
    switch (colorType) {
      case 0:
        paint.setARGB(
            (int) (mFillColor.length > 4 ? mFillColor[4] * opacity * 255 : opacity * 255),
            (int) (mFillColor[1] * 255),
            (int) (mFillColor[2] * 255),
            (int) (mFillColor[3] * 255));
        break;
      default:
        // TODO(6352048): Support gradients etc.
        FLog.w(ReactConstants.TAG, "ART: Color type " + colorType + " not supported!");
    }
    return true;
  }
  return false;
}
 
開發者ID:qq565999484,項目名稱:RNLearn_Project1,代碼行數:27,代碼來源:ARTShapeShadowNode.java

示例4: drawCircularImageViewBorder

import android.graphics.Paint; //導入方法依賴的package包/類
private void drawCircularImageViewBorder(Canvas canvas){
    Paint paint = new Paint();

    paint.setStyle(Paint.Style.STROKE);

    // set ARGB.
    final int RED = Color.red(borderColor);
    final int GREEN = Color.green(borderColor);
    final int BLUE = Color.blue(borderColor);
    final int ALPHA = Color.alpha(borderColor);

    paint.setStrokeWidth(borderSize);

    paint.setARGB(ALPHA, RED, GREEN, BLUE);

    canvas.drawCircle(radius + getXCenter(), radius + getYCenter(), radius, paint);
}
 
開發者ID:MohamedNagyMostafa,項目名稱:IM_Here,代碼行數:18,代碼來源:CircleImageView.java

示例5: drawCircle

import android.graphics.Paint; //導入方法依賴的package包/類
private Bitmap drawCircle(Bitmap bm) {
    int width = bm.getWidth();
    int height = bm.getHeight();
    int left = 0;
    int top = 0;
    int right = width;
    int bottom = height;
    int roundX = height / 2;
    if (width > height) {
        left = (width - height) / 2;
        top = 0;
        right = left + height;
        bottom = height;
    } else {
        left = 0;
        top = (height - width) / 2;
        right = width;
        bottom = top + width;
        roundX = width / 2;
    }
    Bitmap bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
    Canvas canvas = new Canvas(bitmap);

    Rect rect = new Rect(left, top, right, bottom);
    RectF rectF = new RectF(rect);

    Paint paint = new Paint();
    paint.setAntiAlias(true);
    paint.setARGB(0, 0, 0, 0);
    paint.setColor(Color.GRAY);
    canvas.drawRoundRect(rectF, roundX, roundX, paint);
    paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_IN));
    canvas.drawBitmap(bm,rect,rect,paint);
    bm.recycle();
    return bitmap;
}
 
開發者ID:penghuanliang,項目名稱:Rxjava2.0Demo,代碼行數:37,代碼來源:DoActivity.java

示例6: init

import android.graphics.Paint; //導入方法依賴的package包/類
private void init(Context context) {
    if (!this.isInEditMode()) {

        splats[0] = BitmapFactory.decodeResource(getResources(), R.drawable.splat1);
        splats[1] = BitmapFactory.decodeResource(getResources(), R.drawable.splat2);
        splats[2] = BitmapFactory.decodeResource(getResources(), R.drawable.splat2);
        anchor[0] = BitmapFactory.decodeResource(getResources(), R.drawable.anchor_sm);
        axes[0] = BitmapFactory.decodeResource(getResources(), R.drawable.axe2);
        bgs[0] = BitmapFactory.decodeResource(getResources(), R.drawable.sea);
        fgtops[0] = BitmapFactory.decodeResource(getResources(), R.drawable.sail);
        fgbottoms[0] = BitmapFactory.decodeResource(getResources(), R.drawable.shipside2);

        final SurfaceHolder holder = getHolder();
        holder.addCallback(this);
        TypedArray fish = getResources().obtainTypedArray(R.array.fish);
        int[] values = getResources().getIntArray(R.array.points);
        totalValue = 0;
        for (int i = 0; i < fish.length(); i++) {
            FlyingItem item = new FlyingItem(BitmapFactory.decodeResource(getResources(), fish.getResourceId(i, 0)));
            item.setValue(values[i]);
            availableItems.add(item);
            totalValue += (100 - values[i]);
        }
        fish.recycle();

        this.setOnTouchListener(this);
        mLinePaint = new Paint();
        mLinePaint.setARGB(255, 255, 64, 64);
        mLinePaint.setStrokeWidth(5);
        mBGPaint = new Paint();
        mBGPaint.setARGB(255, 127, 127, 200);

        mTextPaint = new Paint();
        mTextPaint.setColor(Color.BLACK);
        mTextPaint.setShadowLayer(8,8,8,Color.WHITE);
        mTextPaint.setTextSize(80);

    }
}
 
開發者ID:quaap,項目名稱:SeafoodBerserker,代碼行數:40,代碼來源:MainFishView.java

示例7: createPaint

import android.graphics.Paint; //導入方法依賴的package包/類
/**
 * This method creates the instance of Paint.
 * In addition, this method sets styles for Paint.
 *
 * @return paint This is returned as the instance of Paint
 */
private Paint createPaint() {
  Paint paint = new Paint();

  paint.setAntiAlias(true);
  paint.setStyle(this.paintStyle);
  paint.setStrokeWidth(this.paintStrokeWidth);
  paint.setStrokeCap(this.lineCap);
  paint.setStrokeJoin(Paint.Join.MITER);  // fixed

  // for Text
  if (this.mode == Mode.TEXT) {
    paint.setTypeface(this.fontFamily);
    paint.setTextSize(this.fontSize);
    paint.setTextAlign(this.textAlign);
    paint.setStrokeWidth(0F);
  }

  if (this.mode == Mode.ERASER) {
    // Eraser
    paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.CLEAR));
    paint.setARGB(0, 0, 0, 0);

    // paint.setColor(this.baseColor);
    // paint.setShadowLayer(this.blur, 0F, 0F, this.baseColor);
  } else {
    // Otherwise
    paint.setColor(this.paintStrokeColor);
    paint.setShadowLayer(this.blur, 0F, 0F, this.paintStrokeColor);
    paint.setAlpha(this.opacity);
  }

  return paint;
}
 
開發者ID:XecureIT,項目名稱:PeSanKita-android,代碼行數:40,代碼來源:CanvasView.java

示例8: init

import android.graphics.Paint; //導入方法依賴的package包/類
private void init() {

        colorPointerPaint = new Paint();
        colorPointerPaint.setStyle(Style.STROKE);
        colorPointerPaint.setStrokeWidth(2f);
        colorPointerPaint.setARGB(128, 0, 0, 0);

        valuePointerPaint = new Paint();
        valuePointerPaint.setStyle(Style.STROKE);
        valuePointerPaint.setStrokeWidth(2f);

        valuePointerArrowPaint = new Paint();

        colorWheelPaint = new Paint();
        colorWheelPaint.setAntiAlias(true);
        colorWheelPaint.setDither(true);

        valueSliderPaint = new Paint();
        valueSliderPaint.setAntiAlias(true);
        valueSliderPaint.setDither(true);

        colorViewPaint = new Paint();
        colorViewPaint.setAntiAlias(true);

        colorViewPath = new Path();
        valueSliderPath = new Path();
        arrowPointerPath = new Path();

        outerWheelRect = new RectF();
        innerWheelRect = new RectF();

        colorPointerCoords = new RectF();

    }
 
開發者ID:MLNO,項目名稱:airgram,代碼行數:35,代碼來源:ColorPicker.java

示例9: Draw

import android.graphics.Paint; //導入方法依賴的package包/類
public void Draw(
        @NonNull Canvas canvas,
        @NonNull Paint paint) {
    canvas.drawRGB(20, 20, 20);
    paint.setARGB(255, 255, 255, 255);

    drawBall(canvas, paint);
    drawBoards(canvas, paint);
    drawPoints(canvas, paint);
    drawInfo(canvas, paint);
}
 
開發者ID:GuepardoApps,項目名稱:LucaHome-MediaServer,代碼行數:12,代碼來源:GameState.java

示例10: createThumbnailBitmap

import android.graphics.Paint; //導入方法依賴的package包/類
public Bitmap createThumbnailBitmap(AsciiConverter.Result result) {
    int width = outputImageWidth / 4;
    int height = outputImageHeight / 4;
    Bitmap bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
    Canvas canvas = new Canvas(bitmap);
    Paint paint = new Paint();
    paint.setStyle(Paint.Style.FILL);
    paint.setARGB(255, 255, 255, 255);

    canvas.drawARGB(255, 0, 0, 0);
    if (result != null) {
        for (int r = 0; r < result.rows; r += 2) {
            int ymin = height * r / result.rows;
            int ymax = height * (r + 2) / result.rows;
            for (int c = 0; c < result.columns; c += 2) {
                int xmin = width * c / result.columns;
                int xmax = width * (c + 2) / result.columns;
                float ratio = result.brightnessRatioAtRowColumn(r, c);
                paint.setColor(result.colorAtRowColumn(r, c));
                // for full color, always draw larger rectangle because colors will be darker
                if (result.getColorType() == AsciiConverter.ColorType.FULL_COLOR || ratio > 0.5) {
                    canvas.drawRect(xmin, ymin, xmax, ymax, paint);
                } else {
                    int x = (xmin + xmax) / 2 - 1;
                    int y = (ymin + ymax) / 2 - 1;
                    canvas.drawRect(x, y, x + 2, y + 2, paint);
                }
            }
        }
    }
    return bitmap;
}
 
開發者ID:tranleduy2000,項目名稱:ascii_generate,代碼行數:33,代碼來源:AsciiRenderer.java

示例11: PageView

import android.graphics.Paint; //導入方法依賴的package包/類
public PageView(Context ctx, AttributeSet atts) {
	super(ctx, atts);

	scroller = new Scroller(ctx);
	detector = new GestureDetector(ctx, this);
	scaleDetector = new ScaleGestureDetector(ctx, this);

	viewScale = 1;
	minScale = 1;
	maxScale = 2;

	linkPaint = new Paint();
	linkPaint.setARGB(32, 0, 0, 255);

	hitPaint = new Paint();
	hitPaint.setARGB(32, 255, 0, 0);

	errorPaint = new Paint();
	errorPaint.setARGB(255, 255, 80, 80);
	errorPaint.setStrokeWidth(5);
	errorPaint.setStyle(Paint.Style.STROKE);

	errorPath = new Path();
	errorPath.moveTo(-100, -100);
	errorPath.lineTo(100, 100);
	errorPath.moveTo(100, -100);
	errorPath.lineTo(-100, 100);
}
 
開發者ID:ArtifexSoftware,項目名稱:mupdf-android-viewer-mini,代碼行數:29,代碼來源:PageView.java

示例12: paintForStrength

import android.graphics.Paint; //導入方法依賴的package包/類
private static Paint paintForStrength(double strength) {
  Paint paint = new Paint();
  int r = (int)(255 * (1 - strength));
  int g = (int)(255 * strength);
  paint.setARGB(255, r, g, 0);
  paint.setStyle(Paint.Style.FILL_AND_STROKE);
  return paint;
}
 
開發者ID:padster,項目名稱:Muse-EEG-Toolkit,代碼行數:9,代碼來源:ConnectionStrengthView.java

示例13: paintForAge

import android.graphics.Paint; //導入方法依賴的package包/類
private static Paint paintForAge(double age) {
  Paint paint = new Paint();
  int r = (int)(255 * (1 - age));
  int g = (int)(255 * age);
  paint.setARGB(255, r, g, 0);
  paint.setStyle(Paint.Style.FILL_AND_STROKE);
  return paint;
}
 
開發者ID:padster,項目名稱:Muse-EEG-Toolkit,代碼行數:9,代碼來源:Plot2DView.java

示例14: drawUnderline

import android.graphics.Paint; //導入方法依賴的package包/類
private void drawUnderline(Canvas canvas) {
    if (!(text instanceof Spanned)) {
        return;
    }
    Spanned spanned = (Spanned) text;
    UnderlineSpan[] spans = spanned.getSpans(start, end, UnderlineSpan.class);
    if (spans == null || spans.length == 0) {
        return;
    }
    Paint paint = new Paint();
    paint.setAntiAlias(true);
    paint.setStyle(Paint.Style.STROKE);
    paint.setStrokeWidth(2); // TODO
    paint.setARGB(0xFF, 0, 0, 0); // TODO
    for (UnderlineSpan span : spans) {
        RectF spanRect = getRect(span);
        if (spanRect == null) {
            continue;
        }
        spanRect.offset(originX, originY);
        if (vertical) {
            float lineX = spanRect.left;
            canvas.drawLine(lineX, spanRect.top, lineX, spanRect.bottom, paint);
        } else {
            float lineY = (spanRect.bottom + originY) / 2;
            canvas.drawLine(spanRect.left, lineY, spanRect.right, lineY, paint);
        }
    }
}
 
開發者ID:geansea,項目名稱:GSLayout,代碼行數:30,代碼來源:GSLayoutLine.java

示例15: drawStrikeThrough

import android.graphics.Paint; //導入方法依賴的package包/類
private void drawStrikeThrough(Canvas canvas) {
    if (!(text instanceof Spanned)) {
        return;
    }
    Spanned spanned = (Spanned) text;
    StrikethroughSpan[] spans = spanned.getSpans(start, end, StrikethroughSpan.class);
    if (spans == null || spans.length == 0) {
        return;
    }
    Paint paint = new Paint();
    paint.setAntiAlias(true);
    paint.setStyle(Paint.Style.STROKE);
    paint.setStrokeWidth(2); // TODO
    paint.setARGB(0xFF, 0, 0, 0); // TODO
    for (StrikethroughSpan span : spans) {
        RectF spanRect = getRect(span);
        if (spanRect == null) {
            continue;
        }
        spanRect.offset(originX, originY);
        if (vertical) {
            float lineX = (spanRect.left + spanRect.right) / 2;
            canvas.drawLine(lineX, spanRect.top, lineX, spanRect.bottom, paint);
        } else {
            float lineY = (spanRect.top + spanRect.bottom + originY) / 3;
            canvas.drawLine(spanRect.left, lineY, spanRect.right, lineY, paint);
        }
    }
}
 
開發者ID:geansea,項目名稱:GSLayout,代碼行數:30,代碼來源:GSLayoutLine.java


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