Alpha Color on Images?

Okay, Let's see if anyone knows this. Let's say I have a Image and I want to make the background transparent. It's certainly possible to load a transparent GIF89A, but say I want a normal gif and I want to "transparentize" it in code. Here's a code I have:
//Precondition: 'global' is a predefined JApplet
//                         'opaque' is a predefined Image with w,h > 0,0
//Postcondition: An Image is returned with the background (as defined
//                           as the color of the top-left pixel) replaced by the GIF89A
//                           "transparent color"
public Image makeTransparent(Image opaque)
  //makes an Image that is the same size as 'opaque'
  Image trans = global.createImage( opaque.getWidth(global), opaque.getHeight(global) );
  //gives me a graphics object to draw on this image
  Graphics g = trans.getGraphics();
  <redraw image substituting transparent for bg>
}I need to know how to do the <>. My most obvious response would be to go though the Image's array of colors (the way an Image is stored) and change the "bg" color to transparent. But that brings up two questions. (a) Is it possible to access and change that array, and (b) What is the "transparent color" and can the Color object hold it?
If anyone can answer this question or has another algorithm, I am offering "duke dollars" for this.

Great news! It worked! Here is the algorithm: All you need is a BufferedImage. It isn't really as inefficient as it may look, either, but don't use it every frame.
Color bg = new Color(bimage.getRGB(0,bimage.getHeight(null)-1), false);
for(int xxx=0;xxx<bimage.getWidth(null);xxx++)
        for(int yyy=0;yyy<bimage.getHeight(null);yyy++)
             if(new Color(bimage.getRGB(xxx,yyy), false).equals(bg))
                  bimage.setRGB(xxx,yyy,0&0&0&0);
}

