How to change the color of same coloured sections of an image according to the colorpicker..?

Hi.. How r u all..?
I'm doing a small program to change the color of those sections of an image which are having the same color, according to the color selected from the colorpicker..
Say we have selected a color from the colorpicker, and then the mouseclick event on the image changes the color of those parts in the image which are having the same color as the clicked portion (or pixel) to the selected color.. If we've selected FF0000 from the colorpicker, then clicked on 3300CC coloured pixel in the image. This should change the color of all the 3300CC coloured pixels in the image..
I've a colorpicker [colpickr] and a movieclip [mc] of the image on the stage. I created a bitmap of that same same image (imag1) using code. Selecting the color from the colorpicker and a mouse click on the movieclip (here I used getPixel) will change that color in the bitmap to the selected color (with setPixel). So here I've two images; one is a movieclip (inorder to add listener for click event) and one is a bitmap (inorder to set the property setPixel). But I need only a single image.
Please help me regarding this.. Given below is my (horrible) code..
import flash.events.MouseEvent;
import flash.display.Bitmap;
import flash.display.BitmapData;
import flash.net.URLRequest;
import flash.display.Loader;
var c = 0;
var myBitmapData:BitmapData;
var bm:Bitmap;
colpickr.selectedColor = 0xffffff;
var preLoader;
var urlReq;
var preloader_img:MovieClip;
preLoader =new Loader();
preLoader.unloadAndStop();
urlReq = new URLRequest("imag1.jpg"); // i've selected the same image as that of movieclip mc
preLoader.load(urlReq);
preLoader.contentLoaderInfo.addEventListener(Event.COMPLETE,preLoaderComplete);
//creates a bitmap image of mc..
function preLoaderComplete(loadEvent:Event) {
    myBitmapData = new BitmapData(mc.width,mc.height);
    myBitmapData.draw(mc);
    bm = new Bitmap(myBitmapData);
    addChild(bm);
    bm.width = mc.width;
    bm.height = mc.height;
mc.addEventListener(MouseEvent.CLICK, _onMouseClick);
//gets the color of mc and sets the color to bitmap
function _onMouseClick(event:MouseEvent):void {
    var myColor:uint = myBitmapData.getPixel(mc.mouseX,mc.mouseY);
    c = myColor.toString(16);
    for (var i=0; i<bm.width; i++) {
        for (var j=0; j<bm.height; j++) {
            if (myBitmapData.getPixel(i,j).toString(16) == c) {
                myBitmapData.setPixel(i,j,colpickr.selectedColor);

try this:
import flash.events.MouseEvent;
import flash.display.Bitmap;
import flash.display.BitmapData;
import flash.net.URLRequest;
import flash.display.Loader;
var c=0;
var myBitmapData:BitmapData;
var bm:Bitmap;
colpickr.selectedColor=0xffffff;
var preLoader;
var urlReq;
var preloader_img:MovieClip;
preLoader =new Loader();
preLoader.unloadAndStop();
urlReq=new URLRequest("z_bitmaps/image1.jpg");// i've selected the same image as that of movieclip mc
preLoader.load(urlReq);
preLoader.contentLoaderInfo.addEventListener(Event.COMPLETE,preLoaderComplete);
//creates a bitmap image of mc..;
function preLoaderComplete(loadEvent:Event) {
    bm = Bitmap(loadEvent.target.loader.content);
    addChild(bm);
stage.addEventListener(MouseEvent.CLICK, f);
function f(e:MouseEvent):void{
    if(bm.hitTestPoint(mouseX,mouseY) && !colpickr.hitTestPoint(mouseX,mouseY)){
        _onMouseClick(e);
//gets the color of mc and sets the color to bitmap
function _onMouseClick(event:MouseEvent):void {
    c=bm.bitmapData.getPixel(bm.mouseX,bm.mouseY);
    for (var i=0; i<bm.width; i++) {
        for (var j=0; j<bm.height; j++) {
            if (bm.bitmapData.getPixel(i,j)==c) {
                bm.bitmapData.setPixel(i,j,colpickr.selectedColor);

Similar Messages

  • I can't figure out how to change a color photo to grayscale/black in InDesign so that we can do a separation that keeps the photos only on the black separation.

    I can't figure out how to change a color photo to grayscale/black in InDesign so that we can do a separation that keeps the photos only on the black separation.

    Yes, I can view/hide the OSK with no problem but the keyboard, itself, changed somehow.

  • How to change background color in online editor

    How to change background color in online editor

    Jeff,
    if you try to change all the plsql keywords to the same background color (that is not either white or black or blue) via the options panel in SQL Developer (Code Editor > PLSQL syntax colors), you will get the new background color in the worksheet only for the areas with plsql text, while the areas without any text will have the same background color as the base color scheme you started with. This means that there is no way to change the "general background" color via the options panel, but you have to use the same background color of one of the predefined color schemes.
    This seems to me a bug, but probably it's not considered high priority, so it will not be fixed for the time being.
    I would like to stress the fact that being able to change the color scheme of the development environment that you use every day about 8 hours a day can make quite a difference on your eyes at the end of the day.
    Thanks,
    Paolo

  • How to change front color in Visual composer

    Dear friend,
    i am taking numerical expression box into visual composer table view
    and try to change the front color in style tab for that field property
    but front color is  not changing in output(back ground color is changing ).
    how to change front color in visual composer?
    and can we change the symbol color too?
    thanks and regards,
    dushyant.

    Hi Vani!
    1. Unfortunately one of my requirements is that I can only get data from queries and not from Web Services or other sources, so no WS calling would be allowed in my deployed I-View, but thanks anyway for your suggestion.
    2. You are right, I was not clear enough in my first post. Let's say I have 3 rows and 12 columns, what I want is the following:
    ROW3 = ROW1 / ROW2
    obviously for each column. Do you have an idea about how it could be done??
    Thanks a lot,
    Andrea

  • How to change background color of multilevel textbox in oracle form 6i

    hi
    How To Change background Color of the Text.
    In One Multilevel Block 10 Record is Display At a Time in a Text Box (Name is AMTt)
    This Text Box display , Buffer and Record Length is 10
    In Case Of Amount is Less 500 then Text Color Is Red(Or Any) and In Case Amount Is More 500 Then Color is Green (Or Any).
    Me Use This Code in PRE_RECORD EVENT
    TCMTL is Block name
    TCMTL_AMT is Text Box Name
    if :TCMTL.TCMTL_AMT >5000 then
         g_fun.msgbox('Values is more');
         Set_Item_Property('TCMTL_AMT' , BACKGROUND_COLOR, 'r50g100b100');
    else
         g_fun.msgbox('Values is Less');
         Set_Item_Property('TCMTL_AMT' , BACKGROUND_COLOR, 'r50g100b10');
    end if;     
    but This Code Is Refer Only 10th Value and change color depend on value.
    so
    possible to Different color in One Block Text Box Then how?

    DECLARE
         cur_itm VARCHAR2(80);
         cur_block VARCHAR2(80) := Name_in('system.trigger_block') ;
         BEGIN
         cur_itm := Get_Block_Property( cur_block, FIRST_ITEM );
    WHILE ( cur_itm IS NOT NULL ) LOOP
              cur_itm := cur_block||'.'||cur_itm;
              --:global.VISUAL_ATTRIBUTE:= 'BACKGROUND_COLOR';
              --:global.VISUAL_ATTRIBUTE:= get_item_property(cur_block||'.'||cur_itm ,Background_Color);
              IF :TCMTL.TCMTL_AMT >= 500 THEN
                             Set_Item_Instance_Property( cur_itm, CURRENT_RECORD, VISUAL_ATTRIBUTE,'r50g100b100');
                   ELSE
                             Set_Item_Instance_Property( cur_itm, CURRENT_RECORD, VISUAL_ATTRIBUTE,'r5g100b10');
                   END IF;
                             cur_itm := Get_Item_Property( cur_itm, NEXTITEM );
                   END LOOP;
                   next_record;
    END;
    this is my in that how to set a VISUAL_ATTRIBUTE, and where to set so get a background color of text and change

  • In elements 10 how to change screen color around photograph being worked on?

    In elements 10 how to change screen color around photograph being worked on?

    If you mean just the background of the tab or image window, right click it and choose what you want. If you mean for the whole program, no can do, sorry.

  • TS3999 When using iCloud Calendar, I am unable to change the color of my work calendar. I have successfully followed the instructions to reset the colors of other calendars as desired. However, this one calendar always defaults to purple.  Help!

    When using iCloud Calendar, I am unable to change the color of my work calendar. I have successfully followed the instructions to reset the colors of other calendars as desired. However, this one calendar always defaults to purple.  Help!

    File>New Calendar to create a new calendar (Groups are for grouping calendars and I should ignore them). When you've created the calendar, control-click on it in the sidebar and choose 'Get Info' There you can select a colour. You can have as many calendars as you like. When you create a new event you can select the calendar it belongs to, and hence the colour it has.

  • How to change background color in photoshop cs3

    how to change background color in photoshop cs3
    Please help me...

    Background for what? You need to explain better and be more specific.
    Mylenium

  • How to change a color for a row in ALV grid display

    Hi,
       how to change a color for a row in ALV grid display based on a condition.Any sample code plz

    Hello Ramya,
    Did you check in [SCN|How to color a row of  alv grid]
    Thanks!

  • Does anyone has a problem with the screen of the new ipad? (there's a part of the screen which the color in it is "very" bright) and when I move the aluminium part of the smart cover when it's attached to the ipad the colors change!! Help!!!

    Does anyone has a problem with the screen of the new ipad? (there's a part of the screen which the color in it is "very" bright) and when I move the aluminium part of the smart cover when it's attached to the ipad the colors change!! Help!!!

    I'd take it into my local APple store and have them look at it. There may be something wrong inside your device.

  • I am trying to change the color of a background layer and it will not accept the color I want

    I am trying to change the color of a background layer and it will not accept the color I want

    If you want to get help you may have to provide a lot more details about what you are doing (which tools or commands do you use, what exactly happens when it fails, …)?

  • How to change group colors

    How to change group color in ical

    To change group colors:
    highlight 'desired' group,
    under <Edit>, choose <Get Info>,
    this should give you a smaller window:
              'desired' Info
              Name: desired                    Box with color choices
                                                       (dropdown colors; 'other' accesses other color palettes)
              Description: (can be added)
              Box ' Ignore alarms'
              'Publish...'                    'Cancel'                    'OK'
       4. make color choice,
       5. choose <OK> to complete color change, or <Cancel> original color remains.
    I do hope I've gotten this correct.

  • How come the color of items in some MC can be edited whilst the colors of other MC can't

    How come the color of items in some MC can be edited whilst
    the colors of other MC can't. All layers are unlocked.

    Need more info - could be anything - maybe the object is a
    Drawing Object - or Grouped - or an
    instance of a symbol - or...?
    Chris Georgenes / mudbubble.com / keyframer.com / Adobe
    Community Expert
    nikos_golf wrote:
    > How come the color of items in some MC can be edited
    whilst the colors of other MC can't. All layers are unlocked.

  • How do i change the systems language of my mac. I had to change it into Chinese but now the Chinese guy is gone and I've no idea how to change it back to english because I don't understand any of the chinese writing

    how do i change the system language of my mac. I had to change it into Chinese. Since the Chinese guy is gone, I've no idea how to change it back into english. I don't understand any of the Chinese writing..

    You may find info from this article helpful.
    http://support.apple.com/kb/PH14211
    Best.

  • I have c-309g it will print all the colors expect pink , why is that ??? all the ink is new and full

    HP Photostat Premium C309-g
    Windows XP
    No Error Massage
    NO changes made to me system before the issue occurred
    just changed the ink for 2 colors blue and pink
    i have c-309g it will print all the colors expect pink , why is that ??? all the ink is new and full

    carrasso76,
    Here is a link to a print quality document that may help troubleshoot your issue.
    Once you go through all the steps if you still have the problem let us know.
    If I helped you at all it would be great if you clicked the blue kudos star!
    If I solved your post please mark it as solved to help others.
    I'm a printer tech with HP.

Maybe you are looking for