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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T00:45:50+00:00 2026-06-10T00:45:50+00:00

I am writing a program in Monodroid to capture a signature on screen, then

  • 0

I am writing a program in Monodroid to capture a signature on screen, then save it to a jpg file. I can capture the signature fine, the problem comes when I try to save it to file. When the user wants to save the image, the below code runs:

 void buttonSave_Click(object sender, EventArgs e)
    {
        try
        {
            if (!m_locked)
            {

                MemoryStream stream = new MemoryStream();
                m_bitmap.Compress(Bitmap.CompressFormat.Jpeg, 100, stream);                                                                         
                byte[] byteArray = stream.GetBuffer();

                //string toSave = Convert.ToBase64String(byteArray);

                //save it to file (test);
                string path = "/mnt/sdcard/TestSig/";
                if (!Directory.Exists(path))
                    Directory.CreateDirectory(path);

                string file = path + "signature.jpg";


                FileOutputStream fo = new FileOutputStream(file);  

                fo.Write(byteArray);
            }
        }
        catch (Exception ex)
        {
            //display message
        }
    }

The ImageView that the signature is drawn onto is set up thus (in the activity’s OnCreate method):

       m_imageView = (ImageView)FindViewById(Resource.Id.imageView);

        m_imageView.SetBackgroundColor(Android.Graphics.Color.White);

        Display d = WindowManager.DefaultDisplay;

        m_dw = d.Width;
        m_dh = d.Height;
        m_bitmap = Bitmap.CreateBitmap((int)m_dw, (int)(m_dh * 0.5), Bitmap.Config.Argb8888);



        m_canvas = new Canvas(m_bitmap);
        m_paint = new Paint();
        m_paint.Color = Color.Black;
        m_imageView.SetImageBitmap(m_bitmap);


        m_imageView.SetOnTouchListener(this);

The problem is when I open the file in an image editor, all the dimensions are OK but it is completely black. It should look something like this:

Signature

By the way this seems to work OK when the png format is used. I am saving the image on an Android device but viewing it on a Windows PC.

Thanks.

  • 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-10T00:45:52+00:00Added an answer on June 10, 2026 at 12:45 am

    In your setup of m_imageView, enable the drawing cache (and set it’s background colour):

    m_imageView.DrawingCacheEnabled = true;
    m_imageView.DrawingCacheBackgroundColor = Color.White;
    

    Then fill the MemoryStream with the contents of the cache:

    m_imageView.GetDrawingCache(false).Compress(Bitmap.CompressFormatJpeg,100, stream);
    

    The call to .GetDrawingCache() will return a Bitmap of what you see inside m_imageView.

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

Sidebar

Related Questions

I'm writing a program that's parsing an XML file to java objects using smooks.
I'm writing a program that reads huge file (3x280 GB) and does a fitting
I am writing a program that creates an image file. I want the original
I am writing a program based on file. My code looks something like this,
I writing a program in Delphi 2010. Part of the program deals with File
I was writing a program for capturing the screen at a set interval and
I have tried writing program that plays a sound file but have been unsuccessful
Good day! I have met problem with synchronizing threads. I am writing program which
Im writing this program in C and Im having a big problem when I
I am writing program in Octave and I encountered a problem, I implemented Gauss-Legandre

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.