How To Change Pixel Color In Java



While you can change the progress bar value color in IE10, as far as I know it is impossible to apply a background image to it. Learn to relate the colors to points on a color wheel and points in a color cube. The colors on the chart matched almost perfectly with the colors produced by the calculator further down on this page. The RGB color model is an additive color model in which red, green and blue light are added together in various ways to reproduce a broad array of colors. create a variable to store the body object. When constructing a Color with an explicit alpha or getting the color/alpha components of a Color, the color components are never premultiplied by the alpha component. Java provides ImageIO class for reading and writing an image. If the method returns null or there is no such method, and the object is an instance of java. If value is 00 that means 100% transparent. NetObjects Website Design Software. The text in dark areas is white because I wrote the following property color: #fff. The paint () method for the applet simply draws 25 copies of the message. This page will let you enter in RGB values, and by pressing evaluate, see the correspinding hexadecimal and integer representations of the color. - I don't think you have control over the background color that IE6 uses when it can't read the alpha channel, so you'll need the extra javascript support. There are 2466 colour combinations with hex code #FFFFFF. Different places where JavaScript can be paced in HTML: JavaScript can be placed in various locations in HTML such as. How do i change the color of Image on my JComponent. and all are images(jpg) EX:Add User, Edit User, Remove user(all arebuttons) I have another set of images with different color. Color allows you to construct your own colors using RGB or HSB formats. We recently published a brand new website for our company, Mabiloft, with a completely redesigned clean layout and a lot of new gorgeous illustration and animations. Does not work with 16-bit and float images. Each pixel takes 4 elements in the array for red, green, blue, and alpha, for a total of 24 array elements, 0-23. Try clicking in the boxes, and then click here to bring things back to some semblance of normality (or click the button above). Those will display only after the mouse click. JavaScript: function changecolor(){ document. Change TextView Foreground Background Color Programmatically Example. For now, it doesn't work because the key and mouse bindings require reflection and applets think that allowing reflection would open a security hole. *; import java. Let Us know if there is a graphic you would like better in a different color, in most cases they are easy to change! Happy Shopping!. Want to change the color of your Google browser window? Learn how you can alter the colors of your Google background. Behind the scenes in the computer's memory, color is always talked about as a series of 24 bits (or 32 in the case of colors with an alpha). (Drag it to the root of this example’s project folder. js you can easily work with the colors of individual pixels of Raster items. if you set this to “none” it will return to the standard margin. How to change the color of Google Maps markers with JavaScript. In the following lesson we are going to follow that up with different kinds of effects specifically built for use with images. In the PPM file, each pixel is defined by a triplet of values representing how much red, green, and blue (RGB) are present. Here is a quick example of how you can change the background color of the cell of a table when the user mouses over that cell. If you simply blend the reference temperature color with the source image color, then yes – all values, including 6500 K, will result in changes. setStrokeColor() and roi. An image can have up to 56 channels. Highlight TextBox on focus using CSS and without any JavaScript or jQuery and set it back to default on blur TAGs: ASP. This wikiHow teaches you how to change the background color of a web page by editing its HTML. RGB color with ranges of 0 to 255 is not the only way you can handle color in Processing. Step 3: the relief. Also, there are a number of "color spaces" to choose from besides RGB for color traversal, which has to be considered. Indeed pixels are gradually getting smaller. However, at this point, all of your images will enlarge from the upper left corner to the lower right. cursor Assign one of the cursor properties to document. Change the Size of an Image for the screen You have a huge image, possibly from a digital camera, and you want to resize it so that it displays nicely on a web page, online board or email message. In this article, we are going to learn to change the button color using CSS, it can be done by two ways: 1) direct set the style properties on the tag, and 2) creating a CSS class and apply it on button. Below is example how to change image when user click on this image. This class has seven - number of constructor. Does not work with 16-bit and float images. Press and hold the left mouse button and move the mouse pointer to the pixel whose color you want to identify. How to Create a Solid-Color Fill Layer in Adobe Photoshop. Net, JavaScript, jQuery, CSS, HTML. I needed a way to test if a background color is light or dark in order to choose an appropriate text color (black on light colors and white on dark colors), you can find yourself in the same problem if you try to convert an image to grayscale. To navigate to the anchors, we’ll need to create a series of links in our html using the hashtag method at the beginning of this article. Re: How to change Image color like Channel mixer Michael L Hale May 14, 2009 3:18 PM ( in response to sunny cloudy ) Your code only converts the layer to B&W because the 3 arrays have the same value. Java has been one of the most popular programming language for many years. jpg“, convert it into byte array, and then reuse the converted byte array, and convert it back to a new BufferedImage, and save it back into a new name “new-darksouls. In the image processing domain, it is also known as an integral. Buttons can change color when a state changed (e. More than a HOWTO, this document is a HOW-DO-I use Python to do my image processing tasks. Color allows you to construct your own colors using RGB or HSB formats. You can select color from color palette. In this part of the Java 2D tutorial, we will work with texts and fonts. Displaying the Image on the Label. As such, we have a list of rules we expect all players to follow with no exceptions. While the traditional MS Paint program won't allow you to create a transparent image, you can create a green screen background by filling in your image with a solid color that can be replaced with a different image later. Average, Avg = (R+G+B)/3. Points exactly at the left (right) border are considered outside (inside); points exactly on horizontal borders are considered outside (inside) at the border with the lower (higher) y. It depends on how you implement the color blending. It doesn't have to be antything spectacular, it just has to be visible. For convert HEX to binary file please use hex2bin converter (this utility you can find by google), and next try to rename bin to jpeg. Edit the background color of javascript image gallery description jquery slides jquery slider galeria de imagenes html diaporama html5 Immagini Galleria 网络幻灯片: 效果的幻灯片 Galeria De Imagens слайдер изображений, слайдшоу, CSS слайдер Bild Galleri 画像のスライダー&ギャラリー. If I'm not mistaken, such a change wouldn't/shouldn't require a separate Chrome theme but is rather a simple setting that I'm just unable to find. CamanJS is very easy to extend with new filters and plugins, and it comes with a wide array of image editing functionality, which continues to grow. — Emily G over 9 years ago; in my IE6 your image, when embedded in a page displays with a grey background. Many times as a web designer I find that some of the colors in a photo are not suitable for use with a site’s color scheme. There are many utilities that you could create if you would be able to extract the color from a single pixel of a canvas, an interactive color picker etc. Back to Image ↑ java2s. How can i change the color of the image which i passed to this Image Object. That is, think of a pixel as a container for a very small dot of color, or said another way, a dot who’s only thing we care about is the color it contains. By continuing to use this website, you agree to their use. I'll cover the following topics in the code samples below: GraphicSetColorKey, ASP. Special Effects - Marquee Tag. It's a combination of a simple-to-use interface with advanced and efficient image/canvas editing techniques. Change - No Image Use this script to change the background image used in the page from a link. How to set background image to jFrame form in netbeans Posted by Arun Alande at 2:17 AM 3 comments Some times we get problem while customizing code. it also has a pause and play button. To blur the images pixels using tracking. If you simply blend the reference temperature color with the source image color, then yes – all values, including 6500 K, will result in changes. A value of a pixel is bounded below by 0 and above by 2^ (bit depth). Features The javascript function will change the image or picture when you focus your mouse cursor on the image. thehung1724. How to change image on hover with CSS. (Note that you can subclass java. We’ll also throw in a placeholder image just to give us a little more scrolling room. GREEN, Color. Digital image resolution unit conversion between dot/inch and pixel/inch, pixel/inch to dot/inch conversion in batch, dpi ppi conversion chart. Not the cells underneath, just the header block. Random class you need to create an instance of this class, while in case of Math. NET, Microsoft Office, Azure, Windows, Java, Adobe, Python, SQL, JavaScript, Angular and much more. When reading forums I've seen the question popup quite a lot that is; How do I change the CSS 'background-image' property using Javascript. Note: This material was originally published as part of the Opera Web Standards Curriculum, available as 48: Dynamic style - manipulating CSS with JavaScript, written by Greg Schechter. Know how to create different colors with Java AWT Color. The pixel is selected on the basis of specific criteria. How to create Black and White image from color image. Build on the work of others and share your creations, or start fresh and create something new. Controls which channels in a composite color image are displayed, where 'channels' is a list of ones and zeros that specify the channels to display. com | © Demo Source and Support. To change colors you change the color of your Graphics object. In this article, we will be using the forms collection of the document object and the elements collection of the form object to set the values of the form elements. The color you select fills the color swatch box, but the color doesn’t fill the background until you click the Apply or OK button. Updated July 13, 2019. Get the most out of Google with the latest additions to Search. Get Gadget Hacks on Facebook Twitter , Reddit , Pinterest , and Flipboard. When you click the Button the form will change its background color. Developed since 2006. Stoyan's phpied. In this example we iterate over all pixels to change their values, then we put the modified pixel array back to the canvas using putImageData(). How do i change every pixel of one color into another color. Introduction to CSS Media Queries. java file, then you can do it by using setBackgroundColor() method on your layout. If you head to Cortana - search bar on task bar - and type in Paint. With WOW Slider we've tried to create the perfect html slider that covers all these needs and even more:. The upper-left hand corner of the screen has an x coordinate of 0 and a y coordinate 0 ; thus x coordinates increase from left to right, and y coordinates increase from top to bottom (unlike our. That's right, placed by hand — I know this sounds a little crazy especially when some pixel scenes have thousands of pixels in them. If you want to use a solid color or choose colors manually, then select the left-most button (the button with a solid color/has no pattern). Please note that the top will be counted from the top of the document - not from the top of the window. Color allows you to construct your own colors using RGB or HSB formats. and all are images(jpg) EX:Add User, Edit User, Remove user(all arebuttons) I have another set of images with different color. Here's the HTML source for a page with a self-resizing background, and a link to download the resizing_background. If the property requires units other than px, convert the value to a string and add the appropriate units before calling the method. Changing this size means that the image will be re. The colors are generated with true randomness originating from atmospheric noise. In this project we will learn to convert a color image into its negative using Java programming language. Creating an HTML Marquee / Scrolling Text The HTML MARQUEE tag is used to scroll text vertically or horizontally within a web page. How to convert grayscale image to binary image in java? I am taking project from image processing area using java. In the following lesson we are going to follow that up with different kinds of effects specifically built for use with images. getElementById("div1". getRed, Color. Since Greenfoot 3. css() as a setter, jQuery modifies the element's style property. Now back to transparency. setColor () to select that color for drawing. Include the jQuery library and invertImgText. com | © Demo Source and Support. Change the Size of an Image for the screen You have a huge image, possibly from a digital camera, and you want to resize it so that it displays nicely on a web page, online board or email message. js JavaScript code that the page relies upon. and you want to match a font color to a color in your page. Erases the area outside the current image selection to the background color. Free Online Photo Editor. In the image processing domain, it is also known as an integral. I write programme to get image from window,then I want change hte color of the pixel before send to the slipboard. We will learn how to store pixel value in a variable. Welcome! Pyxel Edit is a pixel art editor designed to make it fun and easy to make tilesets, levels and animations. At this point, you have learned how to use text, fonts, color, lines, polygons, and sound in your Java programs. The color of each individual pixel is determined by the values stored in the three color bytes for that pixel. The background of the page will change to the color selected. For Tumblr, Facebook, Chromebook or WebSites. If your background image is dark, you can make light text viewable. I'll cover the following topics in the code samples below: GraphicSetColorKey, ASP. On this page we are calling a function from a text link. For each pixel in the PImage, retrieve the pixel's color and set the display pixel to that color. Can somebody please help me with it to find the errors. isReadable: Returns true if the Read/Write Enabled checkbox was checked when the texture was imported; otherwise returns false. Note: This material was originally published as part of the Opera Web Standards Curriculum, available as 48: Dynamic style - manipulating CSS with JavaScript, written by Greg Schechter. The setIconImage() method of Frame class is used to change the icon of Frame or Window. * Who you are:* 2 years of professional development in Java, C or Python. How to Create a Solid-Color Fill Layer in Adobe Photoshop. To adjust colors, select your video on the Video Track and click the Color Adjustments button as shown in the screen image. This means that as soon as the page has loaded the user can begin typing without having to click in the text field first. The plan is to start off with a very simple button and then to add functionality to the button a step at a time. On a Mac you would have to deselect "Transparent" for the color to stick. int r = color. It implements the basic alpha compositing rules for combining source and destination pixels to achieve blending and transparency effects with graphics and images. Lets say i had one specific color of white how could i change that into another color. Lots of filters and effects, easy to use, connects to Facebook, Twitter, WordPress. The Opacity field as shown in my answer above will give you the density of the shadow. From here, individual pixel can be accessed via the pixels array. There is no way to apply the theme to launchers that do not have the ability to change icons. Well organized and easy to understand Web building tutorials with lots of examples of how to use HTML, CSS, JavaScript, SQL, PHP, Python, Bootstrap, Java and XML. Touch-friendly With a built-in support for touch events, jscolor is designed to be easy to use on modern touch devices such as tablets and smartphones. In this tutorial, we are going to learn how to highlight or set RecycleView item row background color in android when clicked. JFrame color FAQ: How do I set the JFrame background color? In general, to set the JFrame background color, just call the JFrame setBackground method, like this: jframe. It is assumed that you have completed the projects titled How to read and write image file in Java and How to get and set pixel value in Java before starting this project. With WOW Slider we've tried to create the perfect html slider that covers all these needs and even more:. Remember, each pixel has a corresponding color value (red, green, and blue). You can add a background color or image to any HTML element pretty easily – all you need is the ID or class name of the element, and a basic understanding of the CSS background property OR you can go the faster and easier route with Layers Pro, which adds full Header and Title Banner customization which includes background images. In Android Programming Language Graphics provide very powerful functions by the help of which we can do many attractive work we can also design low level game for fun,So in this page we learn how we can change the color of any Image. When you click the Button the form will change its background color. While the code here still works in modern browsers, a new page shows you how to do this using style in JavaScript. If you need to, you can change this behavior in Edit→Options→Conversions. I'm so used to it being either transparent or at the very least borrowing from my current background color as it did in Windows 7 but there seems no way to change it in Windows 10. Java BufferedImage: How to get the RGB value of each image pixel | alvinalexander. It is assumed that you have completed the projects titled How to read and write image file in Java and How to get and set pixel value in Java before starting this project. getElementById("div1". Highlight TextBox on focus using CSS and without any JavaScript or jQuery and set it back to default on blur TAGs: ASP. Images, iframed or inline content etc. Demo Change Font Color JavaScript Red color yellow color green color blue color. The top hit is a tutorial on exactly how to do it in c# The top hit is a tutorial on exactly how to do it in c#. The following example will read an image file named “darksouls. Controls which channels in a composite color image are displayed, where 'channels' is a list of ones and zeros that specify the channels to display. An image that is in one of these formats can be loaded by using either a URL, or a filename. All of us know about the background color of a webpage. With Colllor it is much easier to generate a consistent web color palette with just a few clicks. The image is just a small icon image that is black in color with a transparent background but I would like to use the code to change the color to a light grey for example so it is easier to change the color to say green if I wanted in the future without having to make a new image. Types of external CSS. This array is defined by the size of the display window. Programatically using Java code. Select FOX I want that when user click on "Select" from first row of first column, then that complete first row background color will change. futhermore you should use this to regulate the places where the message will be displayed by margin attributes. BasicImage"). Java Programming Language. The most common source of images is to load from a standard file format such as GIF, JPEG, PNG, or BMP. The Color class contains three primitive colors namely, red, blue and green and all other colors are a combination of these three colors. Robot: getPixelColor(int x, int y) import java. NET - BurnIgnorance. hi everyone i want to change some pixels values based on special condition. Julio, At first this code did not work in IE7 but as you mentioned I had to add your site to my "Trusted Sites" list. This page will let you enter in RGB values, and by pressing evaluate, see the correspinding hexadecimal and integer representations of the color. I was wondering how to find the color of a specific pixel on the screen, using (x,y) coordinates and recieving the rgb value, i would also like to know how to link red to Label1. CamanJS is (ca)nvas (man)ipulation in Javascript. Then convert the text to a path. How to Use Inline, Embedded, and External CSS As explained in the previous two parts of this tutorial series, there are three ways to implement CSS in your web design. Back to JTabbedPane ↑ java2s. Java Forums on Bytes. How to set background image to jFrame form in netbeans Posted by Arun Alande at 2:17 AM 3 comments Some times we get problem while customizing code. So, the first pixel, which has a value of 0 0 0, is black, and the last pixel, 255 255 255, is white. If you need to, you can change this behavior in Edit→Options→Conversions. How to change textfield color in DateField If this is your first visit, you may have to register before you can post. The position of a pixel center determines whether a pixel is selected. Beginning Programming with Java For Dummies, 4th Edition. Updated: February 5th, 15'. Here Mudassar Ahmed Khan has explained, how to change TextBox Background color on Focus CSS and without any JavaScript or jQuery i. JavaScript injection is a process by which we can insert and use our own JavaScript code in a page, either by entering the code into the address bar, or by finding an XSS vulnerability in a website. How to get the pixel color from a canvas on click or mouse event with Javascript. Edit photos in your browser!. it also has a pause and play button. Computer display consists of a grid of pixels (The size of grid is called resolution). The other simple way is to dynamically change the font color of a content to be highlighted in a webpage without going back to the server. Taking a look at SWT Images Summary SWT's Image class can be used to display images in a GUI. For the last hour on Java's multimedia capabilities, and the last hour of the book, you will learn how to display image files in GIF and JPEG formats in your programs and present them in animated sequences. How to Change Keyboard Settings in Windows 10 You can find options to change the keyboard layout, language, and other related options at Settings > Time & Language > Region & language. In this tutorial we’re going to learn how to resize and crop an image using the HTML5 element, and while we’re at it, let’s create some fancy controls for resizing, commonly seen in photo editing applications. It depends on how you implement the color blending. The format of the image must be one of PNG (a W3C standard), GIF, or ICO. js in your html document. You can color a single pixel in a Java drawing by drawing a line with the same start point and end point. onmouseover event | mouseover event. It's HTML5 canvas based and uses variable width Bézier curve interpolation based on Smoother Signatures post by Square. However one thing i haven't been able to work out is how to make the background image move to the selected link. and I want to change color of the image to work with other divs but I don't know how to do that. How to create an overlay in css, How to overlay image with color in CSS ,CSS Image Hover Overlay , Overlay another image , How to position text over an image How to create an overlay in css Transparent Image Overlay. Hexadecimal color codes are used to represent colors numerically as three values in the [0,255] range: red, green and blue. Android – Change Tab bar background color By Paresh Mayani - July, 3rd 2011 Same as my previous post on TabBar as mentioned below, this article is also on TabBar and it is for changing Background color of Tab bar. Java Image Filters. It makes web pages functional for specific purposes and if disabled for some reason, the content or the functionality of the web page can be limited or unavailable. So you can adjust and adjust until you feel satisfied. How can I change the sprite image from script? In the editor I have setup a texture with multiple frames (fruits_0, fruits_1. For example if I have a car image(car body) initially white color, then if I choose blue color in options menu the color of the car must change to blue. Not the cells underneath, just the header block. Example Applet. How to get current image size (width & height) in javascript " > Get Current Image Size Colors>Color Picker window to change the background color. In Acrobat JavaScript, color is primarily used for setting annotation and form field visual properties, such as the border, fill, and text. cyan and then print the coordinates of that pixel color. However it is not considered as pure object oriented as it provides support for primitive data types (like int, char, etc). The upper-left hand corner of the screen has an x coordinate of 0 and a y coordinate 0 ; thus x coordinates increase from left to right, and y coordinates increase from top to bottom (unlike our. Then colors. Change Color Tint Free Online Photo Editor. OffsetY with the coordinate of each individual pixel using a for loop to retrieve the RGB of each pixel. Change Text Colors: The right way to change text colors. Join today to get access to thousands of courses. Adding a Background Image to Web Pages In addition to adding a background color to an element, you can also add a background image to any element where you'd add a background color. j a v a 2 s. I have created a working example for you. Using JavaScript to Change an Image SRC Attribute Ever wanted to change a picture whenever you clicked a particular text? Well that’s what this tutorial is all about. These numbers can be turned into a color string using the color rgb function (see next section). How to set background image to jFrame form in netbeans Posted by Arun Alande at 2:17 AM 3 comments Some times we get problem while customizing code. [Transparency. CSS Background Color and Image Styling Properties Explained Find out how to easily add CSS background in your project. I need to read this layer pixel for instance pixel with coordinates (100,100) and write to new layer this pixel with changed pixel color. If your background image is dark, you can make light text viewable. If the background image is light, dark text shows up. index color image editing method in java I want to edit index color images with Java Swing If it is a normal RGB image, you can paint somehow in Graphics, but what I want to do in particular is to specify the color in the color map,. Now that we have these potential background colors and their hex values, we need to find out whether the corresponding text should be in white or black, based on which has a higher contrast, therefore affording the best readability. Cliking on a link from the second row should set the bg color of row 1 to default and change the bg color of row 2. In any case, the amount of change between frames should to be below the amount that triggers a perceptual discontinuity, or you will get some sort of artifact. Actually, they don't. This tutorial covers basic features—it is aimed at a beginner, with no experience in computer graphics. but it works on Microsoft internet explorer,avant browser and crazy browser only. The other simple way is to dynamically change the font color of a content to be highlighted in a webpage without going back to the server. Alt-click in the Image>Colors>Color Picker window to change the background color. Here is a quick example of how you can change the background color of the cell of a table when the user mouses over that cell. To do this, you construct a JSON object that describes the elements that are displayed when a row is loaded in a list view and any styles to be applied to those elements. Method 2: Using CSS Pseudo-Elements This method is seems simple once you see it, and is definitely my preferred method of doing this. Stoyan's phpied. The how-to of it is explained below. The Color class contains three primitive colors namely, red, blue and green and all other colors are a combination of these three colors. ) Then, in Eclipse’s editor, change the name androidBook. This is way faster than taking a screenshot and opening it. You can use the free W3Schools HTML. Introduction. Remember, each pixel has a corresponding color value (red, green, and blue). In this example we iterate over all pixels to change their values, then we put the modified pixel array back to the canvas using putImageData(). Here's how to set your default browser in Windows 10. Lots of filters and effects, easy to use, connects to Facebook, Twitter, WordPress. Discover how color channels, bit depth, and video. A lot of artists have problems with picking out appropriate colors -- lights, darks, and base colors - especially in the case of skin tones! This section should help with the problems associated with color choice. — Emily G over 9 years ago; in my IE6 your image, when embedded in a page displays with a grey background. Image; JButton; JCheckBox; JComboBox; Change JFrame background color. It may be useful sometimes to provide your visitors with the option to change the appearance of your website. Input colors in File name input box, click OK button. CamanJS is very easy to extend with new filters and plugins, and it comes with a wide array of image editing functionality, which continues to grow. StdDraw3D is a Java library that makes it easy to create three-dimensional models, simulations, and games. Hexadecimal color codes are often used to represent web colors. how do i do it ? ===== Most any image editor can change from color to grayscale. The color values are in hexidecimal. A lot of artists have problems with picking out appropriate colors -- lights, darks, and base colors - especially in the case of skin tones! This section should help with the problems associated with color choice. How can I do this?. The below 'image' will illustrate how the image was displayed. Setting color can be used as heading or column name that increases the readability of excel file. When the page loads, just check the date using new Date(), and if it matches with the specific user, just change the src attribute of the image. How to convert image to byte array and byte array to image in Java This article will tell you, how you may show images on your webpage without having the need to store the images using the conversion image to byte array and byte array to image. Go to the Appearance tab and click on the Fill Color icon and pick the color. I'm not the expert in Java image processing, but a chance given to implement this re-sized feature in user image upload form, which request re-sized the large image to a smaller size with fixed width and height. I have created a working example for you. how to change jlabel background image and jpanel color in java JAVA - How To Make Transparent Color In NetBeans Java - Show Image From Resource Folder JTable Click Using Java NetBeans. They allow you to group related data in rows and link them to other data in different columns. How to Use Inline, Embedded, and External CSS As explained in the previous two parts of this tutorial series, there are three ways to implement CSS in your web design. Because the image is tilted and gif looks like crap. From Emgu CV: OpenCV in. A JavaScript "event handler" in a hyperlink tag around the image tests for whether the mouse is leaving or entering the area of the page covered by the image. Get color information from an arbitrary pixel on the screen, such as the current location of the mouse cursor. For Tumblr, Facebook, Chromebook or WebSites. How can i change the color of the image which i passed to this Image Object. You must have heard of grayscale image and may have even used the process in image processing software like Photoshop to get a grayscale image. If value is 00 that means 100% transparent. NET, FromImage, GetPixel, and FromFile. For example, the left side set to 67% of the total parent. 025) makes the thickness of the lines and the size of the points to be five times the 0. Setting the pixel from a Color object If you have a Color object representing the colour that you wish to set (either one of the Color constants such as Color. For other android UI components, it is similar to change foreground and background color like this. The basic idea is to get the pixel value for each cordinates and then keep the desired resultant color pixel value to be same and set the other two as zero. I have layer in Photoshop where with brush is drawn something.