I was able to access the camera and take a picture (with PictureChooser plugin), It store the picture in picture-library of android, I just want to display it on the screen and delete it (I don't need to store pictures) How can I do that ? (few lines of code are welcome :)) Thanks !
ps: maybe with File plugin of mvvmcross ?
edit: Thanks for your answer, I think the best way for me is to do a custom binding to bind a byte[] to a normal ImageView, I saw the sample for custom binding (textview and button) and I tried to make mine.
namespace Testa.Droid.Bindings
{
class PictureBinding : MvxBaseAndroidTargetBinding
{
private readonly ImageView _imageView;
public PictureBinding(ImageView imageView)
{
_imageView = imageView;
}
public override MvxBindingMode DefaultMode
{
get { return MvxBindingMode.OneWay; }
}
public override Type TargetType
{
get { return typeof (byte[]); }
}
public override void SetValue(object value)
{
var memoryStream = new MemoryStream((byte[])valyue);
Bitmap bitmap = BitmapFactory.DecodeStream(memoryStream);
_imageView.SetImageBitmap(bitmap);
}
}
}
In Setup.cs
protected override void FillTargetFactories(Cirrious.MvvmCross.Binding.Interfaces.Bindings.Target.Construction.IMvxTargetBindingFactoryRegistry registry)
{
base.FillTargetFactories(registry);
registry.RegisterFactory(new MvxCustomBindingFactory<ImageView>("Picture", (imageView) => new PictureBinding(imageView)));
}
In my ViewModel I have:
public byte[] ImageData {
get { return _imageData; }
set { _imageData = value; RaisePropertyChanged(() => ImageData); }
}
And now in my view I don't know how to use this custom binding
<ImageView
android:id="@+id/image"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
local:MvxBind="Picture ??, Mode=TwoWay" />
mvvcross vNext|monodroid