canvas drawBitmap()给出不同的输出

时间:2017-12-18 11:25:12

标签: java android image-processing android-image android-bitmap

在图片和代码下面看,如果在不同的设备中提供不同的输出。

bitmaptemplate = BitmapFactory.decodeResource(getResources(),R.drawable.fb_template);

    android.graphics.Bitmap.Config bitmapConfig =   bitmaptemplate.getConfig();
    // set default bitmap config if none
    if(bitmapConfig == null) {
        bitmapConfig = android.graphics.Bitmap.Config.ARGB_8888;
    }

    bitmaptemplate = bitmaptemplate.copy(bitmapConfig, true);

    Canvas canvas = new Canvas(bitmaptemplate);

    Bitmap bitmaplogo=BitmapFactory.decodeResource(getResources(),R.drawable.temp);

    android.graphics.Bitmap.Config bitmapConfi =  bitmaplogo.getConfig();

    if(bitmapConfi == null) {
        bitmapConfig = android.graphics.Bitmap.Config.ARGB_8888;
     }

    bitmaplogo = bitmaplogo.copy(bitmapConfig, true);

    Canvas canlogo=new Canvas(bitmaplogo);

    canlogo.drawColor(Color.BLACK);

    Rect dstRectForRender=new Rect(10,250,700,700);
    canvas.drawBitmap (bitmaplogo , null, dstRectForRender, null );



    Paint paint = new Paint();
    paint.setColor(Color.BLACK); 
   int spSize = 45;
    float scaledSizeInPixels = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP,
            spSize, getResources().getDisplayMetrics());
    paint.setTextSize(scaledSizeInPixels);
    paint.setFakeBoldText(true);
    paint.setColor(Color.BLACK);
    canvas.drawText("PRATIK N SANYAJA", 20, 900+100, paint);

enter image description here

0 个答案:

没有答案