Convert picture URL to Bitmap with React & ASP.NET
In my application i need to be able to capture image in browser then send it back to the server where it gets processed. currently i have a widget that captures an image and returns a pictureUrl for png image.
I'm looking for a best possible way to send it back to server.
Ideally i want this image put back inside the class that I originally fetch from server, then serialize it back to JSON and send to server.
Lets say for instance I heve the following C# class:
myClassWithImage{
Bitmap myBitmap = null;
///many other properties
}
i serialize it to json and send it to the user.
Then i want react to use the instance of this class, update it with the picture, serialize to json & send back updated version.
On server I just want to recreate the class instance using Newtonsoft.JSON like:
myClassWithImage imgCl = data.SelectToken("myClassWImage").ToObject<myClassWithImage>();
Is this possible at all? Or should i serialize images to base64 string ans send separately?
UPDATE:
I guess what I'm trying to find out if it is possible to serialize/deserialize the object directly into the instance of class without using additional Base64 string properties to it.
If i try to add image Url directly to the myBitmap property I get
Newtonsoft.Json.JsonSerializationException: Newtonsoft.Json.JsonSerializationException: 'Error converting value "data:image/png;base64,....
So should i instead introduce another property to this class to hold the value of the image as string during serialization/deserialization?
c# reactjs
add a comment |
In my application i need to be able to capture image in browser then send it back to the server where it gets processed. currently i have a widget that captures an image and returns a pictureUrl for png image.
I'm looking for a best possible way to send it back to server.
Ideally i want this image put back inside the class that I originally fetch from server, then serialize it back to JSON and send to server.
Lets say for instance I heve the following C# class:
myClassWithImage{
Bitmap myBitmap = null;
///many other properties
}
i serialize it to json and send it to the user.
Then i want react to use the instance of this class, update it with the picture, serialize to json & send back updated version.
On server I just want to recreate the class instance using Newtonsoft.JSON like:
myClassWithImage imgCl = data.SelectToken("myClassWImage").ToObject<myClassWithImage>();
Is this possible at all? Or should i serialize images to base64 string ans send separately?
UPDATE:
I guess what I'm trying to find out if it is possible to serialize/deserialize the object directly into the instance of class without using additional Base64 string properties to it.
If i try to add image Url directly to the myBitmap property I get
Newtonsoft.Json.JsonSerializationException: Newtonsoft.Json.JsonSerializationException: 'Error converting value "data:image/png;base64,....
So should i instead introduce another property to this class to hold the value of the image as string during serialization/deserialization?
c# reactjs
Yes it is possible, is it not working? Or what errors are you encountering? Personally, I'd use a property that's marked as serializable. Like public bitmap myBitMap {get;set;} type of thing...
– Trey
Nov 19 '18 at 15:58
If i put Base64 value directly into the myBitmap property I get Newtonsoft.Json.JsonSerializationException: 'Error converting value
– AnKing
Nov 19 '18 at 16:02
Sorry, I'm getting called into a meeting, try this: stackoverflow.com/questions/15510742/…
– Trey
Nov 19 '18 at 16:06
add a comment |
In my application i need to be able to capture image in browser then send it back to the server where it gets processed. currently i have a widget that captures an image and returns a pictureUrl for png image.
I'm looking for a best possible way to send it back to server.
Ideally i want this image put back inside the class that I originally fetch from server, then serialize it back to JSON and send to server.
Lets say for instance I heve the following C# class:
myClassWithImage{
Bitmap myBitmap = null;
///many other properties
}
i serialize it to json and send it to the user.
Then i want react to use the instance of this class, update it with the picture, serialize to json & send back updated version.
On server I just want to recreate the class instance using Newtonsoft.JSON like:
myClassWithImage imgCl = data.SelectToken("myClassWImage").ToObject<myClassWithImage>();
Is this possible at all? Or should i serialize images to base64 string ans send separately?
UPDATE:
I guess what I'm trying to find out if it is possible to serialize/deserialize the object directly into the instance of class without using additional Base64 string properties to it.
If i try to add image Url directly to the myBitmap property I get
Newtonsoft.Json.JsonSerializationException: Newtonsoft.Json.JsonSerializationException: 'Error converting value "data:image/png;base64,....
So should i instead introduce another property to this class to hold the value of the image as string during serialization/deserialization?
c# reactjs
In my application i need to be able to capture image in browser then send it back to the server where it gets processed. currently i have a widget that captures an image and returns a pictureUrl for png image.
I'm looking for a best possible way to send it back to server.
Ideally i want this image put back inside the class that I originally fetch from server, then serialize it back to JSON and send to server.
Lets say for instance I heve the following C# class:
myClassWithImage{
Bitmap myBitmap = null;
///many other properties
}
i serialize it to json and send it to the user.
Then i want react to use the instance of this class, update it with the picture, serialize to json & send back updated version.
On server I just want to recreate the class instance using Newtonsoft.JSON like:
myClassWithImage imgCl = data.SelectToken("myClassWImage").ToObject<myClassWithImage>();
Is this possible at all? Or should i serialize images to base64 string ans send separately?
UPDATE:
I guess what I'm trying to find out if it is possible to serialize/deserialize the object directly into the instance of class without using additional Base64 string properties to it.
If i try to add image Url directly to the myBitmap property I get
Newtonsoft.Json.JsonSerializationException: Newtonsoft.Json.JsonSerializationException: 'Error converting value "data:image/png;base64,....
So should i instead introduce another property to this class to hold the value of the image as string during serialization/deserialization?
c# reactjs
c# reactjs
edited Nov 19 '18 at 16:13
asked Nov 19 '18 at 15:54
AnKing
346512
346512
Yes it is possible, is it not working? Or what errors are you encountering? Personally, I'd use a property that's marked as serializable. Like public bitmap myBitMap {get;set;} type of thing...
– Trey
Nov 19 '18 at 15:58
If i put Base64 value directly into the myBitmap property I get Newtonsoft.Json.JsonSerializationException: 'Error converting value
– AnKing
Nov 19 '18 at 16:02
Sorry, I'm getting called into a meeting, try this: stackoverflow.com/questions/15510742/…
– Trey
Nov 19 '18 at 16:06
add a comment |
Yes it is possible, is it not working? Or what errors are you encountering? Personally, I'd use a property that's marked as serializable. Like public bitmap myBitMap {get;set;} type of thing...
– Trey
Nov 19 '18 at 15:58
If i put Base64 value directly into the myBitmap property I get Newtonsoft.Json.JsonSerializationException: 'Error converting value
– AnKing
Nov 19 '18 at 16:02
Sorry, I'm getting called into a meeting, try this: stackoverflow.com/questions/15510742/…
– Trey
Nov 19 '18 at 16:06
Yes it is possible, is it not working? Or what errors are you encountering? Personally, I'd use a property that's marked as serializable. Like public bitmap myBitMap {get;set;} type of thing...
– Trey
Nov 19 '18 at 15:58
Yes it is possible, is it not working? Or what errors are you encountering? Personally, I'd use a property that's marked as serializable. Like public bitmap myBitMap {get;set;} type of thing...
– Trey
Nov 19 '18 at 15:58
If i put Base64 value directly into the myBitmap property I get Newtonsoft.Json.JsonSerializationException: 'Error converting value
– AnKing
Nov 19 '18 at 16:02
If i put Base64 value directly into the myBitmap property I get Newtonsoft.Json.JsonSerializationException: 'Error converting value
– AnKing
Nov 19 '18 at 16:02
Sorry, I'm getting called into a meeting, try this: stackoverflow.com/questions/15510742/…
– Trey
Nov 19 '18 at 16:06
Sorry, I'm getting called into a meeting, try this: stackoverflow.com/questions/15510742/…
– Trey
Nov 19 '18 at 16:06
add a comment |
0
active
oldest
votes
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%2f53378329%2fconvert-picture-url-to-bitmap-with-react-asp-net%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
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.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- 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%2f53378329%2fconvert-picture-url-to-bitmap-with-react-asp-net%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
Yes it is possible, is it not working? Or what errors are you encountering? Personally, I'd use a property that's marked as serializable. Like public bitmap myBitMap {get;set;} type of thing...
– Trey
Nov 19 '18 at 15:58
If i put Base64 value directly into the myBitmap property I get Newtonsoft.Json.JsonSerializationException: 'Error converting value
– AnKing
Nov 19 '18 at 16:02
Sorry, I'm getting called into a meeting, try this: stackoverflow.com/questions/15510742/…
– Trey
Nov 19 '18 at 16:06