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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T03:02:35+00:00 2026-05-27T03:02:35+00:00

I am using this demo to imnplement the paint in my application. This Demo

  • 0

I am using this demo to imnplement the paint in my application. This Demo.

Now i want Image as a Background of the paint. after that the paint done on that image should be erased as like the it has functionality right now for paint. And while i save that image then it should be save with that Image.

So What should i have to do for that ??

Updated:
Save code:

 case PHOTO_SAVE:
            final Activity currentActivity  = this;
            Handler saveHandler = new Handler(){
                @Override
                public void handleMessage(Message msg) {
                    final AlertDialog alertDialog = new AlertDialog.Builder(currentActivity).create();
                    alertDialog.setTitle("Drawing App");
                    alertDialog.setMessage("Your drawing is saved. :)");
                    alertDialog.setButton("OK", new DialogInterface.OnClickListener() {
                        public void onClick(DialogInterface dialog, int which) {
                            return;
                        }
                    });
                    alertDialog.show();
                }
            } ;
            System.out.println("1");
           new ExportBitmapToFile(this,saveHandler, mBitmap).execute();
           System.out.println("2");
           return true;

And the ExportBitmapToFile class is:

private class ExportBitmapToFile extends AsyncTask<Intent,Void,Boolean> {
    private Context mContext;
    private Handler mHandler;
    private Bitmap nBitmap;
    private ProgressDialog  m_progressDialog = null; 
    @Override     
    protected void onPreExecute(){         
        m_progressDialog = new ProgressDialog(mContext);  
        m_progressDialog.setTitle("Drawing App");
        m_progressDialog.setMessage("Please wait...");
        m_progressDialog.setCancelable(false);         
        m_progressDialog.show();     
        System.out.println("3");
    }

    public ExportBitmapToFile(Context context,Handler handler,Bitmap bitmap) {
        mContext = context;
        nBitmap = bitmap;
        mHandler = handler;
    }

    @Override
    protected Boolean doInBackground(Intent... arg0) {
        try {
            if (!APP_FILE_PATH.exists()) {
                APP_FILE_PATH.mkdirs();
            }
            System.out.println("4");
            final FileOutputStream out = new FileOutputStream(new File(APP_FILE_PATH + "/"+filename+".jpg"));
            nBitmap.compress(Bitmap.CompressFormat.JPEG, 100, out);
            System.out.println("5");
            out.flush();
            out.close();
            return true;
        }catch (Exception e) {
            e.printStackTrace();
        }
        //mHandler.post(completeRunnable);
        return false;
    }

    @Override
    protected void onPostExecute(Boolean bool) {
        super.onPostExecute(bool);
        if ( bool ){
            mHandler.sendEmptyMessage(1);
        }
        if (m_progressDialog.isShowing()) {             
            m_progressDialog.dismiss();          
        }         
    }
}
  • 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-27T03:02:36+00:00Added an answer on May 27, 2026 at 3:02 am

    A Small Change.

            @Override
            protected void onSizeChanged(int w, int h, int oldw, int oldh) {
                super.onSizeChanged(w, h, oldw, oldh);
                mBitmap = Bitmap.createScaledBitmap(mBackground, w, h, true);
                mCanvas = new Canvas(mBitmap);
            }
    

    where mBackground is a Bitmap you initialize in the Constructor of MyView.

    I’m pretty sure, that should do, if you have any problems do report back.

    Update : See Comments

    In That Case, forget the above changes, and modify the onDraw Method like this.

      @Override
        protected void onDraw(Canvas canvas) {
            canvas.drawColor(0xFFAAAAAA);
            canvas.drawBitmap(mBackground, 0, 0, mBitmapPaint); //Make sure mBackground is the same size as the view. 
            canvas.drawBitmap(mBitmap, 0, 0, mBitmapPaint);
    
            canvas.drawPath(mPath, mPaint);
        }
    

    While saving, You’ll have to overlay both Bitmaps onto a new Bitmap Object and then finally write it to disk.

    To Overlap both Bitmaps,

    private Bitmap overlay(Bitmap bmp1, Bitmap bmp2) { //code borrowed from stackoverflow question 1540272
            Bitmap bmOverlay = Bitmap.createBitmap(bmp1.getWidth(), bmp1.getHeight(), bmp1.getConfig());
            Canvas canvas = new Canvas(bmOverlay);
            canvas.drawBitmap(bmp1, new Matrix(), null); // or use the other overloaded functions
            canvas.drawBitmap(bmp2, new Matrix(), null);
            return bmOverlay;
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hoping that using something like this demo it is possible to drag items within
I'm sure you've all seen this demo of image replacement using this : $(#largeImg).attr({
I've created this basic 3D Demo using OpenGL/SDL. I handled the keyboard callback so
I modeled my game after the Lunar Lander demo that Google provides, and it
Hiya guys heres my question: im using mootools and im using this demo-> Drag.Move
I have added a label to the jquery ui progressbar using this demo .
I am using this link from Oleg and Demo to create context menu. Is
well im using this script right here: http://www.kelvinluck.com/assets/jquery/datePicker/v2/demo/ and I have a multiMonth plugin
Using this question as the base is there an alogrithm or coding example to
Using this file as source, I have a situation where I need to retrieve

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.