java创建位图时出现错误 canvas.drawBitmap(before, new Matrix(), paint);求大神解答
importandroid.app.Activity;importandroid.graphics.Bitmap;importandroid.graphics.Bitma...
import android.app.Activity;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.BitmapFactory.Options;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.opengl.Matrix;
import android.os.Bundle;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnTouchListener;
import android.widget.ImageView;
public class YifuActivity extends Activity {
private ImageView iv_after;
private ImageView iv_before;
private Bitmap alterBitmap;
private Canvas canvas;
private Paint paint;
/** Called when the activity is first created.
* @param OnTouchListener */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
BitmapFactory.Options opts=new Options();
opts.inSampleSize=2;
iv_after = (ImageView) findViewById(R.id.iv_after);
iv_before = (ImageView) findViewById(R.id.iv_pre);
Bitmap after=BitmapFactory.decodeResource(getResources(), R.drawable.after);
Bitmap before=BitmapFactory.decodeResource(getResources(), R.drawable.pre);
alterBitmap=Bitmap.createBitmap(before.getWidth(), before.getHeight(), before.getConfig());
canvas=new Canvas(alterBitmap);
paint=new Paint();
paint.setStrokeWidth(5);
paint.setColor(Color.BLACK);
canvas.drawBitmap(before, new Matrix(), paint);
iv_after.setImageBitmap(after);
iv_before.setImageBitmap( alterBitmap); 展开
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.BitmapFactory.Options;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.opengl.Matrix;
import android.os.Bundle;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnTouchListener;
import android.widget.ImageView;
public class YifuActivity extends Activity {
private ImageView iv_after;
private ImageView iv_before;
private Bitmap alterBitmap;
private Canvas canvas;
private Paint paint;
/** Called when the activity is first created.
* @param OnTouchListener */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
BitmapFactory.Options opts=new Options();
opts.inSampleSize=2;
iv_after = (ImageView) findViewById(R.id.iv_after);
iv_before = (ImageView) findViewById(R.id.iv_pre);
Bitmap after=BitmapFactory.decodeResource(getResources(), R.drawable.after);
Bitmap before=BitmapFactory.decodeResource(getResources(), R.drawable.pre);
alterBitmap=Bitmap.createBitmap(before.getWidth(), before.getHeight(), before.getConfig());
canvas=new Canvas(alterBitmap);
paint=new Paint();
paint.setStrokeWidth(5);
paint.setColor(Color.BLACK);
canvas.drawBitmap(before, new Matrix(), paint);
iv_after.setImageBitmap(after);
iv_before.setImageBitmap( alterBitmap); 展开
- 你的回答被采纳后将获得:
- 系统奖励15(财富值+成长值)+难题奖励20(财富值+成长值)
2个回答
展开全部
import android.opengl.Matrix;改成import android.graphicsl.Matrix; 自己瞎想出来的,至于为什么不解
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
看注释是不是串行了,少一行 这个一般都是用工具看 直接看 这样的高手好像没几个知道baidu知道
追问
提示的错误原因是这个呢
“The method drawBitmap(Bitmap, Matrix, Paint) in the type Canvas is not applicable for the arguments (Bitmap, Matrix, Paint)”
我是个菜鸟,代码是照着教程抄的,教程上没错误,但自己打出来就有错误。好纠结
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询