Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7994481
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T14:08:39+00:00 2026-06-04T14:08:39+00:00

I am trying to show a img in Base64 with Html.fromHtml I have a

  • 0

I am trying to show a img in Base64 with Html.fromHtml

I have a tag with Base64 string of one image.

That is my code:

public class GlossaryAdapter extends BaseAdapter{

    ...
    private Resources res;

    public GlossaryAdapter(Context context, ...) {
        this.res = context.getResources();
        ...
    }

    public View getView(int position, View convertView, ViewGroup arg2) {
        ...
        holder.tvContent.setText(Html.fromHtml(glossary.getContent(), new Html.ImageGetter() {
        @Override
        public Drawable getDrawable(String source) {            
                try {
                     byte[] data;
                     data = Base64.decode(source,Base64.DECODE);
                     Bitmap bitmap = BitmapFactory.decodeByteArray(data, 0, data.length);    
                     return new BitmapDrawable(res, bitmap);
                } catch (IOException e) {
                    e.printStackTrace();
                    return null;
                }
            }
        }, null));

glossary.getContent() contains:

<img src="AAAY5671NF..." />

I tested this string in a html page and works. Show the image.

I am using Android 1.6.
And this Base64 class: http://androidcodemonkey.blogspot.com/2010/03/how-to-base64-encode-decode-android.html

I got no errors. But nothing is showing.
If I change the return to ‘null’ I got a small gray square.

any ideas?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T14:08:41+00:00Added an answer on June 4, 2026 at 2:08 pm

    After a long time…
    get imageBytes(BLOB) from db.
    Enconde to Base64 and pass to src.
    Decode and set bounds of bitmap.
    Works!

    @Override
        public Drawable getDrawable(String source) {            
                try {
                     byte[] data;
                     data = Base64.decode(source,Base64.DECODE);
                     Bitmap bitmap = BitmapFactory.decodeByteArray(data, 0, data.length);    
                     Drawable d = new BitmapDrawable(res, bitmap);
                     d.setBounds(0,0,72,72)   // <-----
                     return d;
                } catch (IOException e) {
                    e.printStackTrace();
                    return null;
                }
            }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to use jQuery to show an image that I have set to
I am trying to show an image by doing the following: <img class=header src=banner.png></img>
I am trying to show only elements that have the title attribute passed to
I have this jQuery code: <script type=text/javascript> $(function() { $(.one-edition img).hover(function() { $(this).next(.editions-info-text).show(); },
i'm trying to show image with grayscale-filter. Here is my code: $images = glob('gallery/*small*');
i have a problem trying to show an image in an AlertDialog with a
I am trying to get some JavaScript to programmatically adjust a HTML img tag's
I am trying to show some random images in a div. My HTML code
I have been trying to create a code like this: If you show 'us.gif'
I am trying to show some static Images from the Folder using img tag

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.