请教各位朋友,我的android客户端通过将图片转换成string,上传服务器后不能正常打开图片,
上传的图片下载下来通过文本框能够显示转换过后的string
服务器显示如下
下面是我的img转换String代码
public static String getImageString(String imgFilePath){
String imageString = null;
Bitmap mBitmap=BitmapFactory.decodeFile(imgFilePath);
if(mBitmap!=null){
Matrix matrix = new Matrix();
int mWidth=mBitmap.getWidth();
int mHeight=mBitmap.getHeight();
float scaleWidth=(float)150/mWidth;
float scaleHeight=(float)150/mHeight;
Log.i("scale", scaleWidth+"++++++++++++"+scaleHeight);
matrix.postScale(scaleWidth, scaleHeight);
Bitmap newBitmap=Bitmap.createBitmap(mBitmap, 0, 0, mBitmap.getWidth(), mBitmap.getHeight(), matrix, true);
ByteArrayOutputStream out=new ByteArrayOutputStream();
newBitmap.compress(CompressFormat.JPEG, 100, out);
byte []bytes=out.toByteArray();
imageString=Base64.encodeToString(bytes, Base64.DEFAULT);
System.out.println(imageString);
}
return imageString;
}