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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T02:48:41+00:00 2026-05-24T02:48:41+00:00

I have a bitmap on which I’m trying to write a text using canvas.After

  • 0

I have a bitmap on which I’m trying to write a text using canvas.After setting the bitmap in a canvas and doing the necessary operations(writting a text on the canvas), I draw the resulting canvas on a ImageView.The big problem is that there is no image displayed…the screen turns black.Now, I know that the bitmap is returned ok because I displayed right before doing the canvas operations.

So,here is how I did it:

                     image= (ImageView) findViewById(R.id.imageview);
                    bitmap = android.provider.MediaStore.Images.Media
                       .getBitmap(cr, selectedImage);
                      int heightOfOld=bitmap.getHeight();
                      int widthOfOld=bitmap.getWidth();
                       android.graphics.Bitmap.Config hasAlpha=bitmap.getConfig();

                       Bitmap bitmapResult=bitmap.createBitmap(widthOfOld, heightOfOld, hasAlpha);
                       Canvas c=new Canvas(bitmapResult);
                       Canvas c1=drawTextImage(c);
                       image.draw(c1);

And here is the method used for drawing text on the canvas:

                  private Canvas drawTextImage(Canvas c){
                       Paint paint=new Paint();
                       paint.setColor(Color.BLUE);
                       paint.setStyle(Paint.Style.FILL);
                       paint.setAntiAlias(true);
                       paint.setTextSize(20);
                       c.drawText("Golden Stag", 30, 200, paint);
                       return c;
                       }

Could someone tell me where is the problem,please!?

  • 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-05-24T02:48:45+00:00Added an answer on May 24, 2026 at 2:48 am

    Since the documentation for draw(Canvas) says:

    “Manually render this view (and all of its children) to the given Canvas.”

    Maybe try with:

    image.setImageBitmap(bitmapResult);
    

    “Sets a Bitmap as the content of this ImageView.”

    Update: Example
    I think this should work (can’t test it though):

    image = (ImageView) findViewById(R.id.imageview);
    bitmap = android.provider.MediaStore.Images.Media.getBitmap(cr, selectedImage);
    
    Canvas c = new Canvas(bitmap);
    drawTextImage(bitmap);
    image.setImageBitmap(bitmap);
    
    private Canvas drawTextImage(Bitmap b){
        Canvas c = new Canvas(b);
        Paint paint = new Paint();
        paint.setColor(Color.BLUE);
        paint.setStyle(Paint.Style.FILL);
        paint.setAntiAlias(true);
        paint.setTextSize(20);
        c.drawText("Golden Stag", 30, 200, paint);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to serialize a class in which I have a bitmap variable. Here
I have a bitmap that has greater dimensions than the canvas to which it
I have an android program which draws lines and text to a canvas. (These
I have a 2D bitmap-like array of let's say 500*500 values. I'm trying to
I have a chart (in bitmap format) that I'm trying to render to a
I am using GDI+ Bitmap class to convert an IStream to HBITMAP. I have
I have a bitmap font which which doesn't have every single character, such as
I have a bitmap object which is taking a huge part of the memory
Let's say I have a small bitmap which contains a single digit (0..9) in
I have a 1000x1500 pixel bitmap of which I want to make a mutable

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.