我有一个位图,我想通过编码到base64发送到服务器,但我不想压缩png或jpeg中的图像.
现在我以前做的是.
ByteArrayOutputStream byteArrayBitmapStream = new ByteArrayOutputStream();
bitmapPicture.compress(Bitmap.CompressFormat.PNG, COMPRESSION_QUALITY, byteArrayBitmapStream);
byte[] b = byteArrayBitmapStream.toByteArray();
//then simple encoding to base64 and off to server
encodedImage = Base64.encodeToString(b, Base64.NO_WRAP);
Run Code Online (Sandbox Code Playgroud)
现在我只是不想使用任何压缩,也不想从位图中使用任何格式简单的byte [],我可以编码并发送到服务器.
有什么指针吗?
我正在使用此帖子中的jengelsma代码从相机中捕获图像和在活动中显示以从相机获取图像.
当我得到返回的图像时,它很小,当我尝试扩展它时,我立即失去了图像质量.
我认为这只是预览尺寸,但是我无法找到返回大图像,因为我需要它来操纵它.
供参考,代码是:
package edu.gvsu.cis.masl.camerademo;
import android.app.Activity;
import android.content.Intent;
import android.graphics.Bitmap;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
public class MyCameraActivity extends Activity {
private static final int CAMERA_REQUEST = 1888;
private ImageView imageView;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
this.imageView = (ImageView)this.findViewById(R.id.imageView1);
Button photoButton = (Button) this.findViewById(R.id.button1);
photoButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent cameraIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
startActivityForResult(cameraIntent, CAMERA_REQUEST);
}
});
}
protected void onActivityResult(int requestCode, int resultCode, Intent …Run Code Online (Sandbox Code Playgroud)