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
C# Corner
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Base64 String To Image Converter For Windows Phone 8.1 RT
Charwaka Thupili
Sep 19
2015
Code
2.6
k
0
0
facebook
twitter
linkedIn
Reddit
WhatsApp
Email
Bookmark
expand
Use the following Code to Convert Base64 String To Image for Windows Phone 8.1 RT & Windows 10 Mobile.This is Useful When you are storing Image as String in SQlite and When Retrieving you should convert that Base64 String to Again Image Then You need Use This Converter:
public
class
Base64toImageConverter: IValueConverter {
public
object
Convert(
object
value, Type targetType,
object
parameter,
string
language) {
var base64 = value
as
string
;
var imageBytes = System.Convert.FromBase64String(base64);
using
(InMemoryRandomAccessStream ms =
new
InMemoryRandomAccessStream()) {
using
(DataWriter writer =
new
DataWriter(ms.GetOutputStreamAt(0))) {
writer.WriteBytes((
byte
[]) imageBytes);
writer.StoreAsync().GetResults();
}
var image =
new
BitmapImage();
image.SetSource(ms);
return
image;
}
return
null
;
}
public
object
ConvertBack(
object
value, Type targetType,
object
parameter,
string
language) {
return
null
;
}
}
}
Base64 String
Base64
Windows Phone 8.1