android - How to convert Bitmap to Base64 String -
i developing android application uploads base64
string of image web server. therefore, have used following code convert bitmap base64
string.
public string getencoded64imagestringfrombitmap(bitmap bitmap) { bytearrayoutputstream stream = new bytearrayoutputstream(); bitmap.compress(bitmap.compressformat.png, 100, stream); byte[] byteformat = stream.tobytearray(); string imgstring = base64.encodetostring(byteformat, base64.no_wrap); return imgstring; }
for example, need convert image. after conversion, i'm not getting base64
string expected.
ivborw0kggoaaaansuheugaaaicaaab7cayaaabet5noaaaabhncsvqicagifahkiaaab/fjrefuejzt3u1a4lgxb/d/uvqps3ibnuokzeg56fqkml6bqru0nddxitwrbwbtdhp3oduaicuqvobylkbmsndy3ghedkgggzvkjjm/kr8hxpp8pbk55ioqkjhvoci97lnmqbjxfuwhah4nwp6amqmpab4yefbq3v/637tjjtcut2cxvyfjuqbjzq4cqal4toflpra/m9mgye1aca786eyiyqxszryangpaby8jty6r25p+9wdn64zv4+flohh1ahvsdkjysw8h7eey1a6ofvxbatydr7rxv6qhckfsb3difp/irrwr4xlcjvqgyjxio4a6lr+tw62r1bui38y417xosga7ig6aejkftsulz9shcjczf93byedwjkzgwyfx/syz/6ljqlsgymyehu7/odds/odyrsayupauc5odwjhfl3yqd9mmruda2unnsca1yyybdzi2hyjvnp1/7jpu9fnwl9/mrbmjj48dmp2+zestmgg4eeeuzl4tbqfvsh2hcuhvt6kikcpxdhzrzzdue5hs6nljlkenbf97ghhcnvdi4ntrv9wm8ppi4xisxdgaxsmjg8rn6jsnlq6ajd9fnojxl451jeym0m/zyrcohy55mp7ezkqmigbmiuuh9+3blut5rf12ymckcwc9pzyth/lhuwhwlvvgaaadr65l3aezi+q268hbmadg19llxjfmghvdkydg+hzania5cybndp73rlu2hlonsnfahmsgt+zs7chqhir9qc6c4tkf1y6b6xyinhomrmbbh5e9qyaosqiknunnatd+q/gjqgkywdlkrx87oq4gajxu2vfmphgawogevdgv4zgdwxvd4nilcn9bigdmfcq9fuys+sw73criahyuxvyekl1exi4wjv8lfiw3bpxbchf1xex48lrfrlgcaqdns6oyygzjxu0s/2shcsw/kxglnh7z9jdcr+3m4c/+z6iwksf8i+cik3awaai1/d+/hwm+y60npsbhdgaoftaulo/7t3co1z0bxztricum1/a+fgshmexvc4vcoff6hgrw2urgn7aielr6+vgh5ufwmkxurymmm8udagbimyikbxvg3ud4rf1yummrpnggtpt/0euit4ncqnlj3frmkjffzkgqbtpoerzcqaryan6ltxdldhqbx2mpqhjpvox8bc+xg1cxjohiknciqbioeujciqjjoeqgcycijoeqgsqcipacmel7emjmcsbonzmr+sw7frfimdbnexdctaoerxfze/mhfcuzc4h3cbirf8sveg7xdgmp6qr7/ty7v7yq/ygigqiajpbqirywu/nwmek4xaklmauhguqmpbzhlsnhfxswjjw8o01ornwffjukvxrgiozduav84zboqfa4khubxzhkihn/9juw0tb7wtvboa7v2wppdwgmdlyvfz+vjzlquxdu/rtjfb0qdql3nyovhxljf1daqjjmtzeajj4kyqsc6vi/x3gyd+ft+soinn7ge59x+u2oteylidvlp1l5micdm3eprrhluor5uyvdidwjwaiqserngscys/uojhdzdu9goozlro5ccs6bson+t/bshkbyi/kbgw9eq3yvju+k/vn5f9fm/kfwuqktdcv91tqbbw68qonf/demte7zrym2ny6zaygt7vuzkzz7o+cie77ou+frhboc8vc+pwdg2+7deqkjvjv60qrvbq99rexrv9ue8d32oxiggdr7/9hhf450ifv8xxj4m00tpdje9hh2v41hk8uezi6qrktdyppgsmsiffth5hl+kw/bchjfhijfvttxirqr7kjbala8p8fsjfjlnq8vsemvlr+trc7wi7xb8zs94pv+3mudik6lt5ioaqdwabiqc+0wdebdoaajihl2dwagkryabmqqwx2vbnewdkackjktwqa0302w0m93qpgdcm/tpgkpbqc5cnikuzaowiibxhqful+jtcpivizxbqoiqxj4rlbjopsy1wvwguf7fntqku+tkj+vrbvroaajsexidwaqwo2tt7rxz055agg4ifu9coh4lolgaaludr/h2muhwhms75kzn5v+y07qzrk9mx6l37lljlktjromiohk4zfmwvr62ufrpfjijdkfyl8gh7ohpbmmikxk4zfm2votgqqnervqvmmbseacxnb1jcl1jzud3rchtnl6ddlx2tn0okppbwmwohj4pfkgikhmvlipvw6pnmtwy1iwaimqh18bm2wj9zdcmkzy+fx6lzsjx9merxky8nxeyacgvg5p/ptl6fuwwja6hadws3zlmdxb5otqdwkcve31jekxphxa7nohrvqwwjbyzrhs8l49ckcqyh4vjnyzt3tlroxwzlwxylqpi4xmva5phnshvawfa8hy5fdluc/eyb5ggjmqhh4z6yvknhhahiuhx9xeink9jdayhw7axf5i9omb5cqcgdg9knrp0neps3oozqb0qizkszwxyaa5cgcanps/p8wpdzmoskaaw2hlkhxakr2qovoe5i4yqi7mhksk0avpoevppwvnrbbyhq4agh++bbdjrxhwnekerhi5dwcqsy8k98eachioqgcvjb89jdakew5ary+komeacni0ss4ovzajqf1wpgaabascnojnhwtmzc3dclu5pbf6iczcfzagqlyovzw9kmyduavbisuh38rzqhk8tzljcl85pl5escf6ggh8h2wnu29+inicaaaaaelftksuqmcc
the real base64 string should (i use website convert)
ivborw0kggoaaaansuheugaaaicaaab7cayaaabet5noaaaacxbiwxmaabcsaaaxegfnn9jsaaaagxrfwhrtb2z0d2fyzqbbzg9izsbjbwfnzvjlywr5ccllpaaabjbjrefuenrsnc9x2zwqxre1ydeqsvobdpxjsgvrkhbdqeytr/ixp6qdux1ihuinxkukio8bkctwsj7l98e0iuekqwkb92y4zp+xez3+9lc7isfpr6+vqgs9x92f6y9jfyz4on9fh/iwj33sjgp1+c/plriu7coifbg0vdg78m1rfez1sensh08+4wajmjzj2nkpjamwdgitdkkamogvxxemxyfw4dbgxdiqdfx49p0myru5eybaka+zlogwack+likewzbj2so5ocvofgik2ocx+3at3yfgchatqwb8coans+bctv0oevdmqpiha1qbnikd19k8g9iss9xkxduk2gec4jzah5bsw74zodgtcipvadebl5wiuee0wlrybpvyyvinru6ggzuqrqffzluamyt7lseintvtetaezlzboq2hdus3iemkbamdbgsq7qmtib8ejlnm2oosdtgyjeclv08cr5ugyosbfj1n6rgjyxtlkagyipfbfs+lqykhumv2qj8giybr6kwuijgauwjir6f+ssimrgtwgc5lzmi1bokmdoci1qoht6sbqv2jlyi1yjakfbcndq8tk3neycietawsb+ptphmqumhbpfw3fb+sa28iybr1wo60rdbfuwjrdof+pyewth0tt1grkmowgbikkxdlqykhqtljxxlwzwv/vbpaq34+ag9fn+znuyok1ehz14m//lnlssk1xkrbkeucl1b6kbxzgrug9fgzdq4imhzzjwevktqmh8ixiduxk2mmpybdyxmofklqh+r4m3pozeuvfkalfrmyrqsegrrrsjkcd5anjkv4afuvpugoykzzjadk05dguiapujugsaachbdggaahbdggwaebdghwqbhb8qibibscg9gayvmbtozjbrsggxx72ach5obo0rpgggzadxjboyd4azw0kbovpaceokdt4ua7c5l6oz2e3+ci4dlpuktafa1sotu8gvilmhxid8iahat4amltiydc/qchp2oc8w4ol34xqfprimbrbucob5lw3hxqwds4egnzwiokrlvykh7doys1prr3ow9vjmi08dswjqdpbq+sa1/d4eb6jkfbqj88diex0iprwumohjwe6fziv2b7i2o3jtzcu6j1uizkq3t0idtpv/fu2v6aj1ewoqc3c3s5qwmg4jst5cqzdh6nym/0uhth0/bmcdag9ime4gkuwurz6tqfd75xlh9rvys3susmdcjdl069ktpdeytwtnvgduzx7lxh4b+ckezpirgmsuud0sq5ivpjdl9ldsangleldgoqg3guqvqg4vpx+nxevixh6wakfddyut/cagcfabivgi3hacdxgke6+tmkq56v7qmlecr5kdeveesojeicylqkhwhid4u5ihgwwl1wsksmfrs80sczzptmmfppdinbikezessvtr7a8jycrokcc4imcr69geftq1cvoxjzf3ys8ggdodc8w1eczi5z2oqwxydhfvmpwgaom5ni/nyw3eicdfwpdboxpr8wxfemaizok8niehqrmka6q5vxendjysqivdabtlrhgtfbchgjgmgzxftgmfs5dwivcacqg2b4g24fvayulhgy4fjhflkifbj1duyqywekckaphq23xcshkscpd8vmiyervhkuuosq85sgzz3pmeqlrylfyki7rmc4cxgmyjpdsbaylezhww8zdpfwmcbuhywia3wlwxod3je6edgykjhmiuhmmmtwhbu1cbk5uvjnivspyihjdinbjm9cgpphrjmcrojinywspyehljlkkujvvorzydzuvjwq5cilcbl+bzcqhicshmwpcrys9awjctgyekpdqpqfiacjgjgykbbmib1foioao7og6xswugy3vrf4gg0cdmho9xmtlajhvpjwmcbdz0kibcoqmsnsh1br6hmwsuyayx+jf1hdwydqy0f+efjromcygon/qogkpgimwgedhoqqnmyhucwwamdhqjroqpibi8pu5ugnu3cwqjomrymbkvxygalyynuhyq7cqnk0kycus5bg7j5dcvstirrutc1gjgodysa53fkewtlydshl1mfacrxpeikezifjzdbc9e+aaqbq99bnoprhraaaaabjru5erkjggg==
what problem in conversion ? thank !
public static string encodetobase64(bitmap image) { bitmap immagex=image; bytearrayoutputstream baos = new bytearrayoutputstream(); immagex.compress(bitmap.compressformat.png, 100, baos); byte[] b = baos.tobytearray(); string imageencoded = base64.encodetostring(b,base64.default); return imageencoded; } public static bitmap decodebase64(string input) { byte[] decodedbyte = base64.decode(input, 0); return bitmapfactory.decodebytearray(decodedbyte, 0, decodedbyte.length); }
Comments
Post a Comment