项目:LaunchEnr
文件:ShadowGenerator.java
private ShadowGenerator(Context context) {
mIconSize = LauncherAppState.getIDP(context).iconBitmapSize;
mCanvas = new Canvas();
mBlurPaint = new Paint(Paint.ANTI_ALIAS_FLAG | Paint.FILTER_BITMAP_FLAG);
mBlurPaint.setMaskFilter(new BlurMaskFilter(mIconSize * BLUR_FACTOR,Blur.norMAL));
mDrawPaint = new Paint(Paint.ANTI_ALIAS_FLAG | Paint.FILTER_BITMAP_FLAG);
}
项目:LaunchEnr
文件:ShadowGenerator.java
public static Bitmap createPillWithShadow(int rectColor,int width,int height) {
float shadowRadius = height * 1f / 32;
float shadowYOffset = height * 1f / 16;
int radius = height / 2;
Canvas canvas = new Canvas();
Paint blurPaint = new Paint(Paint.ANTI_ALIAS_FLAG | Paint.FILTER_BITMAP_FLAG);
blurPaint.setMaskFilter(new BlurMaskFilter(shadowRadius,Blur.norMAL));
int centerX = Math.round(width / 2 + shadowRadius);
int centerY = Math.round(radius + shadowRadius + shadowYOffset);
int center = Math.max(centerX,centerY);
int size = center * 2;
Bitmap result = Bitmap.createBitmap(size,size,Config.ARGB_8888);
canvas.setBitmap(result);
int left = center - width / 2;
int top = center - height / 2;
int right = center + width / 2;
int bottom = center + height / 2;
// Draw ambient shadow,center aligned within size
blurPaint.setAlpha(AMBIENT_SHADOW_ALPHA);
canvas.drawRoundRect(left,top,right,bottom,radius,blurPaint);
// Draw key shadow,bottom aligned within size
blurPaint.setAlpha(KEY_SHADOW_ALPHA);
canvas.drawRoundRect(left,top + shadowYOffset,bottom + shadowYOffset,blurPaint);
// Draw the circle
Paint drawPaint = new Paint(Paint.ANTI_ALIAS_FLAG | Paint.FILTER_BITMAP_FLAG);
drawPaint.setColor(rectColor);
canvas.drawRoundRect(left,drawPaint);
return result;
}
项目:buildAPKsSamples
文件:ShadowLayout.java
/**
* Called by the constructors - sets up the drawing parameters for the drop shadow.
*/
private void init() {
mShadowPaint.setColor(Color.BLACK);
mShadowPaint.setStyle(Style.FILL);
setwillNotDraw(false);
mShadowBitmap = Bitmap.createBitmap(sShadowRect.width(),sShadowRect.height(),Bitmap.Config.ARGB_8888);
Canvas c = new Canvas(mShadowBitmap);
mShadowPaint.setMaskFilter(new BlurMaskFilter(BLUR_RADIUS,Blur.norMAL));
c.translate(BLUR_RADIUS,BLUR_RADIUS);
c.drawRoundRect(sShadowRectF,sShadowRectF.width() / 40,sShadowRectF.height() / 40,mShadowPaint);
}
private void init() {
this.mPaint = new Paint();
this.mPaint.setDither(true);
this.mPaint.setAntiAlias(true);
if (this.isBlur) {
this.mPaint.setMaskFilter(new BlurMaskFilter(15.0f,Blur.soLID));
}
this.mPaint.setStyle(Style.FILL);
addViewForTip();
}
项目:FlickLauncher
文件:ShadowGenerator.java
private ShadowGenerator() {
mIconSize = LauncherAppState.getInstance().getInvariantDeviceProfile().iconBitmapSize;
mCanvas = new Canvas();
mBlurPaint = new Paint(Paint.ANTI_ALIAS_FLAG | Paint.FILTER_BITMAP_FLAG);
mBlurPaint.setMaskFilter(new BlurMaskFilter(mIconSize * BLUR_FACTOR,Blur.norMAL));
mDrawPaint = new Paint(Paint.ANTI_ALIAS_FLAG | Paint.FILTER_BITMAP_FLAG);
}
项目:SimpleUILauncher
文件:ShadowGenerator.java
private ShadowGenerator() {
mIconSize = LauncherAppState.getInstance().getInvariantDeviceProfile().iconBitmapSize;
mCanvas = new Canvas();
mBlurPaint = new Paint(Paint.ANTI_ALIAS_FLAG | Paint.FILTER_BITMAP_FLAG);
mBlurPaint.setMaskFilter(new BlurMaskFilter(mIconSize * BLUR_FACTOR,Blur.norMAL));
mDrawPaint = new Paint(Paint.ANTI_ALIAS_FLAG | Paint.FILTER_BITMAP_FLAG);
}
项目:Munin-for-Android
文件:Util.java
public static Bitmap dropShadow(Bitmap src) {
if (src == null)
return null;
try {
// Parameters
int verticalPadding = 10;
int horizontalPadding = 10;
int radius = 3;
int color = 0x44000000;
// Create result bitmap
Bitmap bmOut = Bitmap.createBitmap(src.getWidth() + horizontalPadding,src.getHeight() + verticalPadding,Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(bmOut);
canvas.drawColor(0,PorterDuff.Mode.CLEAR);
Paint ptBlur = new Paint();
ptBlur.setMaskFilter(new BlurMaskFilter(radius,Blur.OUTER));
int[] offsetXY = new int[2];
// Capture alpha into a bitmap
Bitmap bmAlpha = src.extractAlpha(ptBlur,offsetXY);
Paint ptAlphaColor = new Paint();
ptAlphaColor.setColor(color);
canvas.drawBitmap(bmAlpha,ptAlphaColor);
bmAlpha.recycle();
// Paint image source
canvas.drawBitmap(src,null);
return bmOut;
} catch (Exception ex) {
return src;
}
}
项目:kora
文件:ColorDialog.java
public TextSeekBarDrawable(Resources res,int id,boolean labelOnRight) {
mText = res.getString(id);
mProgress = res.getDrawable(android.R.drawable.progress_horizontal);
mPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
mPaint.setTypeface(Typeface.DEFAULT_BOLD);
mPaint.setTextSize(16);
mPaint.setColor(0xff000000);
mOutlinePaint = new Paint(mPaint);
mOutlinePaint.setStyle(Style.stroke);
mOutlinePaint.setstrokeWidth(3);
mOutlinePaint.setColor(0xbbffc300);
mOutlinePaint.setMaskFilter(new BlurMaskFilter(1,Blur.norMAL));
mTextWidth = mOutlinePaint.measureText(mText);
mtextxScale = labelOnRight? 1 : 0;
mAnimation = new ScrollAnimation();
}
项目:DevCamp2014
文件:ShadowLayout.java
项目:Foto
文件:ShadowLayout.java
项目:MPSolveForAndroid
文件:RootsRendererView.java
/**
* @brief Prepare the Paints for later user in the onDraw() method.
*
* Note that this method peform also some other basic initializations,such
* as computing some sizes in a device-independent way and initializing
* some String formatter.
*
* As a rule of thumb,every expensive operation that does not need to
* be performed on every onDraw() call should be called here.
*/
private void initPaints() {
axisFormat = new DecimalFormat("#.#E0");
// Compute a Device independent point size
pointSize = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,4,getResources().getdisplayMetrics());
// ...and in the same spirit get a device independent width for the
// ticks that we will draw on the axis.
tickWidth = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,3,getResources().getdisplayMetrics());
// Paint used for the X and Y axis.
axisPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
axisPaint.setColor(
getResources().getColor(R.color.rootsRendererView_axis));
axisPaint.setTextSize(TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,12,getResources().getdisplayMetrics()));
// Paint used for the points of the plot
pointsPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
pointsPaint.setColor(
getResources().getColor(R.color.rootsRendererView_points));
pointsPaint.setStyle(Style.FILL_AND_stroke);
pointsPaint.setMaskFilter(new BlurMaskFilter(2,Blur.INNER));
// Paint similar to the above,but used for points marked
// in the Approximation list.
markedPointsPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
markedPointsPaint.setColor(
getResources().getColor(R.color.rootsRendererView_MarkedPoints));
markedPointsPaint.setStyle(Style.FILL_AND_stroke);
markedPointsPaint.setMaskFilter(new BlurMaskFilter (2,Blur.INNER));
}
项目:android-couchpotato
文件:ShadowLayout.java
/**
* Called by the constructors - sets up the drawing parameters for the drop shadow.
*/
private void init() {
mShadowPaint.setColor(Color.BLACK);
mShadowPaint.setStyle(Style.FILL);
setwillNotDraw(false);
mShadowBitmap =
Bitmap.createBitmap(sShadowRect.width(),Bitmap.Config.ARGB_8888);
Canvas c = new Canvas(mShadowBitmap);
mShadowPaint.setMaskFilter(new BlurMaskFilter(BLUR_RADIUS,Blur.norMAL));
c.translate(BLUR_RADIUS,BLUR_RADIUS);
c.drawRoundRect(sShadowRectF,mShadowPaint);
}
项目:OmniSnitch
文件:BitmapFilter.java
/**
* Returns a glowed image of the provided icon. If the
* provided name is already in the cache,the cached image
* will be returned. Otherwise,the bitmap will be glowed and
* cached under the provided name
*
* @param name The name of the bitmap - if name == null dont cache
* @param src The bitmap of the icon itself
* @return Glowed bitmap
*/
public Bitmap getGlow(String name,int glowColor,Bitmap src) {
if (name != null && mGlowCache.containsKey(name)) {
return mGlowCache.get(name);
} else {
// An added margin to the initial image
int margin = 0;
int halfMargin = margin / 2;
// The glow radius
int glowRadius = 12;
// Extract the alpha from the source image
Bitmap alpha = src.extractAlpha();
// The output bitmap (with the icon + glow)
Bitmap bmp = Bitmap.createBitmap(src.getWidth() + margin,src.getHeight() + margin,Bitmap.Config.ARGB_8888);
// The canvas to paint on the image
Canvas canvas = new Canvas(bmp);
Paint paint = new Paint();
paint.setColor(glowColor);
// Outer glow
ColorFilter emphasize = new LightingColorFilter(glowColor,1);
paint.setColorFilter(emphasize);
canvas.drawBitmap(src,halfMargin,paint);
paint.setColorFilter(null);
paint.setMaskFilter(new BlurMaskFilter(glowRadius,Blur.OUTER));
canvas.drawBitmap(alpha,paint);
if(name!=null){
// Cache icon
mGlowCache.put(name,bmp);
}
return bmp;
}
}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。