No Transparency on PNG image problem

I'm trying to create an ImageIcon that uses a transparent PNG image. I have set a particular colour on the image itself to be transparent in Corel PhotoPaint, and when i view the .png image that is output this colour is transparent.
However, when i then load this png image into my Swing app, using it as an ImageIcon, the transparent colour is no longer transparent, and the original colour can be seen in its place.
Anyone have any ideas?
Cheers

I'm trying to create an ImageIcon that uses a transparent PNG image. I have set a particular colour on the image itself to be transparent in Corel PhotoPaint, and when i view the .png image that is output this colour is transparent.
However, when i then load this png image into my Swing app, using it as an ImageIcon, the transparent colour is no longer transparent, and the original colour can be seen in its place.
Anyone have any ideas?
Cheers

Similar Messages

  • Keep transparency of png image with type TYPE_BYTE_INDEXED

    Hi, i have a problem with a few png images. they have the type TYPE_BYTE_INDEXED. if i do any resizing or anything else with Graphics2D the transparency is lost..
    here is a simple example..
            BufferedImage bi = ImageIO.read(new File(args[0]));
            double w = 450;
            double oriw = bi.getHeight();
            double orih = bi.getWidth();
            double h = (oriw/orih)*450;
            Image image = bi.getScaledInstance(450, (int)h , bi.getType());
            BufferedImage biRes = new BufferedImage((int)w,(int)h,bi.getType());
            Graphics2D bufImageGraphics = biRes.createGraphics();
            bufImageGraphics.drawImage(image, 0, 0, null);
            System.out.println(biRes.getType());
            ImageIO.write(biRes, "png", new File(args[2]));my actual java program is more complex like this..
    is there anyway to "rescue" the transparency?
    p.s. sorry for my bad english ;)

    Try something like this:
    BufferedImage biRes = new BufferedImage(bi.getColorModel(), bi.getColorModel().createCompatibleWritableRaster(w, h), bi.isAlphaPremultiplied() , null);You have to copy the color table to the new image.
    The transparency data is written there.

  • Transparency in png image not showing

    Hello,
    I have a Region, which needs a background and an image 'on top' of it.
    I can set the background using
    setStyle("-fx-background-color: #" + 123456 + ";");
    Or I can just use a Rectangle of that colour.
    Then I have an ImageView...   spiralImgView = new ImageView(new Image("images/spiral2.png"));
    The png image itself has some transparency in it.
    So when I add them to the region...
    this.getChildren().addAll(rect, spiralImgView);
    I just get a white background showing behind the image.
    Can anyone help me fix this?
    Thanks

    I didn't do any coding.  This will tell you if it is your image:
    1)  Download and start JavaFX Scene Builder
    2)  Without making any changes paste "-fx-background-color: #1d1d1d;" into the "Style" box of the "Properties" window
    3)  Drag and drop an Image View into the scene from the "Library" window.
    4)  Click on the ImageView in the "Hierarchy" window.
    5)  In the "Properties" window Use the "Image" selector to find your img on disk
    If your image is mostly transparent it's background will not be white but #1d1d1d

  • Keep transparency of png image with type TYPE_BYTE_INDEXED(new duke stars)

    related to: http://forum.java.sun.com/thread.jspa?threadID=5178660&tstart=0
    opened to assign new duke stars

    Try something like this:
    BufferedImage biRes = new BufferedImage(bi.getColorModel(), bi.getColorModel().createCompatibleWritableRaster(w, h), bi.isAlphaPremultiplied() , null);You have to copy the color table to the new image.
    The transparency data is written there.

  • Problem with reduction Of an PNG Image with transparent background

    I have an PNG Image on my computer with a transparent background that I would like to reduce 50% and save it back to my computer can you tell me how to achive this?

    Are you looking to reduce the size (pixel dimensions) by 50% or reduce the file size by 50%?
    If you want to reduce the actual image size (pixel dimensions) you could go to Image>Image Size
    and check resample image with constrain proportions and then enter 50 in the pixel dimensions at the top after setting
    the drop-down to percent.
    Or use file Save for Web and enter 50 under the percent under image size.
    As far as saving you could use File>Save As in photoshop and choose png or File>Save for Web>png
    (save for web usually results in smaller file sizes)

  • Framing image with transparent background png frame

    hi,
    i'm trying to find a way to frame images with transparent background png frames...
    what i'm doing now is
    1-drawing my image on a panel
    2-creating a 2nd image using the frame's filename, stretching this 'frame-image' to a size slighlty larger than that of my main image and drawing the 'frame-image'
    the problems with this method are:
    1-depending on the width of the frame, the frame sometimes hides parts of the image (thick frame), and sometimes there is a gap between the frame and the image (thin frame).
    2-if the image file containing the frame is larger than the frame (Ex: The image is 300x300, the frame is centered in this image and is 200x200; as opposed to the image is 200x200 and the frame takes up all the space), when i position the 'frame-image' near the top left corner of the image i want to frame, the frame appears at the wrong place (shifted down and to the right). This is due to the fact that i'm placing the top corner of the created 'frame-image' and not the frame, who is not in the top corner of my 'frame-image'.
    Is there a way to do what i'm trying to do???
    My ideas (which i don't know how to achieve are)
    1-To 'analyse' my transparent background png file and
         1-only keep the frame,
         2-calculate the frame's thickness
    OR
    2-Let java do the analyzing for me and tell it to frame my image with the frame in the png file
    please feel free to ask for more explanations if my description/question is confusing,
    thanks.

    Have you looked into the Border interface? If what you really want to do
    is put a custom border on a component, you may be able to do it this way.
    Anyway, here is some code that stacks and centres 2 images. It's not hard to do.
    import java.awt.*;
    import java.awt.image.*;
    import java.io.*;
    import java.net.*;
    import javax.imageio.*;
    import javax.swing.*;
    public class Example extends JComponent {
        private BufferedImage backgroundImage;
        private BufferedImage foregroundImage;
        public Example(BufferedImage backgroundImage, BufferedImage foregroundImage) {
            this.backgroundImage = backgroundImage;
            this.foregroundImage = foregroundImage;
        public Dimension getPreferredSize() {
            int w = backgroundImage.getWidth();
            int h = backgroundImage.getHeight();
            return new Dimension(w, h); //assuming this is bigger
        protected void paintComponent(Graphics g) {
            super.paintComponent(g);
            int w = getWidth();
            int h = getHeight();
            //paint both, centred
            int x0 = (w-backgroundImage.getWidth())/2, y0 = (h-backgroundImage.getHeight())/2;
            g.drawImage(backgroundImage, x0, y0, null);
            int x1 = (w-foregroundImage.getWidth())/2, y1 = (h-foregroundImage.getHeight())/2;
            g.drawImage(foregroundImage, x1, y1, null);
        public static void main(String[] args) throws IOException {
            URL url1 = new URL("http://weblogs.java.net/jag/Image54-large.jpeg");
            URL url2 = new URL("http://weblogs.java.net/jag/DukeSaltimbanqueSmall.jpeg");
            JComponent comp = new Example(ImageIO.read(url1), ImageIO.read(url2));
            final JFrame f = new JFrame();
            f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            f.getContentPane().add(comp);
            f.pack();
            SwingUtilities.invokeLater(new Runnable(){
                public void run() {
                    f.setLocationRelativeTo(null);
                    f.setVisible(true);
    }

  • Black background for transparent PNG images - Xcelsius 2008 SP4

    Hi Experts,
    I am using Xcelsius 2008 SP4. I have used Image component to show a PNG image with transparent background. When I export the flash, the image is being shown with a black background.
    In Xcelsius 2008 SP3, this problem was not there. I am facing this issue after installing SP4.
    Did anyone else face similar issue ? Is there any workaround ?
    regards,
    pasg

    Hi all,
    I was facing the very same issue. I succeeded in finding a solution to it. This is happening coz of the dimension and pixels of the .png image. I imported the image in the image component, which had the dimensions, 175 x 70, and was of 9.26 kb and the black background was visible. I then changed the dimension of the image to 428 x 140, and 19.2 kb (double the size), and VOILA!! to my surprise IT WORKED !
    Don’t forget to “check” the “embed file” and  “Hide SWF Background Color” check boxes in the image component's, general tab.
    Try the same, I hope this helps.
    Regards,
    Sara

  • Problems converting PNG image to SVG with autotrace

    Hi,
    I am trying to convert a large number of color PNG images of hieroglyphs (produced after much effort) to SVG format, using "autotrace -background-color ffffff -output-format svg".
    It seems that where there are closed paths with background color inside, autotrace produces an SVG image with the background area in black instead of transparency. (You can see the images at http://5b4az.chronos.org.uk/pkg/hieroglyph/A001.png and http://5b4az.chronos.org.uk/pkg/hieroglyph/A001.svg although the svg image is not rendered by Firefox). You may also download the tarballs with all the hieroglyphs of the Gardiner set if you are interested.
    After all the effort that went into these images, I am stuck with being unable to convert raster images to vector graphics. I did try autotrace before I put in all this effort, but I didn't notice the problem because apparently I tried it on images with no enclosed background color.....
    Any suggestions wellcome greatefully!
    Last edited by neok (2009-10-17 16:59:31)

    I know this is an old thread, but I did some new testing on some line art and want to post my results.
    I started with a PNG, and converted it to PBM and PGM. I got much better quality doing this conversion with GIMP, as opposed to pngtopnm.
    I traced both formats with autotrace and potrace, which I output to SVG.
    Autotrace accepts PNG, so I did the trace with the original as well.
    I got the highest quality with PGM and potrace.  It also was the smallest file size.
    a close second was PBM with potrace, slightly larger.
    third was autotrace and the PBM, larger still.
    Using the PGM with autotrace was unacceptable, and the file size was HUGE!
    So if black/white is OK: Convert PNG to PGM with GIMP, then potrace
    both the best quality, and smallest size SVG.  This is assuming you started with anti-aliased black/white line-art, i guess the full greyscale PGM avoids the aliasing of PBM.
    It seems autotrace is the way to go, if your forced to deal with multiple colors. 
    I suspect you will need to do many passes and really tweak those command options,
    The PNG directly to autotrace was a complete disaster, but i suspect it would improve given enough time to configure command arguments.
    However, even with those perfect options I would believe potrace yields a cleaner trace.

  • Adobe Photoshop CS6 png image transpercy problem

    Hello,
    On our site we used a lot of transparent png images.
    The images show up fine however they are not transparent as in Photoshop.
    Now the transparent areas are white where they are transparent in Photoshop.
    Can anybody explains me what I'm doing wrong ?
    For example the logo at the top above antivirus.
    Example 1 Antivirus logo
    Example 2 Antivirus norton product page overview.
    Exampe 3 Antivirus prijs in product overview.
    Thanks for the support.
    Could this have something to do with how I save the png images ? For example I can save as PNG 24 and several other PNG types.
    Message was edited by: BRDigital

    Thanks for your answer, indeed this fixed the problem. Quite stupid I did not see this myself

  • Transparency not working on smartshape button filled with transparent (PNG) image.

    I'm using Captivate 8 and have had no problems so far importing PNG images with transparent backgrounds.....that is until I try and make a smartshape button and import a transparent PNG image as the background.
    It displays fine on screen, but whenever I preview it or publish, the white background of the image/button displays. Is this a known Captivate 8 limitation?
    Sorry if this is a repeated question....I've tried trawling through the forums and all I can see is to try different file formats for the images, such as GIF or BMP, which I've tried and nothing works.
    Any advice or suggestions?

    If it is a button, what is inserted for Rollover and Down state? I just recreated a shape button, with three different images for the states. All are in one PS-file as layers which I imported into Captivate. I kept Stretched checked in this case, because I know there is sometimes a slight change in size between states. Here are screenshots of Up, Rollover and Down state. The stroke was set to 0 for the shape, but to prevent all color contamination I also set stroke to the color of the background (light grey). In the first (Up) image you can clearly see where the stroke is due to truncation of the Question mark.
    Seems only possibility is in the creation of the PNG's? What was your work flow?

  • I have a problem with loading the PNG image

    I have a problem with loading the PNG image from site. For ex. go to icefilms com and is starts to load png like crazy CPU is huge and you can not shut down Firefox at least a minute. This is not just in this site but whit any one whit lots of pictures.
    Image from firefox: Picture [http://img836.imageshack.us/img836/9910/7312011103147pm.jpg 1] [http://img28.imageshack.us/img28/8505/7312011103249pm.jpg 2] [http://img706.imageshack.us/img706/5615/7312011103348pm.jpg 3 ][http://img827.imageshack.us/img827/8483/7312011103533pm.jpg 4]
    This is my Task Manager [http://img217.imageshack.us/img217/5715/7312011103621pm.jpg 1]
    - I try safe mode, same thing
    -All addons and plugins are ok
    Any idea why is this so big problem.

    i did both of them, but still the while sending the mail the diolog box is not showing up and also the spelling and grammer does not do the spelling check. 
    This problem just started for about 3 to 4 days now.  earlier it was working normally.

  • Problem with CFimage / PNG images

    I have a problem saving PNG images from another server, for example itunes, some work, some don't
    The following image will open fine in my browser ->
    http://a576.phobos.apple.com/us/r30/Purple/v4/de/60/bb/de60bb7f-8995-4007-cfec-1b0a472fa36 7/icon.png
    This is the error I am receiving:
    An exception occurred while trying to read the image.
    javax.imageio.IIOException: Error reading PNG metadata
    Code:
    <cfimage source="http://a576.phobos.apple.com/us/r30/Purple/v4/de/60/bb/de60bb7f-8995-4007-cfec-1b0a472fa36 7/icon.png" overwrite="true"  destination="#filepath#/9999.png"
        action = "write">
    I believe some images have malformed/incorrect headers. I'm guessing this is a CF issue (I use CF8), because it loads fine in a browser.
    Anybody have a solution to this? Maybe an alternative way to retrieve the image? Custom tag?
    Thanks
    Mark

    I found the issue and solution. The problem was with the Java, the JVM had issues reading SOME PNG's from servers, but not all, there must be a newer way of encoding them that was not around when the version of java I had was created, or it's just a bug. I had an earlier version of 1.6 which is downloaded as version SE 6 from Oracle.
    As per some instructions by Ben Forta I tried an update of the JVM to version 7 (1.7.x),
    http://forta.com/blog/index.cfm/2013/3/3/Upgrading-ColdFusion-To-Java-7
    The update worked on my local dev machine which was CF8 with Win 7 64bit, and it actually fixed the CFIMAGE issue!
    However, when I did the same update, with the same java file on the same version of CF8, CF would no longer restart throwing an error that it could not find a file.
    Luckily I had a backup of the config file because I could not switch settings back any other way if CF would not start the administrator (Java also makes a .BAK anyway)
    I tried the first build of version 7, same problem, so I went to the very last version 6, build 45, it installed, and it also fixed the CFIMAGE crash!
    A couple of points for anybody else trying this
    Make sure you have a back up the config, in CF8 it's located here (different to the location in Bens instructions)
    Coldfusion8\runtime\bin\jvm.config
    Also note that the forward and backward slashes are different for the built in JVM that ships with CF and is set in the administrator, and the location you will specify
    Original location: C:/ColdFusion8/runtime/jre
    New location: C:\Program Files\Java\jre7\
    Here is the location to the Java file (
    Java SE Runtime Environment 6u45)
    Java Archive Downloads - Java SE 6
    Took me days to get to the bottom of this, but the fix actually takes just a few simple steps and a few minutes, of course
    Mark

  • Usingservlets to create PNG images are not transparent in internet explorer

    11/01/2007
    I have used servlets to dynamically create a PNG image:
    response.setContentType("image/png");
    image = new BufferedImage(maxWidth, maxHeight, BufferedImage.TYPE_INT_ARGB);
    Graphics g2d = image.creatGraphics();
    g2d.setColor(new Color(128,0,250,128));
    g2d.draw......
    ServletOutputStream out = response.getOutputStream();
    ImageIO.write(image, "png", out);
    Works perfectly with transparency for Firefox. However in Internet Explorer
    it does not have any transparency, and also has a gray background as shown
    in http://www.apl.jhu.edu/~vnguyen/pngInIEbug.JPG. The image is simply the
    call to the servlet, which returns the PNG file. Tried using the fix presented in
    http://homepage.ntlworld.com/bobosola/index.htm without success. The
    overall program will produce several images layered on top of each other
    so transparency is key. Please help.

    Either put more research into the IE fix so you can make it work, or switch to using GIF images which will work.

  • Flatten two (or more) transparent PNG images (32 bit)

    Hello
    How to flatten two (or more) transparent (32 bit) PNG images.
    The result must be also a transparent (32 bit) PNG image.
    Solved!
    Go to Solution.

    Since you aren't really doing any alpha blending and just a simple mask I would do the following.
    The Picture to Pixmap VI, as you discovered, wipes out the mask, but you can restore it by simply OR-ing the two image masks.  I assume the two pictures have the same dimensions for simplicity, there are tricks if this isn't the case.
    I have also added a Version 8 (I hope) VI since that seems to be what you are using.
    Attachments:
    FlattenPNG.png ‏176 KB
    FlattenPNGv8.vi ‏161 KB

  • How do i set the transparency of an image retrieved from a database? (image was stored as blob)

    I had stored a png image into a database, when i retrieve it and display it the background is no longer transparent?
    I am loading the blob returned from the select statement by using the "loadBytes" method of the "UILoader" class.
    Thanx in advance
    gv1979

    If you want to stick with adjusting the scale you can do this two ways. Edit the value graph or edit the speed graph.
    The problem is that a camera move, a zoom or a dolly in, is not linear and scale is. This means the graphs are not a good representation of what you'll see visually. This makes them hard to use. At a constant rate for scale the appearance is that the increase in size slows down to closer you get to the final value. In other words, as you scale an object up at a constant rate, the visual appearance is a gradual slowing.
    A speed graph edited to look like this gives the appearance of a constant rate scale of the layer when you expect an acceleration at the end. There's just not enough granularity in the graph editor or enough control to predictably achieve the results you want.
    You'll have better luck editing the value graph to look something like this:
    While this looks extreme, you will get closer to achieving the results you want using the value graph. Once again, the amount of control and the resolution of the graph combined with the visual tomfoolery that scaling an object brings with it makes this a difficult way to achieve predictable results.
    You select the graph you'll edit by clicking on the second icon from the left.
    As I said before, you'll have much better luck getting the look you want if you make the layer 3D and move a camera toward it.

Maybe you are looking for

  • Lion OS & Office for Mac

    I have Office 2004 which is based on Rosetta and not compatible with Lion. I use it for Word. ( I get emails in that format and respond with a Word format. ) I believe the Lion OS is compatible with Office 2008 and 2011. Should I buy the Home Office

  • How to use postback property for JSF to reneder a popup only once

    Hi All, I'm using java script function to show a JSF page as popup. I have called the javascript function on page load of another JSF page. How do i make sure that the popup is getting rendered only once and not everytime the page is getting refreshe

  • How can I contact the administration for cancelling an invoice?

    Hi everyone, first of all sorry for my english. I just bought AbodeExportPDF but I made a mistake: I clicked twice on the button "buy now", I rightly received two invoices. How can I contact the administration for cancelling one of the invoices? Than

  • Re: Error in System Object in Portal

    Hi Experts, I have created a system and have given values for all the property category 1.WAS 2.ITS 3.Connector 1.when I do the connection test for ITS, I'm getting error saying "User mapping is not valid HTTP/S connection failed" 2.when I do the con

  • AOL Compatible with Mac OC X 10.5?

    I started from a clean install on my Alum iMac. Logged on to AOL via Safari and read mail with no problems. I then downloaded AOL software 10.3.7 Rev 4136.310 US. Then proceeded to set up my account. Sign on was normal but when I go to Preferences to