• <i id='Y7nal'><tr id='Y7nal'><dt id='Y7nal'><q id='Y7nal'><span id='Y7nal'><b id='Y7nal'><form id='Y7nal'><ins id='Y7nal'></ins><ul id='Y7nal'></ul><sub id='Y7nal'></sub></form><legend id='Y7nal'></legend><bdo id='Y7nal'><pre id='Y7nal'><center id='Y7nal'></center></pre></bdo></b><th id='Y7nal'></th></span></q></dt></tr></i><div id='Y7nal'><tfoot id='Y7nal'></tfoot><dl id='Y7nal'><fieldset id='Y7nal'></fieldset></dl></div>
      <bdo id='Y7nal'></bdo><ul id='Y7nal'></ul>

      <legend id='Y7nal'><style id='Y7nal'><dir id='Y7nal'><q id='Y7nal'></q></dir></style></legend>

      <small id='Y7nal'></small><noframes id='Y7nal'>

    1. <tfoot id='Y7nal'></tfoot>
      1. Android中base64字符串编码和解码位图对象

        Encode and decode bitmap object in base64 string in Android(Android中base64字符串编码和解码位图对象)
          <bdo id='M6dYg'></bdo><ul id='M6dYg'></ul>
          <tfoot id='M6dYg'></tfoot>
          1. <legend id='M6dYg'><style id='M6dYg'><dir id='M6dYg'><q id='M6dYg'></q></dir></style></legend>

                <tbody id='M6dYg'></tbody>

            • <i id='M6dYg'><tr id='M6dYg'><dt id='M6dYg'><q id='M6dYg'><span id='M6dYg'><b id='M6dYg'><form id='M6dYg'><ins id='M6dYg'></ins><ul id='M6dYg'></ul><sub id='M6dYg'></sub></form><legend id='M6dYg'></legend><bdo id='M6dYg'><pre id='M6dYg'><center id='M6dYg'></center></pre></bdo></b><th id='M6dYg'></th></span></q></dt></tr></i><div id='M6dYg'><tfoot id='M6dYg'></tfoot><dl id='M6dYg'><fieldset id='M6dYg'></fieldset></dl></div>

                • <small id='M6dYg'></small><noframes id='M6dYg'>

                • 本文介绍了Android中base64字符串编码和解码位图对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我想对字符串 base64 中的 Bitmap 对象进行编码和解码.我用的是Android API10,

                  I want to encode and decode Bitmap object in string base64. I use the Android API10,

                  我尝试使用这种形式的方法来编码 Bitmap,但没有成功.

                  I have tried, with no success, to use a method in this form to encode a Bitmap.

                  public static String encodeTobase64(Bitmap image) {
                      Bitmap immagex=image;
                      ByteArrayOutputStream baos = new ByteArrayOutputStream();  
                      immagex.compress(Bitmap.CompressFormat.JPEG, 100, baos);
                      byte[] b = baos.toByteArray();
                      String imageEncoded = Base64.encodeToString(b,Base64.DEFAULT);
                  
                      Log.e("LOOK", imageEncoded);
                      return imageEncoded;
                  }
                  

                  推荐答案

                  public static String encodeToBase64(Bitmap image, Bitmap.CompressFormat compressFormat, int quality)
                  {
                      ByteArrayOutputStream byteArrayOS = new ByteArrayOutputStream();
                      image.compress(compressFormat, quality, byteArrayOS);
                      return Base64.encodeToString(byteArrayOS.toByteArray(), Base64.DEFAULT);
                  }
                  
                  public static Bitmap decodeBase64(String input)
                  {
                      byte[] decodedBytes = Base64.decode(input, 0);
                      return BitmapFactory.decodeByteArray(decodedBytes, 0, decodedBytes.length);
                  }
                  

                  示例用法:

                  String myBase64Image = encodeToBase64(myBitmap, Bitmap.CompressFormat.JPEG, 100);
                  Bitmap myBitmapAgain = decodeBase64(myBase64Image);
                  

                  这篇关于Android中base64字符串编码和解码位图对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  quot;No visible @interface for #39;NSData#39; declares the selector #39;base64EncodedStringquot; error in MKStoreKit(“‘NSData’没有可见的@interface 声明选择器‘base64EncodedString’MKStoreKit 中的错误)
                  How can I use CClistview in COCOS2d Android?(如何在 COCOS2d Android 中使用 CClistview?)
                  cocos2d-android: how to display score(cocos2d-android:如何显示分数)
                  Sqlite database not copied from asset folder Android(Sqlite 数据库未从资产文件夹 Android 复制)
                  SQLite Database Copy Appears Corrupted When Generated by Device and not Emulator(SQLite 数据库副本在由设备而不是模拟器生成时出现损坏)
                  Android file copy(安卓文件拷贝)
                  <legend id='lmBuw'><style id='lmBuw'><dir id='lmBuw'><q id='lmBuw'></q></dir></style></legend>
                • <small id='lmBuw'></small><noframes id='lmBuw'>

                      <tbody id='lmBuw'></tbody>
                        <tfoot id='lmBuw'></tfoot>
                          <bdo id='lmBuw'></bdo><ul id='lmBuw'></ul>

                          <i id='lmBuw'><tr id='lmBuw'><dt id='lmBuw'><q id='lmBuw'><span id='lmBuw'><b id='lmBuw'><form id='lmBuw'><ins id='lmBuw'></ins><ul id='lmBuw'></ul><sub id='lmBuw'></sub></form><legend id='lmBuw'></legend><bdo id='lmBuw'><pre id='lmBuw'><center id='lmBuw'></center></pre></bdo></b><th id='lmBuw'></th></span></q></dt></tr></i><div id='lmBuw'><tfoot id='lmBuw'></tfoot><dl id='lmBuw'><fieldset id='lmBuw'></fieldset></dl></div>