you could use DependencyService to convert System.IO.Stream
into Bitmap
,after raise the contrast of an image ,return the new stream,and show the Image
in forms page.
like:
create a interface IRaiseImage.cs
:
public interface IRaiseImage
{
Stream RaiseImage(Stream stream);
}
then in Droid.project,creat AndroidRaiseImage.cs
:
[assembly: Dependency(typeof(AndroidRaiseImage))]
namespace App18.Droid
{
class AndroidRaiseImage : IRaiseImage
{
public Stream RaiseImage(Stream stream)
{
Bitmap bitmap = BitmapFactory.DecodeStream(stream);
//raise the bitmap contrast
...
// return the new stream
MemoryStream ms = new MemoryStream();
bitmap.Compress(Bitmap.CompressFormat.Png, 100, ms);
return ms;
}
}
}
then you could set to the Image in your forms page:
MemoryStream memoryStream = new MemoryStream();//your original image stream
Image image = new Image();
image.Source = ImageSource.FromStream(() => DependencyService.Get<IRaiseImage>().RaiseImage(memoryStream));
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…