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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T11:15:02+00:00 2026-05-31T11:15:02+00:00

I Have Some static images like below: Now, I want is, when i touch

  • 0

I Have Some static images like below:

enter image description here

Now, I want is, when i touch on the face or hand, then the selected color should be fill on that skin portion.

See below image of result:

enter image description here

So how to get the result like above ??
Redo and Undo Functionality Should be also there.

I have try with the FloodFill color but doing that i can only able to do color in to the perticular portion. as FloodFill only fill the color till the same pixwl color comes. If the touch place pixel color get change the it will not fill color on it.

So Usinf FloodFill i got the result like below image, If i press on the hand, then only hand portion will fill with color, instead of it i want to fill color to the other hand and face also.
enter image description here

So Please help me in this case.

EDITED

After some reply i got the solution like this one.

But still there is a memory issue. It consume lots of memory to draw the color. So please can anyone help me for it ?

  • 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-31T11:15:03+00:00Added an answer on May 31, 2026 at 11:15 am

    You can have a complete image colored the actual way and when you fill a certain region with a color, it will replace all the regions that is specified by that color to be filled in.

    Layman’s terms:

    1. User will click on the hand of the OUTLINE
    2. That click location will be checked with another image with perfectly color coded regions. Lets call it a MASK for this case. All the skin regions will have the same color. The shirt areas will be another color.
    3. Wherever the user clicks, the selected color by the user will be applied to every pixel that has that similar color in the MASK, but instead of painting directly on the MASK, you paint onto the pixels of the the OUTLINE.

    I hope this helps.

    Feel free to comment if you want an example and then I can update the answer with that, but I think you can get it from here.

    EDIT:

    Basically start off with a simple image like this. This we can call as OUTLINE

    Simple image

    Then as the developer, you have to do some work. Here, you color code the OUTLINE. The result we call a MASK. To make this we, color code the regions with the same color that you want. This can be done on paint or whatever. I used Photoshop to be cool lol :D.

    Mask

    Then there is the ALGORITHM to get it working on the phone. Before you read the code, look at this variable.

    int ANTILAISING_TOLERANCE = 70; //Larger better coloring, reduced sensing
    

    If you zoom up on the image specifically noting the black regions of the border, you can actually see that sometimes, the computer blends the colors a little bit. In order to account for that change, we use this tolerance value.

    COLORINGANDROIDACTIVITY.JAVA

    package mk.coloring;
    
    import android.app.Activity;
    import android.graphics.Bitmap;
    import android.graphics.Bitmap.Config;
    import android.graphics.BitmapFactory;
    import android.graphics.Canvas;
    import android.os.Bundle;
    import android.view.MotionEvent;
    import android.view.View;
    import android.widget.ImageView;
    import android.view.View.OnTouchListener;
    
    public class ColoringAndroidActivity extends Activity implements OnTouchListener{
        /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        findViewById(R.id.imageView1).setOnTouchListener(this);
    }
    
    int ANTILAISING_TOLERANCE = 70;
    public boolean onTouch(View arg0, MotionEvent arg1) {
        Bitmap mask = BitmapFactory.decodeResource(getResources(), R.drawable.mask);
        int selectedColor = mask.getPixel((int)arg1.getX(),(int)arg1.getY());           
        int sG = (selectedColor & 0x0000FF00) >> 8;
        int sR = (selectedColor & 0x00FF0000) >> 16;
        int sB = (selectedColor & 0x000000FF);
    
        Bitmap original = BitmapFactory.decodeResource(getResources(), R.drawable.empty);       
        Bitmap colored = Bitmap.createBitmap(mask.getWidth(), mask.getHeight(), Config.ARGB_8888);
        Canvas cv = new Canvas(colored);
        cv.drawBitmap(original, 0,0, null);
    
        for(int x = 0; x<mask.getWidth();x++){
            for(int y = 0; y<mask.getHeight();y++){
                int g = (mask.getPixel(x,y) & 0x0000FF00) >> 8;
                int r = (mask.getPixel(x,y) & 0x00FF0000) >> 16;
                int b = (mask.getPixel(x,y) & 0x000000FF);
                if(Math.abs(sR - r) < ANTILAISING_TOLERANCE && Math.abs(sG - g) < ANTILAISING_TOLERANCE && Math.abs(sB - b) < ANTILAISING_TOLERANCE)
                    colored.setPixel(x, y, (colored.getPixel(x, y) & 0xFF000000) | 0x00458414);
            }
        }
        ((ImageView)findViewById(R.id.imageView1)).setImageBitmap(colored);
    
        return true;
    }
    

    }

    This code doesn’t provide the user with much of color choices. Instead, if the user touches a region, it will look at the MASK and paint the OUTLINE accordingly. But, you can make really interesting and interactive.

    RESULT

    When I touched the man’s hair, it not only colored the hair, but colored his shirt and hand with the same color. Compare it with the MASK to get a good idea of what happened.

    Result

    This is just a basic idea. I have created multiple Bitmaps but there is not really a need for that. I had used it for testing purposes and takes up unnecessary memory. And you don’t need to recreate the mask on every click, etc.

    I hope this helps you 😀

    Good luck

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

Sidebar

Related Questions

I have some static images in a folder on my IIS 6-based website that
I have some static resources (images and HTML files) that will be localized. One
I have some code that looks like: static const std::string and( AND ); This
I have some static text that needs to show up at 2 locations within
I have a windows forms application, where I have declared some static variables. On
I have some code where I use a thread static object in C#. [ThreadStatic]
I have some code shared among multiple projects in a static library. Even with
I have a web application (.war) that contains some static files (e.g. MS word
Suppose I have some per-class data: (AandB.h) class A { public: static Persister* getPersister();
Let's say I have some Java code: public class SomeClass { static { private

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.