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.

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.

  • How do I get picture control to display PNG images with transparent background?

    I have an image of a robot arm looking from the top with a transparent background and saved as PNG. When I drag the image directly to LabVIEW front panel, the image shows properly with the transparent background, but I want to manipulate it such as rotate the image. I used the Read from PNG.vi to read the image to a picture control, but the background isn't transparent anymore. Am I missing something?
    Please help.

    unclebump gets 5 stars for referring you to a document that I wrote. 
    Incidentally, I wrote it years back, for LabVIEW 7.0.  A couple of notes to summarize:
    The picture control doesn't "really" support transparency.  However, the image data type supports masking, and stores the alpha channel, if present in your image data.  So you use the "Create Mask By Alpha.vi" referenced in that document to mask out pixels whose transparency is above a certain level.  It does not support partial transparency.  You could try to implement your own blending algorithm based on the picture control's current pixel values, and the image data's RGB value and transparency value, but it would probably be very slow.
    Also, that VI ships with 8.0 and later.  I don't know if it's on the palettes but it lives here:  vi.lib\picture\picture.llb\Create Mask By Alpha.vi
    Good luck!

  • 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)

  • Graphics, ImageIO, and 32-bit PNG images with alpha-channels

    I have a series of 32-bit PNG images, all with alpha channels. I'm using ImageIO.read(File) : BufferedImage to read the PNG image into memory.
    When I call graphics.drawImage( image, 0, 0, null ); I see the image drawn, however all semi-transparent pixels have a black background, only 100% transparent pixels in the source image are transparent in the drawn image.
    The Graphics2D instance I'm drawing to is obtained from a BufferStrategy instance (I'm painting onto an AWT Canvas).
    Here's my code:
    Loading the image:
    public static BufferedImage getEntityImage(String nom, String state) {
              if( _entityImages.containsKey(nom) ) return _entityImages.get( nom );
              String path = "Entities\\" + nom + "_" + state + ".png";
              try {
                   BufferedImage image = read( path );
                   if( image != null ) _entityImages.put( nom, image );
                   return image;
              } catch(IOException iex) {
                   iex.printStackTrace();
                   return null;
         private static BufferedImage read(String fileName) throws IOException {
              fileName = Program.contentPath + fileName;
              File file = new File( fileName );
              if( !file.exists() ) return null;
              return ImageIO.read( new File( fileName ) );
         }Using the image:
    Graphics2D g = (Graphics2D)_bs.getDrawGraphics();
    g.setRenderingHint( RenderingHints.KEY_ANTIALIASING , RenderingHints.VALUE_ANTIALIAS_ON);
    public @Override void render(RenderContext r) {
              Point p = r.v.translateWorldPointToViewportPoint( getLoc() );
              int rad = getRadius();
              int x = (int) p.x - (rad / 2);
              int y = (int) p.y - (rad / 2);
              BufferedImage image = Images.getEntityImage( getCls(), "F" );
              r.g.drawImage( image, x, y, null );
         }

    You may want to check on you system and see what ImageReaders are available, it could be ImageIO is just not picking the best one, if not, then you can use getImageReaders to get an iterator of image readers, then choose the more appropriate one.

  • Safari on iphone won't render cgi generated png images with query strings

    I've got a cgi app functioning as a web service that generates png images and serves them up as part of another app which marshals them up in HTML.
    Here's the image stand alone:
    http://cybre.net/maps/mapgen.pl.png?WIDTH=1024&HEIGHT=768
    and here's how I marshal it:
    <IMG CONTENTTYPE='image/png' SRC='http://cybre.net/maps/mapgen.pl.png?WIDTH=1024&HEIGHT=768'>
    It seems to work on firefox, epiphany and galeon web browsers for linux, and my windows friends say that internet explorer renders them okay as well.
    My only apple hardware is my iphone, and safari pretends that there is no content when it renders the HTML page. Safari on the iphone does not render even using a direct link.
    The png is generated by perl mapscript, $img = $map->draw;
    print "content-type: image/png\n\n";
    $img->write;
    close(STDOUT)
    On the previous version of the iphone firmware, and before i factored the image generation out into a web service, the iphone was able to render the png image successfully.
    Is this safari wierdness where it gets cranky that there is
    QUERY_STRING info after the .png? mapgen.pl.png?foo=bar ?
    If so, are other browsers just being hyper liberal in what they accept and safari is playing by the rules or is this a bug in safari?
    thanks in advance,
    -marc

    it turns out that safari's handling of png is broken, the problem reproduced on both iphone and mac safaris.
    in changing the format to gif, it all works okay.
    does apple allow mortals to file bugs against safari?

  • 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

  • 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

  • Export PNG images with alpha channel from flash

    Hi,
    I have this FLA with animation and when played, the animation has alpha channel. I can’t understand why when I look in the library I see the frames without the alpha channel and also when I try to export/extract the image again the image don’t have alpha channel.
    How is it that in flash this image has alpha channel and how to get it out like that into PNG?
    Here is the link to download the FLA:
    http://download759.mediafire.com/nb749r29220g/e0636ab0ru6ouoa/Untitled-1.fla

    "when played, the animation has alpha channel"
    how are you playing the animation? control/enter in Flash, Publishing to a Web page or what?
    How can you tell that the animation has the alpha channel? What exactly are you seeing?
    What is the aniimation? a series of images, one image moving? Are teweens imvolved?
    " when I try to export/extract the image again the image don’t have alpha channel"
    How are you exporting the image? is it a single image? or a series of frames that makes up an animation?
    What was the file format of the original image? you brought that image into Flash and animated it? Now you want to export as a .png with transparency?
    Have you ever tried to export a  simple .png before so that you see and understand the dialog box that pops up during export? are you chosing "24 bit with alpha channel" in the "Colors" choice?
    For those of us who may not want to download your file, please provide a more detailed describtion of everything related to this question.
    Best wishes,
    Adninjastrator

  • Huge thanks - Mac problems with Type A new firmwar...

    Since I got the upgraded Type A firmware on my HomeHub 3 its messing my wifi on my macbook pro. Every other device is fine, the macbook works fine on other connections.
    The connections stalls for 30sec or so, disconnects all games, apps etc.
    Then comes back on.
    Spent 45mins onto India tech support, the girl had no idea what firmware was and kept blaming my macbook. Ive worked for o2 broadband support, i know what the problem is the HomeHub. Problems started 23rd Nov when i got upgrade.
    I email and a lovely lady has a Type B on the way next day, took 2 emails.
    Seems to get things sorted, you need to escalate.

    Hi BuckleZ
    I am sorry you are having problems.  Could you drop us in an email please and we'll have a closer look.
    Use the 'contact us' form in my forum profile under the 'about me' section. You can find it by clicking on my username.
    Thx
    Craig
    BTCare Community Mod
    If we have asked you to email us with your details, please make sure you are logged in to the forum, otherwise you will not be able to see our ‘Contact Us’ link within our profiles.
    We are sorry but we are unable to deal with service/account queries via the private message(PM) function so please don't PM your account info, we need to deal with this via our email account :-)”
    td-p/30">Ratings star on the left-hand side of the post.
    If someone answers your question correctly please let other members know by clicking on ’Mark as Accepted Solution’.

  • 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?

  • Images with transparent backgrounds in MDM

    I've got several images in MDM with transparent backgrounds, yet when i look at these in image manager (or thumbnails in data manager) they look terrible. The transparency is black for example, among other issues. These images are all okay in photoshop, they have been saved as .png and imported through the data manager.
    Has this import ruined these image files on the way in? When my search engines etc extract the images, what of the transparencies?

    Hi Adam,
    MDM makes use of Internet Explorer quite frequently. I can imagine that this engine is also used to display images in MDM. However, Internet Explorer in version 6 does not support transparency in PNG images. That is why the black background occurs.
    Since your images after upload are only saved in a binary object in the database, you should not encounter any data loss when using the same images. If you need to create variants, I would consider using Photoshop for the creation of those.
    I hope that helps you further.
    Best regards
    Christian

  • 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

  • PNG Semi-Transparent background shows up with visual errors in code view in Dreamweaver CS5

    Hi,
    I am using an image as a visual divider between blocks of content for a template that I am making. The background is a PNG image with varying amounts of transparency. This background is set to be at the bottom of the div and creates a horizontal line. Everythign works out when the page is viewed in browser, and also in live-view inside dreamweaver. But once I view it in code view, the lines turn into jagged green distortions. I asked friends to run this in their dreamweaver and it is happening to them as well. Any help is appreciated. Thanks.

    I guess you're referring to 'Design View'.
    Design View is only more from a reference perspective - it doesn't render graphic elements the way it is supposed to, always.
    But, you did mention that it looks just fine in Live View, right?
    Btw, can you post the CSS rule you've applied to this DIV where you add the background image for the separator line?

  • Image content type in Site Asset Image library: The Preview and Thumbnail Preview columns do not display the picture of the item.

    I have two different Site Asset libraries.  The Site Asset Picture library has items of
    content type picture.  The Site Asset Image Library has items of
    content type image. 
    1) I do not quite understand the different between a picture content type versus an image content type. 
    2) the thumbnail and preview columns do not display the image in the Site Asset
    Image Library.  (the image does display in the thumbnail column of the Site Asset Picture library.)  I expected the image to display in the Site Asset Image Library the same as it does in the Site Asset Picture library. 
    Why doesn't it?
    Betty
    Betty Stolwyk

    I have subsequently found out that our "Site Asset Images" library is a Document Library to which someone must have replaced the Document content type with an Image content type.  I also found out that picture previews/thumbnails cannot be displayed
    in Document libraries.  So the problem was the library type, not the content type.
    So I simply created a new Picture Library (whose content type = picture) and copied the files into that and the thumbnails displayed just fine!
    I bet what led to this is the default "Site Assets" library that is created for a new Team site.  It is just a document library but sounds very similar to the "Assets" library.  I can imagine someone thinking the "Site Assets" library was a standard
    container for images, and simply changed the name to better identify the content! 
    As far as 'image' vs 'picture' content types, I noticed that a new Picture Library contains a content type of 'picture', but an Asset Library contains a content type of 'image' (as well as audio and video).  Although the 'image' content type has a few
    more fields than the 'picture' content type (picture content type does not have thumbnail), the actual Picture Library contains pretty much all the same fields, including the thumbnail.  So for all practical purposes, either library type can be used for
    storage of pictures.  I am guessing that the Pictures Library which uses the picture content type is for backwards compatibility purposes, and that the 'image' content type is newer, being derived from the new "Rich Media Asset" content type and used
    in the new Asset Library which can hold audio and video in addition to pictures.  
    Microsoft Help also mentioned that a Picture Library has a slide view which an Asset library does not.  So my take on that is that if you want the potential of seeing your pictures as a slide show, put them in a Picture library which is still using
    the 'picture' content type of previous SharePoint versions.  If you want to keep pictures organized with audio/video files, then put them into an Asset library which uses the  'image' content type derived from the new Rich Media Asset content type.
    Betty Stolwyk

Maybe you are looking for