Is my encoding of bitmap usable for other platforms?

Multi tool use
Multi tool use












0















My question is is an encoded string generated with the code below usable on another platforms and if not - how do I make it? The code is working good on android, but I am not sure what will happen if I try to expand the project.



This is the code for generating the string:



private String BitMapToString(Bitmap bitmap){
ByteArrayOutputStream baos = new ByteArrayOutputStream();
bitmap.compress(Bitmap.CompressFormat.JPEG, 50, baos);
byte b = baos.toByteArray();
String imageEncoded = Base64.encodeToString(b, Base64.NO_WRAP);
return imageEncoded;
}


And this is the code for decoding it:



private Bitmap StringToBitMap(String encodedString){
byte decodedByte;
try {
decodedByte = Base64.decode(encodedString, 0);
} catch(Exception e) {
return null;
}
return BitmapFactory.decodeByteArray(decodedByte, 0, decodedByte.length);
}


I'm sending the string to the database and retrieving it and everything works just fine hence I can display the image. But is it usable elsewhere? And if not - how do I make it?










share|improve this question


















  • 2





    Define "elsewhere". Sure, if you implemented equivalent transforms in another app ... or another programming language ... it should work. Provided that you implement them correctly.

    – Stephen C
    Dec 29 '18 at 22:15











  • Lets say I get that string and try to decode it on JS or swift. Will it be okay or I have to use for example UTF-8 encoding somehow in my code?

    – A. Newbie
    Dec 29 '18 at 22:46






  • 1





    You don't need to use UTF-8 with Base64. Any encoding that will support a subset of the ASCII / LATIN 1 charset will do. Digits, lowercase and uppercase letters, + and / are all that are required. Read up on the spec for base64 encoding. (Google it)

    – Stephen C
    Dec 29 '18 at 22:54


















0















My question is is an encoded string generated with the code below usable on another platforms and if not - how do I make it? The code is working good on android, but I am not sure what will happen if I try to expand the project.



This is the code for generating the string:



private String BitMapToString(Bitmap bitmap){
ByteArrayOutputStream baos = new ByteArrayOutputStream();
bitmap.compress(Bitmap.CompressFormat.JPEG, 50, baos);
byte b = baos.toByteArray();
String imageEncoded = Base64.encodeToString(b, Base64.NO_WRAP);
return imageEncoded;
}


And this is the code for decoding it:



private Bitmap StringToBitMap(String encodedString){
byte decodedByte;
try {
decodedByte = Base64.decode(encodedString, 0);
} catch(Exception e) {
return null;
}
return BitmapFactory.decodeByteArray(decodedByte, 0, decodedByte.length);
}


I'm sending the string to the database and retrieving it and everything works just fine hence I can display the image. But is it usable elsewhere? And if not - how do I make it?










share|improve this question


















  • 2





    Define "elsewhere". Sure, if you implemented equivalent transforms in another app ... or another programming language ... it should work. Provided that you implement them correctly.

    – Stephen C
    Dec 29 '18 at 22:15











  • Lets say I get that string and try to decode it on JS or swift. Will it be okay or I have to use for example UTF-8 encoding somehow in my code?

    – A. Newbie
    Dec 29 '18 at 22:46






  • 1





    You don't need to use UTF-8 with Base64. Any encoding that will support a subset of the ASCII / LATIN 1 charset will do. Digits, lowercase and uppercase letters, + and / are all that are required. Read up on the spec for base64 encoding. (Google it)

    – Stephen C
    Dec 29 '18 at 22:54
















0












0








0








My question is is an encoded string generated with the code below usable on another platforms and if not - how do I make it? The code is working good on android, but I am not sure what will happen if I try to expand the project.



This is the code for generating the string:



private String BitMapToString(Bitmap bitmap){
ByteArrayOutputStream baos = new ByteArrayOutputStream();
bitmap.compress(Bitmap.CompressFormat.JPEG, 50, baos);
byte b = baos.toByteArray();
String imageEncoded = Base64.encodeToString(b, Base64.NO_WRAP);
return imageEncoded;
}


And this is the code for decoding it:



private Bitmap StringToBitMap(String encodedString){
byte decodedByte;
try {
decodedByte = Base64.decode(encodedString, 0);
} catch(Exception e) {
return null;
}
return BitmapFactory.decodeByteArray(decodedByte, 0, decodedByte.length);
}


I'm sending the string to the database and retrieving it and everything works just fine hence I can display the image. But is it usable elsewhere? And if not - how do I make it?










share|improve this question














My question is is an encoded string generated with the code below usable on another platforms and if not - how do I make it? The code is working good on android, but I am not sure what will happen if I try to expand the project.