Similar Messages

  • How to create 2-color Pantone image from jpeg logo

    Working in CS3 under XP, I need to convert a jpeg rvb image of a logo  into a 2-color pantone image to import it into an Illustrator file. I  can isolate the logo's two distinct colors using the select wand and  then tried filling the selections with the closest Pantone colors, but  the rvb layers still seem to exist. I have saved in .eps DCS2, but the  imported colors when sampled in Illustrator are still rvb/cmyk. Is there  a way to isolate the shapes/colors and then transfer them as vector  images into Illustrator, where I could fill them with the Pantone  colors? Or a simpler way not necessarily using Photoshop? Thanks very much!

    Is this a vector image or pixels? EPS can be both.
    Better than selecting it with automatic functions like magic wand is to draw it manually in Illustrator. If it already is vector (like shape layers), then you can just copy the paths from Photoshop and paste into Illustrator.

  • Exporting photos for UHDTV or Native 4K TV, what are the best settings ? (File: Quality File: Color Space, Image Sizing and resolution)   Or in other words; How can I get the smallest files but keep good quality for display on new UHDTV

    Exporting photos for UHDTV or Native 4K TV, what are the best settings ? (File: Quality File: Color Space, Image Sizing and resolution)   Or in other words; How can I get the smallest files but keep good quality for display on new UHDTV

    You're welcome, and thank you for the reply.
    2) Yesterday I made the subclips with the In-Out Points and Command-U, the benefit is that I've seen the clip before naming it. Now I'm using markers, it's benefit is that I can write comment and (the later) clip name at once, the drawback is that I have to view to the next shot's beginning before knowing what the shot contains.
    But now I found out that I can reconnect my clips independently to the format I converted the master clip to. I reconnected the media to the original AVI file and it worked, too! The more I work with, the more I'm sold on it... - although it doesn't seem to be able to read and use the date information within the DV AVI.
    1) Ok, I tried something similar within FCE. Just worked, but the file size still remains. Which codec settings should I use? Is the export to DV in MOV with a quality of 75% acceptable for both file size and quality? Or would be encoding as H.264 with best quality an option for archiving, knowing that I have to convert it back to DV if I (maybe) wan't to use it for editing later? Or anything else?
    Thank's in advance again,
    André

  • Alpha channel and imaging lingo

    I have a 32 bit image with an alpha channel. When placed on
    the stage only
    the black anti-aliased text shows and no background shows
    (using the copy
    ink)
    I'm scrolling this image with imaging lingo where I take a
    sliding portion
    of the original image in one direction or the other. When I
    do this the
    background of the portion on the stage is white instead of
    transparent.
    I'm creating an image and assign a portion of the text image
    to it. I tried
    pImage.useAlpha = TRUE but I get an error saying the property
    can't be set
    which is rediculous I know. pImage is definitely an image, I
    checked it
    with the debugger.
    useAlpha might not be the correct solution but it brought up
    a second
    question. First, how can I maintain the alpha channel with
    imaging Lingo
    and second why do I get the error telling me that the
    useAlpha property
    can't be set?
    Craig
    Craig Wollman
    Lingo Specialist
    Word of Mouth Productions
    212-928-9581
    www.wordofmouthpros.com

    Thanks. You're right, I did need to create the image in 32
    bits but
    otherwise I only needed to set useAlpha to TRUE and the alpha
    was maintained
    perfectly without any other changes.
    Craig Wollman
    Lingo Specialist
    Word of Mouth Productions
    212-928-9581
    www.wordofmouthpros.com
    "Lukewig" <[email protected]> wrote in
    message
    news:ek0ibj$c9k$[email protected]..
    > Hi Craig,
    >
    > If "pImage.useAlpha = TRUE" gives a 'cannot set this
    property" error, then
    > pImage.depth is less than 32. Change your code to
    something like this to
    > confirm:
    >
    > if pImage.depth < 32 then put "oops, no alpha to use"
    > else pImage.useAlpha = TRUE
    >
    > As how to "maintain the alpha channel with imaging
    Lingo", I gotta scratch
    > my
    > head each time (its kind of counter-intuitive). Basic
    rule of thumb is
    > turn off
    > alphas for copypixel operations, extract your alphas and
    copypixel them
    > separately, and then reset the alpha of the final
    composite image (of
    > course,
    > the details depend on whether your are wanting to
    combine your alphas or
    > not).
    >
    > -- Luke
    >
    >

  • Converting color .jpg image to grayscale

    I have a color .jpg image that I want to convert to grayscale and then add annotation. Is this easy to do in Illustrator?

    Thomas Crowley wrote:
    I've opened the .jpg image in Illustrator. It is a line drawing.
    Those two statements constitute a logical fallacy. A JPEG image is a bitmap, and not, in any way or fashion, a "line drawing". Therefore,
    ...I cannot edit individual parts of the drawing.
    is because the "individual parts" of the image are single color pixels. To "edit" these, you need a bitmap editor.
    It's necessary to say "edit" (w/quotes) because you will be editing pixels. Any notion of 'lines', 'planes', and 'shades' only exist in your mind, and not as physical separate objects somewhere inside the bitmap. If you think you can "select" a big black square "object" in the bitmap editor, well, that's because the software only makes you think you can (it's easy to scan for the edge of a single color filled region).
    ... I just felt you might need to know this.

  • Modifying colors in images

    I am trying to create a vi in Labview 7.1 that will upload an image from a jpeg file, modify the color and luminance of the image, and then output the image as a jpeg file. I am currently able to input and output the image to a file, but I am having difficulty modifying the colors of images. I read in a manual that the color control was a 32 bit array, but when I try to make my own array and wire it to the color control on the image block, it breaks the wire and won't let me make the condition. How do you design a proper array to set color and which array elements correspond to red, blue, green, hue, luminance, and saturation of the image? I am able to manually adjust the color and set my own color in rectangles, but I wanted to create an automated process with an array to automatically generate a range of colors.
    The other problem I was having was getting the image to be displayed on the visual panel of Labview. I can import and export the jpeg file, but I cannot get it to be displayed on the grid. I would greatly appreciate any assistance and advice you have.
    Thanks,
    Daniel

    If you are going to do some heavy image manipulation, you may wish to look into a LV toolkit called IMAQ, which allows you to go that way.
    If not, you can start by using the standard picture VIs (Graphics & Sound palette), which I assume you already do to read and write the file.
    LV treats a picture in one of three formats:
    1. Picture - the blue wire. You will need to to use this for any manipulation using the picture VIs.
    2. Pixmap. A 2D numeric array in which each cell holds the color value of the coresponding pixel.
    3. Flattened pixmap. A cluster holding all the picture information in which the pixel data is stored as 1D array.
    There are VIs for converting all these formats.
    To replace colors you can simply use Replace Array Subset to replace specific cells either in the 1D or 2D array or use the Draw point VI. The main problem you will have is that you will need to calculate everything on your own. If you want to modify the entire image, you can go over the array in a loop and (for example) increase all values by 1000 and see what that does.
    All of this can be found from reading the help files for the VIs (right click>>Help), which is what I suggest you do to learn more about this.
    You can display an image simply by converting to the first format right clicking the VI output (picture) and selecting Create>>Indicator. because it's a picture format, a picture indicator will automatically be created.
    It sound as if you don't have much experience in LV. Also, try searching this site and google for LabVIEW tutorials. Here and here are a couple you can start with. You can also contact your local NI office and join one of their courses.
    In addition, I suggest you read the LabVIEW style guide.
    Try to take over the world!

  • Changing color of Image in PSE 8.0

    I have a logo design that is black on white.  I'd like to change the black to another color - in this case, blue.  I wqas able to do it, but it ended up being quite convoluted.  What are some simple ways to change the color of a selected area in Elements 8.  I'm using a PC, BTW.
    Thanks!

    Thank you.  I found another way that's even simpler.  I chose the paint brush, set the mode to lighten, and then just painted over the image with blue - the white didn't pick up any of the blue, but the black did.
    Date: Tue, 22 Feb 2011 17:02:09 -0700
    From: [email protected]
    To: [email protected]
    Subject: Changing color of Image in PSE 8.0
    1. Select the black (use the magic wand if it's all one color).
    2. Layer>New Adjustment Layer>Hue Saturation.
    3. Turn on the colorize checkbox in the layers panel, and move the sliders till you see the color you want.
    >

  • Invalid color template image

    I try to do patttern matching using IMAQ Vision. Both source and
    template images are .BMP files and are generated in a VB .NET program
    through NI Framegrabber. IMAQ Match Color Pattern gives me the
    following error message:
    Error-1074395384 occurred at IMAQ Match Color Pattern
    Invalid color template image
    Do I have to use .PNG files when doing pattern matching?
    Thanks.

    Hey John123,
    I was wondering what version of Vision that you are using? Have you tried to run any of the example programs, like the ColorPatternMatching example that can be found in the following directory: C:\Program Files\National Instruments\Vision\Examples\MSVB.NET\2. Functions\Color Pattern Matching. I was able to run this example program by using .BMP images and not PNG images. So to answer your question, you don't have to use PNG files with this function, you can use Bitmap images. You can use any kind of image that have a 32-bit RGB or HSL bit depth.
    If you are acquiring from a Framegrabber, I would suggest that you double check and make sure that the images that you are getting from your camera are actually 32-bit, and not 16-bit. Also, you could post a couple of your images on this thread, and I could try them out with an example that uses the IMAQ Match Color Pattern function. Try some other BMP images and do you get the same error? Try the example program, and see if that gives you the error with your images. Let me know if you have any questions. Thanks, and have a great day.
    Regards,
    DJ L.

  • Where are bg color / bg image in CS 5.5?

    Where are bg color / bg image in CS 5.5? They don't appear in the properties panel when a table is selected. Thanks.

    The background color and background image attributes of the table tag have been deprecated by the W3C and should no longer be used to specify those two things. As a result, they have (rightly) been removed from the table Property inspector). Instead, you are expected to use CSS to apply these two styles to the table in question, e.g.,
    table#thisOne { background-color:#FF6633; background-image:url(path/to/image.jpg); }
    which will style this table -
    <table id="thisOne">...</table>
    with a color and a background image.

  • How to make a Colorful Gif Image for Holi

    How to make a colorful Gif Image for Happy Holi 2014

    Okay, I know this doesn't answer your question, but don't get me wrong. A logo is meant to be the way it was designed - upright, no flipping/ swiveling animation. Why exactly do you want to let your logo turn around?
    If its to grab attention, why dont you consider animating the area on which your logo sits (header)? Or maybe add nice transitive slideshows on your main content area to add more interactivity?

  • Colors and images on itunes U site not displaying correctly.

    After the issues of not being able to login this weekend our site has dropped much of it's theming, including colors and images. The page/course thumbnails still show as well as the background image, but all the other areas look like they are missing the background images. Is anyone else having the same issues with their site. This is the original "private" site, not the new PSM version.
    Thanks,
    Kyle

    Yes, my store and another institution as well - we mentioned the new problem here:
    https://discussions.apple.com/thread/3142618?tstart=0

  • How to get max 5 color from image??

    I try to get max 5 color from image (ex. jpeg,gif) ,I use PixelGrabber
    it too slowly when i use large image,Please help me, to run more fast
    (other way PixelGrabber)
    best regard
    [email protected],[email protected]
    source below:
    public String generateColor(InputStream source,String filePath){
    BufferedImage image = null;
    String RGB = "";
    System.out.println("==generateColor==");
    try {
    image = ImageIO.read(source);
    catch (IOException ex1) {
    ex1.printStackTrace();
    //image.getGraphics().getColor().get
    // BufferedImage image2 = ImageIO.read(source);
    // image.getColorModel().getNumColorComponents()
    if(image.getColorModel() instanceof IndexColorModel) {
    IndexColorModel icm = (IndexColorModel)image.getColorModel();
    byte[][] data = new byte[3][icm.getMapSize()];
    int[] rgbB = new int[icm.getMapSize()];
    icm.getRGBs(rgbB);
    String dataHtm = "<HTML><table width=\"100\" border=\"0\"><tr>";
    for(int i = 0 ;i< rgbB.length;i++){
    int r = (rgbB[i] >> 16) & 0xff;
    int g = (rgbB[i] >> 8) & 0xff;
    int k = (rgbB) & 0xff;
    System.out.println("red:" + Integer.toHexString(r));
    System.out.println("green:" + Integer.toHexString(g));
    System.out.println("blue:" + Integer.toHexString(k));
    dataHtm = dataHtm + "<td width=\"10\" bgcolor=\"#" + Integer.toHexString(r)+Integer.toHexString(g)+Integer.toHexString(k);
    dataHtm = dataHtm + "\"> </td>";
    dataHtm = dataHtm + "</tr></table></HTML>";
    try {
    BufferedWriter out = new BufferedWriter(new FileWriter("c:\\23289207.html"));
    out.write(dataHtm);
    out.close();
    catch (IOException e) {
    e.printStackTrace();
    int w = image.getWidth();
    int h = image.getHeight();
    int[] pixels = new int[w*h];
    int[] pixs = new int[w*h];
    System.out.println("image width:"+w+"image hight:"+h+"image w*h:"+(w*h));
    Image img = Toolkit.getDefaultToolkit().getImage(filePath);
    PixelGrabber pg = new PixelGrabber(img, 0,0, w, h, pixels, 0, w);
    try {
    pg.grabPixels();
    catch (Exception x) {
    x.printStackTrace();
    String picColor = "";
    Stack stackColor = new Stack();
    Hashtable hashColor = new Hashtable();
    for (int i = 0; i < w * h; i++) {
    int rgb = pixels[i];
    int a = (rgb >> 24) & 0xff;
    int r = (rgb >> 16) & 0xff;
    int g = (rgb >> 8) & 0xff;
    int k = (rgb) & 0xff;
    i = i+1000;
    //System.out.println("i:" + i);
    picColor = convertToSring(r)+convertToSring(g)+convertToSring(k);
    stackColor.add(picColor);
    //System.out.println("picColor:"+picColor);
    // System.out.println("\n\n a:" + a);
    // System.out.println("red:" + r);
    // System.out.println("green:" + g);
    // System.out.println("blue:" + k);
    }//end for
    getMaxColor(stackColor);
    System.out.println("==generateColor==end\n\n");
    return null;

    import java.awt.Color;
    import java.awt.image.BufferedImage;
    import java.io.IOException;
    import java.net.URL;
    import javax.imageio.ImageIO;
    public class HighFive
        private void examineColors(BufferedImage image)
            long start = System.currentTimeMillis();
            int w = image.getWidth(), h = image.getHeight();
            int[] rgbs = image.getRGB(0,0,w,h,null,0,w);
            findHighFive(rgbs);
            long end = System.currentTimeMillis();
            System.out.println("total time = " + (end - start)/1000.0 + " seconds");
        private void findHighFive(int[] colors)
            int[] uniqueColors = getUniqueColors(colors);
            int[] colorCounts  = getColorCounts(uniqueColors, colors);
            int[] highFive     = getHighFive(colorCounts);
            // for each value of highFive find index in colorCounts
            // and use this index to find color code in uniqueColors
            for(int j = 0; j < highFive.length; j++)
                int index = findIndexInArray(colorCounts, highFive[j]);
                Color color = new Color(uniqueColors[index]);
                String s = color.toString();
                s = s.substring(s.indexOf("["));
                System.out.println("color " + s + "  occurs " +
                                    highFive[j] + " times");
        private int[] getUniqueColors(int[] colors)
            // collect unique colors
            int[] uniqueColors = new int[colors.length];
            int count = 0;
            for(int j = 0; j < colors.length; j++)
                if(isUnique(uniqueColors, colors[j]))
                    uniqueColors[count++] = colors[j];
            // trim uniqueColors
            int[] temp = new int[count];
            System.arraycopy(uniqueColors, 0, temp, 0, count);
            uniqueColors = temp;
            return uniqueColors;
        private int[] getColorCounts(int[] uniqueColors, int[] colors)
            // count the occurance of each unique color in colors
            int[] colorCounts = new int[uniqueColors.length];
            for(int j = 0; j < colors.length; j++)
                int index = findIndexInArray(uniqueColors, colors[j]);
                colorCounts[index]++;
            return colorCounts;
        private int[] getHighFive(int[] colorCounts)
            // find five highest values in colorCounts
            int[] highFive = new int[5];
            int count = 0;
            for(int j = 0; j < highFive.length; j++)
                int max = Integer.MIN_VALUE;
                for(int k = 0; k < colorCounts.length; k++)
                    if(colorCounts[k] > max)
                        if(isUnique(highFive, colorCounts[k]))
                            max = colorCounts[k];
                            highFive[count] = colorCounts[k];
                count++;
            return highFive;
        private boolean isUnique(int[] n, int target)
            for(int j = 0; j < n.length; j++)
                if(n[j] == target)
                    return false;
            return true;
        private int findIndexInArray(int[] n, int target)
            for(int j = 0; j < n.length; j++)
                if(n[j] == target)
                    return j;
            return -1;
        public static void main(String[] args) throws IOException
            String path = "images/cougar.jpg";
            Object o = HighFive.class.getResource(path);
            BufferedImage image = ImageIO.read(((URL)o).openStream());
            new HighFive().examineColors(image);
    }

  • Help me, How to insert Rectangle which fill color to image picture

    How to insert Rectangle which fill color to image picture and then It is saved file JPG

    > Is it possible to get the data from CSV files.
    Have you tried searching this forum?

  • How to convert all white - alpha for vector image?

    I'm attempting to make a new font. Currently I've been saving all the png -> vector images that I work with as .AI files, so that I can import them into my font program later, and they open fine in illustrator. The problem is, I usually save my vector images with a white background instead of alpha. Now, I need to replace white with alpha, but I can't find a magic wand in illustrator . Any help?

    function(){return A.apply(null,[this].concat($A(arguments)))}
    I only knew the most fundamental differences between raster and vector: that raster images are saved in dots while vector images are saved in, at the simpliest, lines.
    Not "dots";  pixels. Pixels are simply color values. That's all. Raster programs arrange color values in a rectangular grid of same-size rectangles (usually squares).
    Not "lines"; paths. Paths are discrete individual objects. Paths are stacked, independently moved, freely arranged, scaled, filled, stroked, and otherwise manipulated as individual objects.
    function(){return A.apply(null,[this].concat($A(arguments)))}
    But I'd have thought there was a way to quickly delete the white lines
    There is no "vector image" with a background. Where there are no objects, there is no "background." If a path is there, regardless of whether it has a white fill, a white stroke, or fill(s) and/or stroke(s) of any other color or no color at all, the path is there and can be deleted. (Again, there is no substitute for learning to use the program from the documentation.)
    Technically, paths are mathematically-defined curves. So even a "straight line" is a path, and is technically a curve. The specific kind of mathematically-defined curve used in programs like Illustrator is called a Bezier curve.
    function(){return A.apply(null,[this].concat($A(arguments)))}
    I have no idea how hard it is to create a vector image from scratch.
    It's not rocket science. Anyone can learn it. But again, you have to learn it. There is no substitute for learning to use the program from the documentation.
    function(){return A.apply(null,[this].concat($A(arguments)))}
    I myself am mostly a newbie in both hemispheres of the graphic design world.
    It shows. And there's certainly nothing wrong with that. We all started as beginners. I'm not trying to belittle you: I'm offering you sound advice that will serve as a very valuable shortcut to becoming more than a beginner (if you will accept it) without an unnecessary amount of fumbling around with bad practices.
    Just don't ever claim to a client or in a job interview to know anything at all about any mainstream general-purpose vector drawing program (of which Illustrator is just one) until you are proficient at drawing Bezier curves. That's prerequisite. It's lesson one in chapter one. Might as well start there. Start at the correct beginning and you'll know all the answers to the questions you have asked in this thread. Your understanding of "background" and things like why a region with no objects is not the same thing as an alpha channel in a raster image will come very early if you just start at the beginning. You've got to learn the lay of the land. Start at the beginning.
    function(){return A.apply(null,[this].concat($A(arguments)))}
    In any case, I use a program called vectormagic that does the work for me pretty well, so you might want to check it out.
    Trust me; I'm familiar with it. It's just another autotrace program. I know what it does. I know how "well" it does it. Everything I said in the previous post stands.
    Vector drawing programs are not the kind of program you learn by just launching it and poking around. Not if you want to avoid endless confusion and frustration. Asking random questions in an online user forum (in which wrong "answers" are just as common as right answers) everytime you encounter a point of confusion is just as inefficient. Read the documentation.
    JET

  • Alpha value for image

    the alpha value of all pixels of many images(jpg,gif) is coming out to be same(ie 255).why is it so? does alpha value really represents intensity?

    What colour model are you thinking of? Perhaps you'd find the Color.RGBtoHSB method helpful?

Maybe you are looking for

  • Dubbing Audio with ASUS P6T WS Pro motherboard ADI AD2000B Audio CODEC

    I am trying to dub audio commentary into my clips using the SoundMAX program settings provided with the ASUS ADI AD2000B Audio Codec.  I have confirmed a microphone signal appears in SoundMAX and that PPro Audio Hardware Settings/Enable Devices has a

  • My new ATV remote also controls MacBook pro.  How do I get it to stop?

    The computer is in the same room as the Apple TV.  The remote controls both devices but each is doing a different thing. I have tried to unpaired the remote from the MacBook but it doesn't seem to complete the unpairing.  How do I get the MacBook to

  • Best directory for isnatlling Unix Applications in Snow Leopard?

    Can someone advise me on the best location for installing Unix Applications in Snow Leopard? Should I install them in /usr/local or create a new /opt directory for them? My understanding is that OS X 10.6 does not come with /opt. I prefer to install

  • Database Console Error

    When im starting the database console i reserve the this error report. Event log Please help me to solve this.? Edited by: fireoze on Dec 31, 2009 4:05 AM

  • PO validating while creating...

    Hi All, I need to validate some item level data with the header data, So i wrote the code in User Exit. Its validating well, but if i press save button its simple asking a dialog and the PO is getting saved when i have errro also. i have tried  EXIT_