我目前正在研究一个steganogrpahy android应用程序作为一个类项目.我创建了一个对象,它将在另一个图像中编码图像并返回编码的位图.此代码在单独的线程中运行.
new Thread(new Runnable()
{
public void run()
{
Bitmap encoded_image = null;
Encryptor encryptor = new Encryptor();
encoded_image = encryptor.encode_image_in_image(
image_location,message_image_location);
}
}).start();
Run Code Online (Sandbox Code Playgroud)
在对位图进行编码之后,我将位图传递给我创建的文件浏览器活动,以将位图保存为png图像.此方法适用于较小的图像,但是,当编码大图像并将其传递给子活动时,应用程序会冻结并返回主活动.
private void pass_image_to_file_browser( Bitmap image )
{
Intent intent = new Intent(Encrypt.this,FileBrowser.class);
intent.putExtra( Intent.EXTRA_STREAM, image );
startActivity( intent );
}
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
Bundle bundle = this.getIntent().getExtras();
Bitmap image = bundle.getParacable(Intent.EXTRA_STREAM);
}
Run Code Online (Sandbox Code Playgroud)
我假设一个大的位图是使用意图在活动之间发送大的,所以我决定简单地将图像保存在临时位置并将图像的位置传递给子活动.然后将png图像保存在用户指定和删除临时图像文件的位置.
private void save_bitmap( Bitmap image, String location )
{
FileOutputStream fileOutputStream = new FileOutputStream(location);
BufferedOutputStream buffered_output_stream = …Run Code Online (Sandbox Code Playgroud)