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 8664497
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T17:15:13+00:00 2026-06-12T17:15:13+00:00

I’m facing an problem, exporting a what was drawn on a view to a

  • 0

I’m facing an problem, exporting a what was drawn on a view to a base64 encoded PNG. I did a previous research and found those two topics heare on stackoverflow:

Android canvas to jpg

Encode and decode bitmap object in base64 string in Android

My problem is, that the when I decode the encoded String, my image displays only the about 15% of the image from the top.

My code looks as follows:

private void doMagic() {
    View paintview = findViewById(R.id.paintView1);
    Log.d(TAG, "width: " + paintview.getWidth() + " height:" + paintview.getHeight());
    Bitmap bitmap  = Bitmap.createBitmap(paintview.getWidth(), paintview.getHeight(), Bitmap.Config.ARGB_8888);
    Canvas canvas = new Canvas(bitmap);
    paintview.draw(canvas);
    encodeTobase64(bitmap);
}

public static String encodeTobase64(Bitmap image)
{
    Bitmap immagex=image;
    ByteArrayOutputStream baos = new ByteArrayOutputStream();  
    boolean result = immagex.compress(Bitmap.CompressFormat.PNG, 100, baos);
    byte[] b = baos.toByteArray();
    String imageEncoded = Base64.encodeToString(b,Base64.NO_WRAP);

    Log.d(TAG, ""+ result);
    Log.d(TAG, "baos: " + baos.size());
    Log.d(TAG, "b: " + b.length);
    Log.d(TAG, "imageEncoded: " + imageEncoded.length());
    Log.e(TAG, imageEncoded);
    return imageEncoded;
}

As for the logs:

  • the dimensions logged and of the decoded image are the same (the rest
    of the image is just white)
  • result is true
  • baos.size() == b.length == imageEncoded.length() * 6 / 8

here is the encoded String:

iVBORw0KGgoAAAANSUhEUgAAAyAAAAGACAYAAABV8wavAAAABHNCSVQICAgIfAhkiAAAIABJREFUeJzs3XfcFNX1x/EP0uyICEqxK2LHXkDFoNhr7MYWNWpiLFFji4m9997FboK9d7HXaAR7w4qCBRVRUYHfH2f3xz77zOxOudN2vu/XKy+e3Z25cyE+u3vm3HsOiEhYg4DPgX1jjDGvg3k8BeziYBw/M/o8/yQwOMJ4qwDPRZ+OlNTJwDfAIcDcEcdYCHgLONDVpGr8CejY5Jh9gRsSuHbVt0C3iOeuBxzv8XxH4BVg97rnO1Wut3DE6xXVYth/QyIiIqk7C/viP0+Gc5gFC4AGJXiNjYG1PJ7vASwVccwfsLmLhNUduAx4F9gyxjhnAg8BnV1MKqTtgQcSGntV4NkY5x8JnO3z2uXAhR7Pv4fdVCiT97FgVkREJBWzA58AB2Q8j2WxL/JJBkBHAHc5HvMOYFPHY0r5LALcgmXSvALkINYBfgE2czWpEIYBLyU09tHAv2Kcvz8W5HnZB3je4/nngI1iXLNozgX+mvUkRESkPFYC+mU8hy2B/yV8jX8DJzgec3/8766KRLEKMBK4h+gZuduBS1xNKIQVgDEJjf0c8bISewA3+ry2MvAbMFPd83eT7FLQPFkPuD/rSYiIiKTl79id36R0Ad4EtnE87lLAaMdj1o7dPaGxpRg2xP776hvx/D9hmc2lnc0omAWA73G/FGwOYELMMbbDPwPaEejv8fxw4KCY1y2KKcAMWU9CREQkaZcCpyQ4/krA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/oZ9MY/iz8AFNY/7AZ9EHOsEku06/hj2d/VTH

I don’t know what I’m doing wrong.

  • 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-12T17:15:16+00:00Added an answer on June 12, 2026 at 5:15 pm

    So eventually I figured out, what went wrong.

    Every thing I did was right. But the imageEncoded String which I logged to logcat was truncated. So only little more than 4000 characters of the Image where logged. For more information read this discussion.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've tracked down a weird MySQL problem to the two different ways I was
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have an MVC Razor view @{ ViewBag.Title = Index; var c = (char)146;
I am currently running into a problem where an element is coming back from
I have a view passing on information from a database: def serve_article(request, id): served_article
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
That's pretty much it. I'm using Nokogiri to scrape a web page what has

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.