This is the code for generating the string:



private String BitMapToString(Bitmap bitmap){
ByteArrayOutputStream baos = new ByteArrayOutputStream();
bitmap.compress(Bitmap.CompressFormat.JPEG, 50, baos);
byte b = baos.toByteArray();
String imageEncoded = Base64.encodeToString(b, Base64.NO_WRAP);
return imageEncoded;
}


And this is the code for decoding it:



private Bitmap StringToBitMap(String encodedString){
byte decodedByte;
try {
decodedByte = Base64.decode(encodedString, 0);
} catch(Exception e) {
return null;
}
return BitmapFactory.decodeByteArray(decodedByte, 0, decodedByte.length);
}


I'm sending the string to the database and retrieving it and everything works just fine hence I can display the image. But is it usable elsewhere? And if not - how do I make it?







java android base64 android-bitmap






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Dec 29 '18 at 22:06









A. NewbieA. Newbie

36116




36116








  • 2





    Define "elsewhere". Sure, if you implemented equivalent transforms in another app ... or another programming language ... it should work. Provided that you implement them correctly.

    – Stephen C
    Dec 29 '18 at 22:15











  • Lets say I get that string and try to decode it on JS or swift. Will it be okay or I have to use for example UTF-8 encoding somehow in my code?

    – A. Newbie
    Dec 29 '18 at 22:46






  • 1





    You don't need to use UTF-8 with Base64. Any encoding that will support a subset of the ASCII / LATIN 1 charset will do. Digits, lowercase and uppercase letters, + and / are all that are required. Read up on the spec for base64 encoding. (Google it)

    – Stephen C
    Dec 29 '18 at 22:54
















  • 2





    Define "elsewhere". Sure, if you implemented equivalent transforms in another app ... or another programming language ... it should work. Provided that you implement them correctly.

    – Stephen C
    Dec 29 '18 at 22:15











  • Lets say I get that string and try to decode it on JS or swift. Will it be okay or I have to use for example UTF-8 encoding somehow in my code?

    – A. Newbie
    Dec 29 '18 at 22:46






  • 1





    You don't need to use UTF-8 with Base64. Any encoding that will support a subset of the ASCII / LATIN 1 charset will do. Digits, lowercase and uppercase letters, + and / are all that are required. Read up on the spec for base64 encoding. (Google it)

    – Stephen C
    Dec 29 '18 at 22:54










2




2





Define "elsewhere". Sure, if you implemented equivalent transforms in another app ... or another programming language ... it should work. Provided that you implement them correctly.

– Stephen C
Dec 29 '18 at 22:15





Define "elsewhere". Sure, if you implemented equivalent transforms in another app ... or another programming language ... it should work. Provided that you implement them correctly.

– Stephen C
Dec 29 '18 at 22:15













Lets say I get that string and try to decode it on JS or swift. Will it be okay or I have to use for example UTF-8 encoding somehow in my code?

– A. Newbie
Dec 29 '18 at 22:46





Lets say I get that string and try to decode it on JS or swift. Will it be okay or I have to use for example UTF-8 encoding somehow in my code?

– A. Newbie
Dec 29 '18 at 22:46




1




1





You don't need to use UTF-8 with Base64. Any encoding that will support a subset of the ASCII / LATIN 1 charset will do. Digits, lowercase and uppercase letters, + and / are all that are required. Read up on the spec for base64 encoding. (Google it)

– Stephen C
Dec 29 '18 at 22:54







You don't need to use UTF-8 with Base64. Any encoding that will support a subset of the ASCII / LATIN 1 charset will do. Digits, lowercase and uppercase letters, + and / are all that are required. Read up on the spec for base64 encoding. (Google it)

– Stephen C
Dec 29 '18 at 22:54














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
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53973701%2fis-my-encoding-of-bitmap-usable-for-other-platforms%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
















draft saved

draft discarded




















































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.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53973701%2fis-my-encoding-of-bitmap-usable-for-other-platforms%23new-answer', 'question_page');
}
);

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







NHFpbuonO,wSAuld9 VL7dd0wk10 rEbuTi4,9M7dn476RCgG,boVpxi3mZ 7etXG96zsBeuC,X6OIDbn4,xiq0y672
X5f4oTdxloDMAriBAbD2MorzJigVORv6lK,X7,LpDyGt y6SJMa7,6 ZZp FesSMfu2r7FUttoSfscWsUEHo,A,DbavgKlFPPKN

Popular posts from this blog

Monofisismo

Angular Downloading a file using contenturl with Basic Authentication

Olmecas