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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T17:29:58+00:00 2026-05-23T17:29:58+00:00

Recently, I worked with a paint project. First of all ,I need to select

  • 0

Recently, I worked with a paint project. First of all ,I need to
select a color. When I touch the image then selected color will be
replaced with same color region of bitmap image. How I can recognize
the shape of same color region in the image.

Sincerely,

Habib

  • 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-23T17:29:58+00:00Added an answer on May 23, 2026 at 5:29 pm

    This code can be help full

    imageViewEdit.setOnTouchListener(new View.OnTouchListener() {
    
        @Override
        public boolean onTouch(View v, MotionEvent event) {
            setColor = newbitmap.getPixel((int)event.getX(),(int)event.getY());
            replaceX=(int)event.getX();
            replaceY=(int)event.getY();
    
            setColor_R = (setColor & 0x00ff0000) >> 16;
            setColor_G = (setColor & 0x0000ff00) >> 8;
            setColor_B = setColor & 0x000000ff;
    
            boolean[][] visited = new boolean[newbitmap.getWidth()][newbitmap.getHeight()];
    
    
            Queue<Pixel> pixel=new LinkedList<Pixel>();
            pixel.add(new Pixel(replaceX, replaceY));
    
            while(!pixel.isEmpty()){
    
                Pixel loc = pixel.remove();
                visited[loc._x][loc._y] = true;
    
                putIfValid(loc._x+1,loc._y-1,pixel,visited);
                putIfValid(loc._x+1,loc._y,pixel,visited);
                putIfValid(loc._x+1,loc._y+1,pixel,visited);
                putIfValid(loc._x-1,loc._y-1,pixel,visited);
                putIfValid(loc._x-1,loc._y,pixel,visited);
                putIfValid(loc._x-1,loc._y+1,pixel,visited);
                putIfValid(loc._x,loc._y+1,pixel,visited);
                putIfValid(loc._x,loc._y-1,pixel,visited);
            }
            imageViewEdit.setImageBitmap(newbitmap);
    
            return false;
        }
    
    
        public void putIfValid(int x, int y, Queue<Pixel> pixel, boolean[][] visited) {
    
                int colors=newbitmap.getPixel(x, y);
    
                int  current_R = (colors & 0x00ff0000) >> 16;
                int  current_G = (colors & 0x0000ff00) >> 8;
                int  current_B = colors & 0x000000ff;
    
                if(((setColor_R-RGBThreshold<=current_R) && (setColor_R+RGBThreshold>=current_R))
                  &&((setColor_G-RGBThreshold<=current_G)&&(setColor_G+RGBThreshold>=current_G))
                  &&((setColor_B-RGBThreshold<=current_B)&& (setColor_B+RGBThreshold>=current_B))
                  && valid(x,y,visited)){
    
                    pixel.add(new Pixel(x,y));
                    newbitmap.setPixel(x, y, getColor);
                    visited[x][y]=true;
                }
        }
    
        private boolean valid(int x, int y, boolean[][] visited) {
    
            return x >= 2 && x < (newbitmap.getWidth()-2)&&
                   y >= 2 && y < (newbitmap.getHeight()-2) &&
                   !visited[x][y];
        }
    });
    
    
    public static class Pixel {
        final public int _x;
        final public int _y;
        public Pixel(int x,int y){
            _x=x;
            _y=y;
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Recently, I have worked in a project were TDD (Test Driven Development) was used.
A .NET project I've worked on, has encountered a build error recently. The project
I recently worked on a .Net WPF project to build a retail point of
Having recently worked on a project which required some more IO interaction than I'm
I recently worked on a project on .NET and part of the code involved
I've recently worked on a project where every method contained a return code. Example:
I recently worked in a ipad project. I find no nib files in the
I recently worked with Hyper Terminal on windows 7 in which i access SMS
I've got a program that worked until recently. The offending code is shown here:
I recently upgraded MySQL to 5.1.41. Before the upgrade the following SQL worked (or

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.