use of android.graphics.PaintFlagsDrawFilter in project c-geo by just-radovan.
the class cgCompass method onAttachedToWindow.
@Override
public void onAttachedToWindow() {
compassUnderlay = BitmapFactory.decodeResource(context.getResources(), R.drawable.compass_underlay);
compassRose = BitmapFactory.decodeResource(context.getResources(), R.drawable.compass_rose);
compassArrow = BitmapFactory.decodeResource(context.getResources(), R.drawable.compass_arrow);
compassOverlay = BitmapFactory.decodeResource(context.getResources(), R.drawable.compass_overlay);
compassUnderlayWidth = compassUnderlay.getWidth();
compassUnderlayHeight = compassUnderlay.getWidth();
compassRoseWidth = compassRose.getWidth();
compassRoseHeight = compassRose.getWidth();
compassArrowWidth = compassArrow.getWidth();
compassArrowHeight = compassArrow.getWidth();
compassOverlayWidth = compassOverlay.getWidth();
compassOverlayHeight = compassOverlay.getWidth();
setfil = new PaintFlagsDrawFilter(0, Paint.FILTER_BITMAP_FLAG);
remfil = new PaintFlagsDrawFilter(Paint.FILTER_BITMAP_FLAG, 0);
wantStop = false;
watchdog = new changeThread(changeHandler);
watchdog.start();
}
use of android.graphics.PaintFlagsDrawFilter in project c-geo by just-radovan.
the class cgMapOverlay method drawInternal.
private void drawInternal(Canvas canvas, MapProjectionImpl projection) {
MapFactory mapFactory = settings.getMapFactory();
if (displayCircles) {
if (blockedCircle == null) {
blockedCircle = new Paint();
blockedCircle.setAntiAlias(true);
blockedCircle.setStrokeWidth(1.0f);
}
if (setfil == null)
setfil = new PaintFlagsDrawFilter(0, Paint.FILTER_BITMAP_FLAG);
if (remfil == null)
remfil = new PaintFlagsDrawFilter(Paint.FILTER_BITMAP_FLAG, 0);
canvas.setDrawFilter(setfil);
for (CacheOverlayItemImpl item : items) {
final cgCoord itemCoord = item.getCoord();
float[] result = new float[1];
Location.distanceBetween(itemCoord.latitude, itemCoord.longitude, itemCoord.latitude, itemCoord.longitude + 1, result);
final float longitudeLineDistance = result[0];
GeoPointImpl itemGeo = mapFactory.getGeoPointBase((int) (itemCoord.latitude * 1e6), (int) (itemCoord.longitude * 1e6));
GeoPointImpl leftGeo = mapFactory.getGeoPointBase((int) (itemCoord.latitude * 1e6), (int) ((itemCoord.longitude - 161 / longitudeLineDistance) * 1e6));
projection.toPixels(itemGeo, center);
projection.toPixels(leftGeo, left);
int radius = center.x - left.x;
final String type = item.getType();
if (type == null || "multi".equals(type) || "mystery".equals(type) || "virtual".equals(type)) {
blockedCircle.setColor(0x66000000);
blockedCircle.setStyle(Style.STROKE);
canvas.drawCircle(center.x, center.y, radius, blockedCircle);
} else {
blockedCircle.setColor(0x66BB0000);
blockedCircle.setStyle(Style.STROKE);
canvas.drawCircle(center.x, center.y, radius, blockedCircle);
blockedCircle.setColor(0x44BB0000);
blockedCircle.setStyle(Style.FILL);
canvas.drawCircle(center.x, center.y, radius, blockedCircle);
}
}
canvas.setDrawFilter(remfil);
}
}
use of android.graphics.PaintFlagsDrawFilter in project Lazy by l123456789jy.
the class BitmapUtil method createThumbnailBitmap.
/**
* Returns a Bitmap representing the thumbnail of the specified Bitmap. The
* size of the thumbnail is defined by the dimension
* android.R.dimen.launcher_application_icon_size.
* <p/>
* This method is not thread-safe and should be invoked on the UI thread
* only.
*
* @param bitmap The bitmap to get a thumbnail of.
* @param context The application's context.
* @return A thumbnail for the specified bitmap or the bitmap itself if the
* thumbnail could not be created.
*/
public static Bitmap createThumbnailBitmap(Bitmap bitmap, Context context) {
int sIconWidth = -1;
int sIconHeight = -1;
final Resources resources = context.getResources();
sIconWidth = sIconHeight = (int) resources.getDimension(android.R.dimen.app_icon_size);
final Paint sPaint = new Paint();
final Rect sBounds = new Rect();
final Rect sOldBounds = new Rect();
Canvas sCanvas = new Canvas();
int width = sIconWidth;
int height = sIconHeight;
sCanvas.setDrawFilter(new PaintFlagsDrawFilter(Paint.DITHER_FLAG, Paint.FILTER_BITMAP_FLAG));
final int bitmapWidth = bitmap.getWidth();
final int bitmapHeight = bitmap.getHeight();
if (width > 0 && height > 0) {
if (width < bitmapWidth || height < bitmapHeight) {
final float ratio = (float) bitmapWidth / bitmapHeight;
if (bitmapWidth > bitmapHeight) {
height = (int) (width / ratio);
} else if (bitmapHeight > bitmapWidth) {
width = (int) (height * ratio);
}
final Config c = (width == sIconWidth && height == sIconHeight) ? bitmap.getConfig() : Config.ARGB_8888;
final Bitmap thumb = Bitmap.createBitmap(sIconWidth, sIconHeight, c);
final Canvas canvas = sCanvas;
final Paint paint = sPaint;
canvas.setBitmap(thumb);
paint.setDither(false);
paint.setFilterBitmap(true);
sBounds.set((sIconWidth - width) / 2, (sIconHeight - height) / 2, width, height);
sOldBounds.set(0, 0, bitmapWidth, bitmapHeight);
canvas.drawBitmap(bitmap, sOldBounds, sBounds, paint);
return thumb;
} else if (bitmapWidth < width || bitmapHeight < height) {
final Config c = Config.ARGB_8888;
final Bitmap thumb = Bitmap.createBitmap(sIconWidth, sIconHeight, c);
final Canvas canvas = sCanvas;
final Paint paint = sPaint;
canvas.setBitmap(thumb);
paint.setDither(false);
paint.setFilterBitmap(true);
canvas.drawBitmap(bitmap, (sIconWidth - bitmapWidth) / 2, (sIconHeight - bitmapHeight) / 2, paint);
return thumb;
}
}
return bitmap;
}
use of android.graphics.PaintFlagsDrawFilter in project Android-MaterialRefreshLayout by android-cjj.
the class SunLineView method init.
private void init() {
Log.i(Tag, "init");
mLineWidth = changeDp(1);
mLineHeight = changeDp(3);
mFixLineHeight = changeDp(6);
mSunRadius = changeDp(12);
mLineColor = Color.RED;
mLineLevel = 30;
//线的配置
mLinePaint = new Paint(Paint.ANTI_ALIAS_FLAG);
mLinePaint.setColor(mLineColor);
mLinePaint.setStyle(Paint.Style.FILL_AND_STROKE);
// 设置画笔宽度
mLinePaint.setStrokeWidth(mLineWidth);
mDrawFilter = new PaintFlagsDrawFilter(0, Paint.ANTI_ALIAS_FLAG | Paint.FILTER_BITMAP_FLAG);
debugRect = new Rect();
mouthRect = new RectF();
}
use of android.graphics.PaintFlagsDrawFilter in project mobile-android by photo.
the class WheelRadio method init.
/**
* Inits the.
*
* @param context
* the context
* @param attrs
* the attrs
* @param defStyle
* the def style
*/
private void init(Context context, AttributeSet attrs, int defStyle) {
mFast = new PaintFlagsDrawFilter(Paint.FILTER_BITMAP_FLAG | Paint.DITHER_FLAG, 0);
mPaint = new Paint(Paint.FILTER_BITMAP_FLAG);
TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.WheelRadio, defStyle, 0);
mSmallTicksCount = a.getInteger(R.styleable.WheelRadio_smallTicks, 25) - 1;
mBigTicksCount = a.getInteger(R.styleable.WheelRadio_bigTicks, 5) - 1;
mValueIndicatorColor = a.getColor(R.styleable.WheelRadio_valueIndicatorColor, 0xFF00BBFF);
mSmallIndicatorColor = a.getColor(R.styleable.WheelRadio_smallIndicatorColor, 0x33FFFFFF);
mBigIndicatorColor = a.getColor(R.styleable.WheelRadio_bigIndicatorColor, 0x66FFFFFF);
a.recycle();
}
Aggregations