Drawing images with transparent background on any AWT container control.

I have an AWT applet with some background image.
There is another image say of a size of an icon which
has a transparent background. This image can be
dragged anywhere on the applet.
I am using a panel of a size of an icon and drawing the
image on it. The whole panel is dragged when the user
drags the image.
The problem over here is, though the image has a
transparent background it is not appearing transparent
on the applet because the background of its container
i.e., the panel which is dragged along, itself is not
transparent.
My question is : "Is there a way to make a control, like a panel, background transparent in AWT or some other way that can produce a similar effect in AWT ?".
Please help me out.
Thanks.

Maybe the best way is to create your own component ( extending Component ) and then implementing paint() to do what you need.

Similar Messages

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

  • Printing Images with Transparent Background

    Sorry if this question has already been asked, but I couldn't find anything similar to it in a search through the archives.
    I have a couple of images with transparent backgrounds in a document, much like the shells and the blue flowers in the "Classic Brochure" template in Pages 2.0.1. These images show up perfect on the screen, and when printed as .pdf files, but when I print to either an hp color laserjet 4600 or an hp laserjet 1320, the images show up with a clear box around them; the colors under the box (where it should be transparent) are faded and slightly blurred. This happens both with my document, and the unaltered "Classic Brochure" template. I've tried moving various objects backwards and forwards, but it doen't seem to have any effect. It even happens with one of the text boxes I have in the document.
    Another odd thing is that the printed "box" isn't the same size as the box that appears when you click on the object in the document. It's a bit bigger. I've seen other posts about problems with hp printers, but I'm not sure it's related. Any insight would be appreciated.
    MAF
    iMac Intel Core Duo   Mac OS X (10.4.7)  

    http://indesignsecrets.com/eliminating-ydb-yucky-discolored-box-syndrome.php
    Bob

  • Image with transparent background als foreground of a button

    I'd like to build an app with buttons using the phone's accent Color as Background and an Image with transparent Background as foreground of the button. It should look like the tiles on the start screen of WP8.1.
    The following code doesn't work (no foreground appears)
    <Button x:Name="myButton" Background="{ThemeResource PhoneAccentBrush}">
     <Button.Foreground>
         <ImageBrush ImageSource="/Assets/myImage.png"/>                    
     <Button.Foreground>
    </Button>
    Are there any ideas?
    Thanks
    Martin

    Hi mfv_technet,
    The Foreground property is used to get or set a brush that describes the foreground color. So we can not bind the Foreground to a image,
    if I do not misunderstand you, in my mind if we want to set the button look like the tiles on the start screen of WP8.1, maybe you can try to refer to the following xaml:
    <Button x:Name="myButton" Foreground="Red" Background="{ThemeResource PhoneAccentBrush}" Margin="116,136,0,363" Width="195" Height="141">
    <Button.Content>
    <StackPanel Orientation="Vertical">
    <Image Source="/Assets/myImage.png" Width="80" Height="80"></Image>
    <TextBlock Text="Button"></TextBlock>
    </StackPanel>
    </Button.Content>
    </Button>
    The result:
    If I have misunderstood you, please feel free to let me know.
    Best Regards,
    Amy Peng
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • 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

  • Image with transparent background changes surrounding fill color when PMS...

    Hello.
    I have a .PSD image I'm using in InDesign CS3. It's a greyscale image with a transparent background. When I bring it into InDesign and set the background color of the image box to a Pantone and then print it, the PMS color within the area of the .PSD image size changes color compared to the rest of the page. But, when the same document is printed, but with "All Spot to Process" via the Ink Manager, the page prints fine. I get the same results on a number of different Canon and Xerox proofing printers. I have uploaded a PDF to my web server showing an example of the results I'm getting the PDF can be found here:
    http://theboyk.net/temp/PMSvsCMYK.pdf
    The first page is the document printed normally. You can see the color change in the green (Pantone Green). The second page is the same document printed with "All Spot to Process" via Ink Manager.
    Does anyone know why this happens when I leave it as printing a spot color?
    Any advice would be appreciated!
    Thanks,
    Kristin.

    I totally forgot to put that in my post.  Yes, I am putting logos with transparent backgrounds in front of colored rectangles.  That's how I noticed that this one logo is showing up with a white background.  The weird thing is that the other two logos are fine.  I did find a different version of this logo and this one works fine.  The one that works fine is a JPG and the one that shows up with a white background is a JPG.

  • Images with transparent background layers

    I have a number of .psd files with transparent backgrounds. If I import them into Aperture, they show up in the Browser and Viewer with black backgrounds. If I drag them into a Book, some of them behave as though transparent, but some retain the black background.
    I can't see any difference in the files themselves. They were all created by the same means. Why would some of them lose their transparency in Aperture and some retain it?

    Aperture doesn't support transparency at this time.
    I'm pretty surprised that any of them behave as though transparent.
    You should make the Image backgrounds the same color as the book pages to achieve a transparency effect.
    DLS

  • Image with transparent background shows up with a white background in ID

    Amateur needs help.
    I have a copy of a logo with a transparent background.  I made the (white) background transparent in PS by creating a layer from background and then selecting the white color in the background and deleting it.  This has always worked in the past.  But when I place this image into ID, it shows up with a white background.  I have tried saving as a PSD, TIF, JPG, etc.  I cannot get it to work. 
    I normally research these things until I find an answer, but I am on a tight deadline.  Thanks!

    I totally forgot to put that in my post.  Yes, I am putting logos with transparent backgrounds in front of colored rectangles.  That's how I noticed that this one logo is showing up with a white background.  The weird thing is that the other two logos are fine.  I did find a different version of this logo and this one works fine.  The one that works fine is a JPG and the one that shows up with a white background is a JPG.

  • How to insert image with transparent background?

    I have several logos saved at .GIFs with transparent backgrounds that I would like to import into my dashboard, but it seems that the image component only supports JPEG.  Is there a way to import images while maintaining their transparency?

    Well, you CAN insert GIFs or other image formats.  But I have yet to figure out a way to take a GIF with a transparent background and import it into my Xcelsius while preserving the transparency.  The transparent background always just defaults to white.
    This is a crucial feature as I have some logos I want to use that are circular.  But if I can't give them a transparent background, it drastically limits their placement options.
    I know that flash does support transparency, so am I missing something here?

  • Creating images with transparent backgrounds

    Hello all,
         I've got a swing app drawing program where you have multiple layers, with each layer containing many components that can be moved and resized. So, in the most simple form, I have a JComponent which has a list of images to be drawn. If I setOpaque to false, the background (and other layers) can be seen through the empty spaces of this component, as expected.
         The problem was that once the number of components grew above 300, performance started suffering. So I decided to optimize it. Instead of redrawing all of the components each time I need to paint, I 'cache' that layer by drawing all of the components in a layer onto an Image's graphic. Then I do a 'graphics.drawImage(cachedImage);' in my main JComponent's paint method.
         Very fast, but now I can't see the background (and other layers) beneath the topmost one.
         So now the question. Is there a way to preserve the 'setOpaque(false)' call when painting to the image. To be more specific, I want an image that is transparent except for graphics that I've drawn into it. I've even tried first filling the image with a 'new Color(255,255,255,0)', but I'm still getting an opaque image.
    thanks for any help,
    Steven     
    A Dynamic character with an ability to survive certain death, and a questionable death scene leaving no corpse? Face it, we'll never see her again... - Riff from Sluggy Freelance

    Using a TYPE_INT_ARGB BufferedImage worked beautifully. I had played around with Image for hours, but it never occurred to me that BufferedImage would be needed. :)
    many, many thanks,
    Steven

  • Using images with transparent backgrounds

    Hello. I'm trying to design several forms using a large background graphic along with several other overlays (defined by the form user) that contain transparent backgrounds. Unfortunately, everytime I go to change the graphic, the program won't recognize the transparency of the overlay and substitutes white in it's place. So, for example, I have a background image that is rectangular and when my form user selects an overlay that is circular, it inserts the circle with a white background (which is supposed to be transparent). Can anyone help me with this?
    Thanks!
    -Mike

    Min required version of flash player for my application is 9..
    I think I figured it out, Here is my solution:
    private function completeHandler(evt:Event):void
       var originalWidth:int=loaderG.content.width;
       var originalHeight:int=loaderG.content.height;
       var scale:Number = 0.5;
       var matrix:Matrix = new Matrix();
       matrix.scale(scale, scale);
       myBitmapDataObj=new BitmapData(originalWidth, originalHeight, true, 0xFFFFFF);
       myBitmapDataObj.draw(loaderG.content, null, null, null, null, true);
       var copyBitmapData:BitmapData= new BitmapData(originalWidth* scale, originalHeight* scale, true, 0x000000);
       copyBitmapData.draw(myBitmapDataObj, matrix, null, null, null, true);
       var myBitmapG:Bitmap=new Bitmap(copyBitmapData,PixelSnapping.AUTO,true);
       addChild(myBitmapG);
    I also try blur filter on my bitmap:
    var blur:BlurFilter = new BlurFilter();
       blur.blurX = 1.4;
       blur.blurY = 1.4;
       blur.quality = BitmapFilterQuality.HIGH;
       myBitmapG.filters = [blur];
    Or is there better solution?

  • Images with Transparent Backgrounds.

    I would like to have an image with a transparent background, so that any image underneath will show through. I know that this can be done with watermarks, but I would like the flexibility to move the image around on a book page background. Is this possible in Aperture?

    I still believe this a software problem with Pages
    Ah, but your belief is based on suppositions and the suppositions are not based on data processing developments -:)
    Apple Pages is a client of Apple ColorSync which is the Apple interface to the colour imaging architecture of ISO 15076 aka the architecture of the International Color Consortium. Apple ColorSync is also the interface to the Adobe PostScript colour imaging architecture for applications that depend on Apple Mac OS X to write Adobe PostScript, as Apple Pages does. Adobe InDesign, Adobe Illustrator, Adobe Photoshop, Adobe Acrobat, and QuarkXPress write their own PostScript, known as passthrough PostScript (cf the Adobe Acrobat interface, for instance).
    That aside, you want to begin by NOT configuring your inkjet printer(s) with uncoated copy paper. As a rule, uncoated copy paper has so much optical brightener that it positively fluoresces in broad daylight. Try measuring with a spectrophotometer, and you will see the *b channel in the CIELa*b D50 2 degree standard observer measurement way, way, way out in the negatives.
    Find the inkjet paper the manufacturer intended, and find the manufacturer's ICC profile for that paper. Then calibrate your printer as per the manufacturer's documentation, configure the ICC profile for that paper in the manufacturer's driver, and you should be OK. If you are not using a paper made by the manufacturer, find a photographer who can build you an ICC profile.
    Cheers,
    Henrik

  • Photoshop Image with transparent background - exporting gives me a white background ?

    Hi,
    OK, hours of my life have gone into this one already - I guess that's computers!  I have some images in Photoshop which already have transparent backgrounds, however when I try and drag these into a different program, they move across with a white box as their background.  I have tried saving as TIF, GIFF ... - all sorts, so I am clearly missing a pretty fundamental step that I can't see.
    Any help would be SO appreciated.
    Thanks.
    Doreen.

    Save as PSD or PNG, depending on whether you final output will be print or web. Then use Place instead of dragging the image over.

  • Saving image with transparent background for web/Dreamweaver

    How do I save a little image, so that the background stays transparent. I already have the image set up in Photoshop with a transparent background and have saved it as gif and png. When I import it into Dreamweaver the background stays white instead of transparent. What am I not doing right, since I read several posts saying that png and gif are the right formats to save in, if you want a transparent background?
    Thanks for any help with this,
    Anne

    Well now that you have told me to save with some sort of an alpha channel, it works perfectly.
    In CS5:
    Select layer,"Composition,Make movie". Then navigate to "Output module" and choose an option that has "alpha channel" in the title.Choose a name for your project "Output to". I now use "lossless alpha".I don't know if that is the best one, but it seems to be working fine.
    There is no "Quicktime" option in CS5 as in older versions of AE.
    I was trying to save as a video in general or for photoshop and that just wasn't working out well.
    I don't know what the "Frames to Layers import assistant" is that you mentioned though. I still tend to drag and drop, rather then import.
    Thanks for your help.

  • Question about images with transparent backgrounds in inDesign

    Hi,
    I've recently switched from Quark to inDesign CS5.5, and I'm trying to figure out how to do something that was easy in Quark but doesn't seem to work in iD. I'd like to colorize a greyscale image that has a transparent background. In Quark, I could import it as a TIF and then specify different colors for the image and background (which I could specify to be transparent). In iD, seems that the transparency needs to be included in Photoshop (which wasn't the case in Quark; the method worked for any greyscale TIF), and that I need to chage the color of the in original image if I want to keep that transparency. Also, from what I've read, the imported image works better as a PSD.
    Is this correct? Does the transparency and color need to be specified in Photoshop for me to have a transparent image? (The image is too complex to include a clipping path, and it's being placed on a photographic background, so I can't simply change the bckground image to a solid color to make it blend in).
    If this is the case, it's really disappointing--I was able to get some great effects in Quark using the other method. I hope I'm misunderstanding what to do, or there's some kind of workaround.
    Thanks in advance for any help,
    --Harriet

    ID will only colorize non-transparent grayscales or bitmap mode images. If you don't need continuous tone, saving in Bitmap mode will render the white areas transparent when you colorize ( if the frame itself has no fill color, else that fill color will show), but that's not much good if you need a true grayscale. Changing the blending mode of a colorized grayscle to Multiply will cause white areas to be come transparent, but other areas will multiply over any background, which may not be what you want, either.

Maybe you are looking for