zoukankan      html  css  js  c++  java
  • 拼图效果

    public static Bitmap getComponseBitmap(Bitmap src, Bitmap src2){
    if(src == null || src2 == null)
    return null;

    int width = src.getWidth();
    int height = src.getHeight();
    Bitmap newBitmap = Bitmap.createBitmap(width, height, Config.RGB_565);
    Canvas canvas = new Canvas(newBitmap);
    canvas.drawBitmap(src, 0, 0, null);

    Bitmap zoomBitmap = zoomImage(src2, 640, 360);
    canvas.drawBitmap(zoomBitmap, 200, 200, null);
    canvas.save(Canvas.ALL_SAVE_FLAG );
    canvas.restore();

    return newBitmap;
    }

    //等比缩放图片
    public static Bitmap zoomImage(Bitmap bitmap, int newWidth, int newHeight){
    int width = bitmap.getWidth();
    int height = bitmap.getHeight();
    //计算缩放比例
    float scaleW = (float)newWidth/width;
    float sacleH = (float)newHeight/height;
    //取得缩放Matrix参数
    Matrix matrix = new Matrix();
    matrix.postScale(scaleW, sacleH);
    matrix.postRotate(30);
    //得到新图片
    Bitmap newBitmap = Bitmap.createBitmap(bitmap, 0, 0, width, height, matrix, true);
    return newBitmap;
    }

  • 相关阅读:
    npm install --save
    ajax总结
    javascript学习资料
    前端工具学习资料
    php学习资料
    Bootstrap学习资料
    css学习资料
    Express搭建一个Node项目
    网站性能优化
    POJ 1862 Stripies【哈夫曼/贪心/优先队列】
  • 原文地址:https://www.cnblogs.com/clarence/p/3837417.html
Copyright © 2011-2022 走看看