首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >具有缩放功能的android画布图的图像分辨率

问具有缩放功能的android画布图的图像分辨率
EN

Stack Overflow用户
提问于 2015-04-08 10:22:44
回答 1查看 89关注 0票数 0

在我的android应用程序中,我从Url下载一张图像,然后根据屏幕大小进行缩放,然后在画布上绘制,如下所示。这幅帆布可以放大到1.5倍。

( 1)假设我支持手机和平板电脑,这些图像的最佳分辨率是什么?

代码语言:javascript
复制
 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块,并对图像进行轮廓化。在未缩放和缩放的图像中,轮廓并不那么尖锐。如何提高生产线的平整度和质量。

代码语言:javascript
复制
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);
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2015-04-12 01:54:52

在画布上绘制位图之前设置这些标志。

[中英文摘要] paint.setFlags(Paint.FILTER_BITMAP_FLAG x Paint.ANTI_ALIAS_FLAG);

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/29512009

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档