TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Emad Younan
NA
67
4.2k
Xamarin.android Convert from Binary To image
Mar 25 2020 11:10 AM
hello guys
i used this code to insert into my sql server the image i loaded
Stream st = ContentResolver.OpenInputStream(uri);
Android.Graphics.Bitmap bitmap = BitmapFactory.DecodeStream(st);
MemoryStream memoryStream = new MemoryStream();
bitmap.Compress(Android.Graphics.Bitmap.CompressFormat.Jpeg, 100, memoryStream);
byte[] data = memoryStream.ToArray();
image = Convert.ToBase64String(data);
my column type varbinary(MAX) of image
SqlCommand cm = new SqlCommand("update dbo.Members set Member_Name= '" + firs.Text + " " + second.Text + "',Image=CONVERT(Varbinary(MAX),'" + image + "'), Phone='" + phone.Text + "' where user_name ='" + mail.Text + "' ", cn);
cm.CommandTimeout = 0;
and when i load my app from start i select the info and sent them with intent to the next actiity like that
emailadress = dt.Rows[0]["user_name"].ToString();
user_name = dt.Rows[0]["Member_Name"].ToString();
image = dt.Rows[0]["Image"].ToString();
well my question how to reback that to bitmap to use into that code
i used this code but not working
image = Intent.GetStringExtra("Image") ?? "Data is not available";
byte[] bytes = Encoding.ASCII.GetBytes(image);
MemoryStream memoryStream = new MemoryStream();
memoryStream.Write(bytes, 0, bytes.Length);
bitmap = BitmapFactory.DecodeStream(memoryStream);
`circleImageView.SetImageBitmap(bitmap);`
thanks at advance
Reply
Answers (
1
)
From Sqlite database to editor xamarin forms
Bookmark i have tablet with android 4.4.2