DrawView.class中的主要代码 Canvas mCanvas;
private Bitmap originalBitmap = null;
Bitmap mBitmap;/
private Path mPath;
private Paint mBitmapPaint; // 画布的画笔
Paint mPaint; // 真实的画笔
private float mX, mY;//临时点坐标
private static final float TOUCH_TOLERANCE = 4; private int screenWidth = 1000, screenHeight = 300;// 屏幕長寬public boolean setBitmap(String imagePath)
{
Bitmap bitmap = BitmapFactory.decodeFile(imagePath);
int width = bitmap.getWidth();
int height = bitmap.getHeight();
float nxScale = -1;
float nyScale = -1;
if( width!=0 && height!=0)
{
nxScale = (float)width/screenWidth;
nyScale = (float)height/screenHeight;
if (nxScale>=1 && nyScale >=1 || nxScale<1 && nyScale<1)
{
if(nxScale > nyScale)
{
width = (int)(width/nxScale);
height = (int)(height/nxScale);
}
else
{
width = (int)(width/nyScale);
height = (int)(height/nyScale);
}
}
if (nxScale >=1 && nyScale <1)
{
width = screenWidth;
}
if(nxScale <=1 && nyScale >=1)
{
height = screenHeight;
}
originalBitmap = Bitmap.createScaledBitmap(bitmap,width,height,true);
mBitmap = Bitmap.createBitmap(width,height,Bitmap.Config.ARGB_8888);
// mSavePath.clear();
//mDeletePath.clear();
mCanvas.setBitmap(mBitmap);
mCanvas.drawBitmap(mBitmap,0,0,mBitmapPaint);
postInvalidate();
return true;
}
else
return false;
public class TuyaActivity extends Activity{
galler.setOnItemClickListener(new OnItemClickListener() { @Override
public void onItemClick(AdapterView<?> parent, View view,
int position, long id) {
// TODO Auto-generated method stub
String url=ImageList.get(position);
System.out.println(url);
touchView.setBitmap(url);
}
});
}}
private Bitmap originalBitmap = null;
Bitmap mBitmap;/
private Path mPath;
private Paint mBitmapPaint; // 画布的画笔
Paint mPaint; // 真实的画笔
private float mX, mY;//临时点坐标
private static final float TOUCH_TOLERANCE = 4; private int screenWidth = 1000, screenHeight = 300;// 屏幕長寬public boolean setBitmap(String imagePath)
{
Bitmap bitmap = BitmapFactory.decodeFile(imagePath);
int width = bitmap.getWidth();
int height = bitmap.getHeight();
float nxScale = -1;
float nyScale = -1;
if( width!=0 && height!=0)
{
nxScale = (float)width/screenWidth;
nyScale = (float)height/screenHeight;
if (nxScale>=1 && nyScale >=1 || nxScale<1 && nyScale<1)
{
if(nxScale > nyScale)
{
width = (int)(width/nxScale);
height = (int)(height/nxScale);
}
else
{
width = (int)(width/nyScale);
height = (int)(height/nyScale);
}
}
if (nxScale >=1 && nyScale <1)
{
width = screenWidth;
}
if(nxScale <=1 && nyScale >=1)
{
height = screenHeight;
}
originalBitmap = Bitmap.createScaledBitmap(bitmap,width,height,true);
mBitmap = Bitmap.createBitmap(width,height,Bitmap.Config.ARGB_8888);
// mSavePath.clear();
//mDeletePath.clear();
mCanvas.setBitmap(mBitmap);
mCanvas.drawBitmap(mBitmap,0,0,mBitmapPaint);
postInvalidate();
return true;
}
else
return false;
public class TuyaActivity extends Activity{
galler.setOnItemClickListener(new OnItemClickListener() { @Override
public void onItemClick(AdapterView<?> parent, View view,
int position, long id) {
// TODO Auto-generated method stub
String url=ImageList.get(position);
System.out.println(url);
touchView.setBitmap(url);
}
});
}}
解决方案 »
- Android点按钮弹出系统菜单的方法
- 请教一下关于tomcat配置问题
- MediaRecorder问题!!!!!!!!!!!
- Tab选项中图标变亮和变暗问题?
- listView显示来自网络的图片是如何实现?
- 请教下android布局的问题
- android google Map 问题
- aidl数据库查询的问题
- 关于AndroidSocketClient的使用
- android MediaPlayer+ SurfaceView 播放视频 全屏播放视频没有成功
- Android 电子书的应用,大段的文字存放在哪比较好啊?
- android 短信读取程序, 为什么string的长度(短信内容)只有一小部分
这里不是已经告诉你产生错误的代码行了么。10-11 21:06:56.654: E/MessageQueue-JNI(8434): java.lang.NullPointerException
10-11 21:06:56.654: E/MessageQueue-JNI(8434):at com.tuya.TuyaActivity$4.onItemClick(TuyaActivity.java:296)