首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >旋转图像,但图像颜色较暗且图像变形

旋转图像,但图像颜色较暗且图像变形
EN

Stack Overflow用户
提问于 2011-08-12 16:16:25
回答 2查看 292关注 0票数 0

我想旋转图像更多的时间,但我不能在onDraw方法中做到这一点,我的代码是:

代码语言:javascript
运行
复制
           options = new BitmapFactory.Options();
    options.inScaled = false;
    options.inJustDecodeBounds = false;
    options.inDither = false;

    options.inScaled = false;
    options.inPreferredConfig = Bitmap.Config.ARGB_8888;

      public void setAddBmpImage(int rotate) {

    byte[] by = getBitmapByte(rotatedBitmap);
    Bitmap source = BitmapFactory.decodeByteArray(by, 0, by.length, options);

     Bitmap bmpSephia = Bitmap.createBitmap(rotatedBitmap.getWidth(),   rotatedBitmap.getHeight(), Bitmap.Config.ARGB_8888);
     Canvas canvas = new Canvas(bmpSephia);
     canvas.rotate(rotate);
     canvas.drawBitmap(source, 0, 0, null);
     rotatedBitmap= bmpSephia;
     imageStartX = (screenWidth / 2 - rotatedBitmap.getWidth() / 2);
        imageStartY = (screenHeight / 2 - rotatedBitmap.getHeight() / 2);
        invalidate();

}

通过图像旋转得很好,但是图像是变形的,很难看,你能告诉我为什么吗,并给我一个好的方法,谢谢

EN

回答 2

Stack Overflow用户

发布于 2011-08-12 17:31:13

尝试使用setAntiAlias(true)

代码语言:javascript
运行
复制
Canvas canvas = new Canvas(bmpSephia);
canvas.rotate(rotate);
Paint paint = new Paint();
paint.setAntiAlias(true);
canvas.drawBitmap(source, 0, 0, paint);

代码语言:javascript
运行
复制
BitmapDrawable bmdraw = new BitmapDrawable(bmpSephia);
bmdraw.setAntiAlias(true);
Canvas canvas = new Canvas(bmdraw.getBitmap());
canvas.rotate(rotate);
票数 1
EN

Stack Overflow用户

发布于 2011-08-13 10:59:03

我已经使用了@user7777方法,并修改了Paint paint = new Paint();paint.setAntiAlias(真);然后旋转图像的中心旋转,图像变形也发生了很小的变化,我看着rotate image in around its center point in canvas

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

https://stackoverflow.com/questions/7037321

复制
相关文章

相似问题

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