0
저는 Android 개발에 익숙하지 않습니다. 지금 현재 Image Steganography 용 앱을 만들고 있습니다. 그래서 내 응용 프로그램에서 갤러리에서 선택한 이미지를 비트 배열로 변환해야합니다 (각 픽셀은 8 비트 값을가집니다.). 어떻게 할 수 있습니까? 아무도 나를 도울 수 있습니까?이미지를 비트 배열로 변환하는 방법
public class ImageActivity extends Activity {
private Button btnSelectImage;
private Button btnEncode;
String Pathfile=new String();
public String selectedImagePath;
private ImageView myImage;
Bitmap result;
public static final int ICON_SELECT_GALLERY = 1;
private static final Object IMAGE_TAKER_REQUEST = null;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_image);
btnSelectImage = (Button) findViewById(R.id.button1);
btnEncode = (Button) findViewById(R.id.button2);
btnSelectImage.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
selectImage();
}
});
myImage = (ImageView) findViewById(R.id.imageView1);
}
public void selectImage() {
Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
intent.setType("image/*");
startActivityForResult(intent, ICON_SELECT_GALLERY);
}
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data)
{
if (resultCode == RESULT_OK)
{
if (requestCode == 1)
{
Uri selectedImageUri = data.getData();
String selectedImagePath = getPath(selectedImageUri);
Log.v("IMAGE PATH====>>>> ",selectedImagePath);
TextView imgPath=(TextView)findViewById(R.id.textView2);
imgPath.setText(selectedImagePath);
Pathfile=new String(selectedImagePath);
result = BitmapFactory.decodeFile(Pathfile);
myImage.setImageBitmap(result);
}
}
}
public String getPath(Uri uri)
{
String[] projection = { MediaStore.Images.Media.DATA };
Cursor cursor = managedQuery(uri, projection, null, null, null);
int column_index = cursor
.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
cursor.moveToFirst();
return cursor.getString(column_index);
}
}
그러나 바이트 [] 배열에서
byte[]
이 일부 거짓 알파벳 값되지 않은 이진 값을 얻고 돌아갑니다? 왜 그렇게? – Abinthaha