在我的android应用程序中,我从Url下载一张图像,然后根据屏幕大小进行缩放,然后在画布上绘制,如下所示。这幅帆布可以放大到1.5倍。
( 1)假设我支持手机和平板电脑,这些图像的最佳分辨率是什么?
InputStream is = conn.getInputStream();
BufferedInputStream bis = new BufferedInputStream(is);
bm = BitmapFactory.decodeStream(bis);
Bitmap scaledBitmap = Bitmap.createScaledBitmap(bm,
(int) width, (int) height, true);
//width height are 0.75 of screen width height
bm.recycle();
bm = scaledBitmap;2)然后使用如下路径对象将图像分割成10块,并对图像进行轮廓化。在未缩放和缩放的图像中,轮廓并不那么尖锐。如何提高生产线的平整度和质量。
Bitmap piecePicture = Bitmap.createBitmap(100, 100,Bitmap.Config.ARGB_8888);
Canvas gfx = new Canvas(piecePicture);
// Canvas gfx = new Canvas(bm);
Paint whitePaint = new Paint(Paint.ANTI_ALIAS_FLAG);
whitePaint.setColor(Color.WHITE);
whitePaint.setStyle(Paint.Style.FILL_AND_STROKE);
whitePaint.setStrokeWidth(1);
//translatedFigure is the path object
gfx.drawPath(translatedFigure, whitePaint);
Paint paint = new Paint();
paint.setXfermode(new PorterDuffXfermode(
android.graphics.PorterDuff.Mode.SRC_IN));
gfx.drawBitmap(sourcePicture, 0,
0, paint);
Paint mPaint = new Paint(Color.RED);
mPaint.setAntiAlias(true);
mPaint.setDither(true);
mPaint.setStyle(Paint.Style.FILL_AND_STROKE);
mPaint.setStrokeJoin(Paint.Join.ROUND);
mPaint.setStrokeCap(Paint.Cap.ROUND);
EmbossMaskFilter mEmboss = new EmbossMaskFilter(new float[] { 1, 1, 1 }, 0.4f, 6, 3.5f);
//new EmbossMaskFilter(new float[] { 1, 1, 1 }, 0.4f, 6, 3.5f);
BitmapShader fillBMPshader = new BitmapShader(piecePicture, TileMode.MIRROR, TileMode.CLAMP);
mPaint.setShader(fillBMPshader);
mEmboss = new EmbossMaskFilter(new float[] { 1, 1, 1 },0.4f, 6, 3.5f);
mPaint.setMaskFilter(mEmboss);
gfx.drawBitmap(piecePicture, 0,0, mPaint );
//outline pen
Paint outlinePen = new Paint(Color.BLACK);
outlinePen.setStyle(Paint.Style.STROKE);
outlinePen
.setStrokeWidth(1);
outlinePen.setAntiAlias(true);
gfx.drawPath(translatedFigure, outlinePen);发布于 2015-04-12 01:54:52
在画布上绘制位图之前设置这些标志。
[中英文摘要] paint.setFlags(Paint.FILTER_BITMAP_FLAG x Paint.ANTI_ALIAS_FLAG);
https://stackoverflow.com/questions/29512009
复制相似问题