How to present a Image in Xamarin from Database
I have uploaded a image from an
asp.net website to the db (An interface to update news on the Xamarin.Android app)
The Image is uploaded as byte
And the target DB has the datatype varbinary(Max)
The image is saved.
When i show it on the website as is just for test (asp.net webpage)
The code is... THis works
........(An storeprocedure that return value).............
byte bytes = (byte)command.ExecuteScalar(); // Returnera ett värde
String stringBase64 = Convert.ToBase64String(bytes);
Image1.ImageUrl = "data:Image/png;base64,"+ stringBase64;
But i want to know how i can make a webservice and what datatype type the Xamarin.Android wants. An code example please.
I cant figure this out. =/
I sould be able to use some of the code in the webservice example.
and how it would be placed in this with C# code.
ImageView imageView = new ImageView(this);
imageView ???????????????????????????
mainlinerlayout.AddView(imageView);
This was my try
byte bytes = (byte)command.ExecuteScalar(); // Returnera ett värde
//Im unsure about this 2 lines but example on internet wants it to be Converted to tobase64string, and memorystream wants byte
String stringBase64 = Convert.ToBase64String(bytes);
byte imageBytes = Convert.FromBase64String(stringBase64);
MemoryStream ms = new MemoryStream();
ms.Write(imageBytes, 0, imageBytes.Length);
Image image = Image.FromStream(ms, true);
return image;
So
The Xamarin.Android Load
That call the webservice that gets the image from the db.
A full code please. This is one of the last part i need to
get right before i can go foward.
c# android database image xamarin
add a comment |
I have uploaded a image from an
asp.net website to the db (An interface to update news on the Xamarin.Android app)
The Image is uploaded as byte
And the target DB has the datatype varbinary(Max)
The image is saved.
When i show it on the website as is just for test (asp.net webpage)
The code is... THis works
........(An storeprocedure that return value).............
byte bytes = (byte)command.ExecuteScalar(); // Returnera ett värde
String stringBase64 = Convert.ToBase64String(bytes);
Image1.ImageUrl = "data:Image/png;base64,"+ stringBase64;
But i want to know how i can make a webservice and what datatype type the Xamarin.Android wants. An code example please.
I cant figure this out. =/
I sould be able to use some of the code in the webservice example.
and how it would be placed in this with C# code.
ImageView imageView = new ImageView(this);
imageView ???????????????????????????
mainlinerlayout.AddView(imageView);
This was my try
byte bytes = (byte)command.ExecuteScalar(); // Returnera ett värde
//Im unsure about this 2 lines but example on internet wants it to be Converted to tobase64string, and memorystream wants byte
String stringBase64 = Convert.ToBase64String(bytes);
byte imageBytes = Convert.FromBase64String(stringBase64);
MemoryStream ms = new MemoryStream();
ms.Write(imageBytes, 0, imageBytes.Length);
Image image = Image.FromStream(ms, true);
return image;
So
The Xamarin.Android Load
That call the webservice that gets the image from the db.
A full code please. This is one of the last part i need to
get right before i can go foward.
c# android database image xamarin
You could try using jgoldberger's advice: stackoverflow.com/questions/53372917/…
– York Shen - MSFT
Nov 20 '18 at 5:10
add a comment |
I have uploaded a image from an
asp.net website to the db (An interface to update news on the Xamarin.Android app)
The Image is uploaded as byte
And the target DB has the datatype varbinary(Max)
The image is saved.
When i show it on the website as is just for test (asp.net webpage)
The code is... THis works
........(An storeprocedure that return value).............
byte bytes = (byte)command.ExecuteScalar(); // Returnera ett värde
String stringBase64 = Convert.ToBase64String(bytes);
Image1.ImageUrl = "data:Image/png;base64,"+ stringBase64;
But i want to know how i can make a webservice and what datatype type the Xamarin.Android wants. An code example please.
I cant figure this out. =/
I sould be able to use some of the code in the webservice example.
and how it would be placed in this with C# code.
ImageView imageView = new ImageView(this);
imageView ???????????????????????????
mainlinerlayout.AddView(imageView);
This was my try
byte bytes = (byte)command.ExecuteScalar(); // Returnera ett värde
//Im unsure about this 2 lines but example on internet wants it to be Converted to tobase64string, and memorystream wants byte
String stringBase64 = Convert.ToBase64String(bytes);
byte imageBytes = Convert.FromBase64String(stringBase64);
MemoryStream ms = new MemoryStream();
ms.Write(imageBytes, 0, imageBytes.Length);
Image image = Image.FromStream(ms, true);
return image;
So
The Xamarin.Android Load
That call the webservice that gets the image from the db.
A full code please. This is one of the last part i need to
get right before i can go foward.
c# android database image xamarin
I have uploaded a image from an
asp.net website to the db (An interface to update news on the Xamarin.Android app)
The Image is uploaded as byte
And the target DB has the datatype varbinary(Max)
The image is saved.
When i show it on the website as is just for test (asp.net webpage)
The code is... THis works
........(An storeprocedure that return value).............
byte bytes = (byte)command.ExecuteScalar(); // Returnera ett värde
String stringBase64 = Convert.ToBase64String(bytes);
Image1.ImageUrl = "data:Image/png;base64,"+ stringBase64;
But i want to know how i can make a webservice and what datatype type the Xamarin.Android wants. An code example please.
I cant figure this out. =/
I sould be able to use some of the code in the webservice example.
and how it would be placed in this with C# code.
ImageView imageView = new ImageView(this);
imageView ???????????????????????????
mainlinerlayout.AddView(imageView);
This was my try
byte bytes = (byte)command.ExecuteScalar(); // Returnera ett värde
//Im unsure about this 2 lines but example on internet wants it to be Converted to tobase64string, and memorystream wants byte
String stringBase64 = Convert.ToBase64String(bytes);
byte imageBytes = Convert.FromBase64String(stringBase64);
MemoryStream ms = new MemoryStream();
ms.Write(imageBytes, 0, imageBytes.Length);
Image image = Image.FromStream(ms, true);
return image;
So
The Xamarin.Android Load
That call the webservice that gets the image from the db.
A full code please. This is one of the last part i need to
get right before i can go foward.
c# android database image xamarin
c# android database image xamarin
asked Nov 16 '18 at 22:01
JonasJonas
506
506
You could try using jgoldberger's advice: stackoverflow.com/questions/53372917/…
– York Shen - MSFT
Nov 20 '18 at 5:10
add a comment |
You could try using jgoldberger's advice: stackoverflow.com/questions/53372917/…
– York Shen - MSFT
Nov 20 '18 at 5:10
You could try using jgoldberger's advice: stackoverflow.com/questions/53372917/…
– York Shen - MSFT
Nov 20 '18 at 5:10
You could try using jgoldberger's advice: stackoverflow.com/questions/53372917/…
– York Shen - MSFT
Nov 20 '18 at 5:10
add a comment |
1 Answer
1
active
oldest
votes
Can you try this if it works. Just to be clear are you using Xamarin.Forms or Xamarin.Android?
String stringBase64 = Convert.ToBase64String(bytes);
byte imageBytes = Convert.FromBase64String(stringBase64);
Image image = Image.FromStream(() => new MemoryStream(imageBytes));
return image;
I will check that Im using Xamarin.Andorid But for everyone include myself please answer for both =)
– Jonas
Nov 20 '18 at 8:23
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53346017%2fhow-to-present-a-image-in-xamarin-from-database%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Can you try this if it works. Just to be clear are you using Xamarin.Forms or Xamarin.Android?
String stringBase64 = Convert.ToBase64String(bytes);
byte imageBytes = Convert.FromBase64String(stringBase64);
Image image = Image.FromStream(() => new MemoryStream(imageBytes));
return image;
I will check that Im using Xamarin.Andorid But for everyone include myself please answer for both =)
– Jonas
Nov 20 '18 at 8:23
add a comment |
Can you try this if it works. Just to be clear are you using Xamarin.Forms or Xamarin.Android?
String stringBase64 = Convert.ToBase64String(bytes);
byte imageBytes = Convert.FromBase64String(stringBase64);
Image image = Image.FromStream(() => new MemoryStream(imageBytes));
return image;
I will check that Im using Xamarin.Andorid But for everyone include myself please answer for both =)
– Jonas
Nov 20 '18 at 8:23
add a comment |
Can you try this if it works. Just to be clear are you using Xamarin.Forms or Xamarin.Android?
String stringBase64 = Convert.ToBase64String(bytes);
byte imageBytes = Convert.FromBase64String(stringBase64);
Image image = Image.FromStream(() => new MemoryStream(imageBytes));
return image;
Can you try this if it works. Just to be clear are you using Xamarin.Forms or Xamarin.Android?
String stringBase64 = Convert.ToBase64String(bytes);
byte imageBytes = Convert.FromBase64String(stringBase64);
Image image = Image.FromStream(() => new MemoryStream(imageBytes));
return image;
answered Nov 20 '18 at 5:28
iamlawrenceviamlawrencev
806
806
I will check that Im using Xamarin.Andorid But for everyone include myself please answer for both =)
– Jonas
Nov 20 '18 at 8:23
add a comment |
I will check that Im using Xamarin.Andorid But for everyone include myself please answer for both =)
– Jonas
Nov 20 '18 at 8:23
I will check that Im using Xamarin.Andorid But for everyone include myself please answer for both =)
– Jonas
Nov 20 '18 at 8:23
I will check that Im using Xamarin.Andorid But for everyone include myself please answer for both =)
– Jonas
Nov 20 '18 at 8:23
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53346017%2fhow-to-present-a-image-in-xamarin-from-database%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
You could try using jgoldberger's advice: stackoverflow.com/questions/53372917/…
– York Shen - MSFT
Nov 20 '18 at 5:10