Graphics.copyArea() and transparent pixels

Hi,
I have a problem with a JLayeredPane.
I have to paint a scrolling sampled signal on top of a grid. To do this I used a JLayeredPane where on the bottom layer there's a panel (let's call it GridPane) with the grid, and then some layers up I put another JPanel with setOpaque(false) that paints the signal (PaintPane). This way I have to paint the grid only one time, or so I thought.
Now when I try to scroll the signal I use the copyArea() function to scroll one pixel to the left then paint the next line of the trace.
The problem is that the copyArea() function ignores the transparent pixels and copies the grid that is behind them even when I'm using the PaintPane Graphics. This way is like i'm shifting the grid but I want it to be fixed.
So do all the components in the JLayeredPane share the same graphics? that would explain the behaviour of the copyArea() func.
Is there a way to tell the copyArea() func to copy also the transparent pixels, ignoring what stands behind them?
Thank you.

Nothing.
Apparently there's no way to just repaint that portion of graphics without repainting everything.
I now understand more on how transparent pixels are treated.
So, when I overwrite one of the pixels in the background in a way or another I have lost it forever. and it's my function that has to take care of repainting it.(usually repainting everything).
I hoped to improve performance with this method but, well, have to turn back on the old one.
Thanks again.

Similar Messages

  • How do you eliminate transparent pixels caused by glare coming from a painting and still retain org.

    How do you eliminate transparent pixels caused by glare from the sun coming off a painting and still retain orginal color and composition?

    You'll need to post the image for us to give advice.
    In general, the glare cannot be removed.  You can clone over the glare, but the cloned areas will not be the original underlying painting.  Depending on your image, acceptable solutions might be possible, as long as you are aware of what is actually being done.
    Ken

  • Cookie Cutter and removing transparent pixels

    Unlike crop, when I used the cookie cutter, the transparent pixels remained after I accepted the cut.  Doing a Ctrl-click in the Layers panel > Image menu > Crop, only did a crop rectangle delimited by the x/y max of the shape.
    Is there an easy way to remove all of them, that is following the outline of the shape?

    Every digital image ever is rectangular (or square). That's the whole point of transparency: it lets your rectangular image look like it's shaped like a star or a sailboat or a german shepherd, even though it isn't.

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

  • PS CS6 Shows Transparent Pixels Over Image When Zooming Past 50%

    I'm not sure why, but Photoshop just started doing this after I converted my files to a smart object. When I try to zoom in past 50%, it displays these transparent pixel squares over the entire image. I tried rasterizing and flatting the image back, but that didn't do anything. It seems to keep doing this. Any suggestions how I can fix this?

    That sounds like a typical display driver problem.
    If you have a PC, visit the web site of the maker of your video card, seek out and download/install the latest display driver for your hardware and OS, and reboot (even if it doesn't require it).
    If you're on a Mac, you might find that manipulating the graphics processor-specific settings in your Photoshop-Preferences-Performance dialog (and in the Advanced settings) might help.  Make sure to fully Quit and restart Photoshop after making changes there.
    -Noel

  • How do i stop PS from deleting transparent Pixels on layers?

    Hello community,
    i have a problem concering the place-function of Photoshop CS6. I want to include hundreds of png files in a psd file and i want them to keep their original size. Unfortinatly they have transparent borders and PS deletes these borders when you place the images in the PSD-file. For example: I have a square with x=50px and y=50px and it is positioned in an png with the dimensions x=100px and y=100px. I want to have these kind of files in my psd-file an need to keep their full dimensions, because my graphic specifications relate to the 100px/100px size and i need it later in my workflow.
    How do i stop PS from cutting off the tranparent borders of my images?

    Yes Free Transform has what was set during the place and you can see in the option bar if the layer has been scaled or is at 100 % width and height. You can also drag out guide line to the transforms bounding box. Then later measure the size or drop in a low opacity pixel in two diagonal corners to force the bounds to the png's canvas size.   However if you don't add those pixels in a script the bounds you get is that of the bounds of the non transparent pixels and in an action Ctrl|CMD clicking the layers content in the layers palette selects the non transparent pixels.
    My Photoshop Photo Collage populating scripts do not always fill an image area when they resizing odd shaped png images, However if the png is rectangular with transparent borders the script will fill the area with pixel for the scripts gets the bounds of the non transparent pixels, not the png canvas size. So resizing works well. There is a difference between layer size and canvas size in the png file. Layers can also be larger then canvas size in psd files Photoshop support any size layer you have the canvas act like a cropping mask on a document.
    Message was edited by: JJMack

  • Drawing transparent pixels into BufferedImage?

    Hi,
    I'm trying to do this:
    1) Create a BufferedImage
    2) Paint its background to black
    3) Paint a rectangle using a fully-transparent color
    4) Output this BufferedImage in the form of a PNG file using ImageIO
    My expectation is for step 3 to paint in "transparent" but what seems to be happening is that Graphics interprets my paint command as "draw nothing, it won't change the image anyway". Or maybe the PNG writer in JDK 1.5 does not actually output transparent pixels? Either way, I'm not getting the results I want. Any ideas?
    Thanks,
    Gili

    one should use Graphics.clearRect() for clearing a regionI'm not so sure about that. The API for clearRect states:
    ...the background color of offscreen images may be system dependent. Applications should use setColor
    followed by fillRect to ensure that an offscreen image is cleared to a specific color.
    So I tried to do as this suggests:
    import java.awt.*;
    import java.awt.image.*;
    import java.io.*;
    import javax.imageio.*;
    public class Test0 {
        public static void main(String[] args) throws IOException {
            int W = 100, H = 100;
            BufferedImage bi = new BufferedImage(W, H, BufferedImage.TYPE_INT_ARGB);
            Graphics2D g = bi.createGraphics();
            g.setColor(Color.BLACK);
            g.fillRect(0, 0, W, H);
            g.setColor(new Color(0,0,0,0));
            g.fillRect(W/4, H/4, W/2, H/2);
            g.dispose();
            ImageIO.write(bi, "png", new File("temp.png"));
    }...and it doesn't work?! I'm thinking this is a bug. What to do? Can't get enough of that Porter-Duff:
    import java.awt.*;
    import java.awt.image.*;
    import java.io.*;
    import javax.imageio.*;
    import javax.swing.*;
    public class Test {
        public static void main(String[] args) throws IOException {
            int W = 100, H = 100;
            BufferedImage bi = new BufferedImage(W, H, BufferedImage.TYPE_INT_ARGB);
            Graphics2D g = bi.createGraphics();
            g.setColor(Color.BLACK);
            g.fillRect(0, 0, W, H);
            g.setComposite(AlphaComposite.Clear); //<<---- magic pixie dust
            g.fillRect(W/4, H/4, W/2, H/2);
            g.dispose();
            ImageIO.write(bi, "png", new File("temp.png"));
            JLabel lbl = new JLabel(new ImageIcon(bi));
            lbl.setOpaque(true);
            lbl.setBackground(Color.GREEN);
            JFrame f = new JFrame("Test");
            f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            f.getContentPane().add(lbl);
            f.pack();
            f.setLocationRelativeTo(null);
            f.setVisible(true);
    }

  • Transparency/Transparent Pixels.

    Okay, I'm trying to get transparency working properly, but it's being a pain. I need to know a few things, which I can't locate online.
    1) Is alpha 0 opaque or is alpha 255?
    2) In the java docs they always refer to alpha as between 0.0 and 1.0; is it correct to assume 1.0 = 255? I remember in Flash it was reversed.
    3) Is transparency(either Bitmask or Transluscent) enabled by default for whatever image/buffer an applet uses?
    4) Is there anything I have to do other than g.setComposite(AlphaComposite.Src); to make it work in theory?
    Here's the thing - if I check the transparent colour on my backbuffer, it has alpha 255. I've got the BufferedImage set up as TYPE_INT_ARGB, and I call setComposite before drawing. Despite that, it insists on copying pixels with 255 alpha when I call drawImage();
    I'm baffled as to why. I tried some Java2D tutorials, and they don't seem to work when I copy the code in and compile it? Well, maybe someone can link me to a tut that applies to Java 1.5/1.6

    Here's an example I threw together, it draws a 100*100 blue square, then a smaller pink (half-alpha red) square in the middle of it.
    package sandbox2;
    import java.awt.Color;
    import java.awt.Graphics;
    import java.awt.Graphics2D;
    import java.awt.Toolkit;
    import java.awt.image.BufferedImage;
    import javax.swing.JFrame;
    public class TransEx extends javax.swing.JPanel {
        int width = 100;
        int height = 100;
        BufferedImage bimage;
        public TransEx() {
            this.setSize(width, height);
            // Create an image that supports arbitrary levels of transparency
            bimage = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB_PRE);
            Graphics2D g2d = bimage.createGraphics();
            // Make all filled pixels transparent
            Color blue = Color.BLUE;
            g2d.setColor(blue);
            g2d.fillRect(00, 00, 100, 100);
            Color pink = new Color(255, 0, 0, 63);
            g2d.setColor(pink);
            g2d.fillRect(20, 20, 60, 60);
            g2d.dispose();
            JFrame frame = new JFrame();
            frame.setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
            frame.add(this);
            frame.setSize(200, 200);
            frame.setVisible(true);
        public void paintComponent(Graphics g) {
            g.drawImage(Toolkit.getDefaultToolkit().createImage(bimage.getSource()), 0, 0, this);
        public static void main(String[] args) {
            new TransEx();
    }I was using setComposite(AlphaComposite.Src); on the bimage's graphics context, and it was drawing the pink square as solid red. It worked when I took that out.

  • Nvidia GeoForce Go 7600 graphics driver and IQ770 with Windows Vista Home Premium 32 bit edition

    I have been having problems with my screen for several months now:  every so often, for no apparent reason, it loses some of the pixels.  I can still read the items on the screen, but the resolution is trashed.  It happens intermittently and then goes back to normal.  I have tried uninstalling the graphics driver and letting the computer go find it on a reboot.  This does not work.  I have also tried installing the original graphics driver.  This does not work either.
    If I look in the "Problem Reports" area in Control Panel, there is a graphics related error: 
    Error Message: STOP 0x000000EA THREAD_STUCK_IN_DEVICE_DRIVER (Q293078)  The resolution listed is to reinstall the device driver (which I've tried dozens of times without success) or to change the computer's performance settings, which also does nothing.  I still get the occasional loss of screen clarity which returns to normal all by itself.
    Is anyone else seeing this problem?  Does anyone have a resolution?
    I have tried the latest graphics driver available on the hp website, from 8-2008 as well as the originally installed version from January 2007.  The version of Windows is Vista Home Premium 32 bit edition, Service Pack 1.
    If I completely uninstall the graphics driver, and do not reload any, the screen performance is fine, but then there are other problems, such as graphics acceleration.
    Thanks for your help.

    For the IQ700 series
    If you're running Windows Vista SP2, there is a patch for USB patch for NVIDIA chipsets
    http://support.microsoft.com/kb/975163/ 
    If you're running Windows 7, install this patch
    http://h30434.www3.hp.com/t5/Lockups-Freezes-Hangs/Driver-update-for-Win7-USB-issue-on-nVidia-chipse...
    And only use the driver from the system manufacturer's website or Windows Update. Do not use the latest drivers from NVIDIA's website for the IQ700 series

  • I want to delete all transparent pixels, how can I? CS6

    I would like to delete all transparent pixels surrounding my irregularly (non-square) image.  The TRIM function only trims to a square surrounding my image and not to the edge of the image itself.  Is there a work around for this?  I have looked around and haven't found one. 
    Thanks,
    JB

    Image have rectangular area they have a width and height boundaries as do layer.  Not all of the rectangular area need to have content or be fully opaque,  However the image boundary is a rectangle.  Some file formats are like a Photoshop Background layer do not support empty area or even transparency so those file formats only contain image that are rectangles and have no transparency. Some file formats support transparency and empty areas so those images can be any shape and contain transparency still the image boundary is rectangular. Then there is the GIF file format an oddball format. It only supports 256 Colors. Pixels are mapped to one of the 256 colors selected for the image.  If you want Transparency in a gif  the number of colors is reduced by 1 to 255  the 256 color now indicate no content its not real transparency it just a no color pixel in other words off or no content.
    So if you have areas that are 100% transparent there is nothing to delete the area is empty.  If you have pixels that contain some transparency and you delete those pixels you delete details are you sure you want to delete all pixels that contain transparency? You will loose things like drop shadows

  • How to edit transparency pixels in a FilterPlugin?

    I want develop a fiter plugin of photoshop. while i am not clearly about some issues:
    (1) how does the photoshop provide the transparency data ( blank data ) to me ?
    in other words, i want obtain the "alpha" channel data, is this provided by the "inData" together with other channels?
    (2) I want to change the pixel's transparency, means i want change totally transparent pixels into
    opaque. how to do it ?
    (3) in the pluginName.r file,there are 7 entries in FilterCaseInfo like following. is there anything i must pay special attention to?
      FilterCaseInfo
        /* Flat data, no selection */
        inWhiteMat, outWhiteMat,
        doNotWriteOutsideSelection,
        filtersLayerMasks,
        worksWithBlankData,
        copySourceToDestination,
    By the way, When i invoke a filter (i develop it 2 yeas ago) on the transparency document , photoshop gives a messagebox said it canot invoke the fiter because the selection area is totally empty.
    if the area has both transparency and opaque pixels, then the plugin cause write access faled and made the photoshop crash ,  why does this happen, how to avoid it.
    Thanks a lot.!

    First off, don't confuse "alpha" with "transparency" they are different.
    If I create a RGB document with one layer and call the Dissolve example I get the following bits of information in the FilterRecord:
    planes = 4
    imageMode = 3 // plugInModeRGBColor
    filterCase = 4 // filterCaseEditableTransparencyNoSelection
    inLayerPlanes = 3
    inTransparencyMask = 1
    plane 0 = red, 1 = green, 2 = blue, 3 = transparency
    See DoFilter, the loop on the planes, and DissolveRectangle, the changing of the data on each plane, in the Dissolve.cpp example file.
    Now flatten the document and create an alpha channel and select all channels via the channels panel. Selecing just the alpha channel or any one channel will have different results.
    planes = 4
    imageMode = 3 // plugInModeRGBColor
    filterCase = 2 // filterCaseFlatImageWithSelection
    inLayerPlanes = 0
    inTransparencyMask = 0
    inNonLayerPlanes = 4
    There is some documentation about FilterCaseInfo in the Plug-in Resource Guide.pdf found in the documentation folder.

  • Crop document by transparent pixels

    Hi,
    I have a question on you. I need crop document by transparent pixels.
    But I don't know, how to do it.
    Document has function crop but it need width and height.
    Do you know function with transparent pixels??
    Than you Domaneni

    Here is an example.
    app.activeDocument.trim ( TrimType.TRANSPARENT );// assumes you want to trim all edges

  • About sprite3D with fully transparent pixels

    I have a image with fully transparent pixels. want to use in a sprite3D object. But all of fully transparent pixels is rendered as white. There is no transparent at all. How can I do it or if the Sprite3D is not support transparent?
    best regards and Thanks any reply.
    The init code is :
    Image sprImg = Image.createImage("/spr.png");
    Appearance sprApp = new Appearance();
    Sprite3D spr3D = new Sprite3D(true,new Image2D(Image2D.RGBA,sprImg),sprApp);
    spr3D.setCrop(sprTexX,0,52,128);
    sprTran.setIdentity();
    sprTran.postTranslate(0.f,2.f,5.f);
    sprTran.postScale(2.f,4.f,1.f);

    Hi Sniper_bat,
    I want to do exactly the same thing, did you ever fix this problem?
    Dan

  • Trim Transparent Pixels

    I cropped the photo to 16x20. With this crop I ended up with some transparent pixels on the right and left edges. I used the Trim tool to remove the transparent pixels. Question - after removing the transparent pixels with the Trim tool do I still have a full 16x20 photo ready for printing OR because I chopped off the transparent pixels my photo has shrunk to a slightly smaller size?

    I started with a photo that I cropped to 16x20. With this 16x20 crop I had some transparent pixels. I trimmed the transparent pixels off. By trimming did I decreased the size of the 16x20? I did NOT recrop after the trimming.

  • Why are my transparent pixels becoming opaque (grey)?

    I have PSE 6, and am using it for digital scrapbooking. Some of the elements have transparent pixels, which allows you to see the background and layers beneath the elements. For some reason, when I drag one of these elements onto a background or another element, the transparent pixels become gray, creating an ugly grey box around the element. Also, I see when the new layer is created (on the background), by dragging the element onto the background, it becomes a "frame layer". Not sure exactly what that means, but I am thinking it might have something to do with this problem.   Hopefully someone has a suggestion
    thanks

    Have a look at  #5 in the link below which describes this "feature" and how to get around it.
    http://blog.hummiesworld.com/2007/10/bugs-and-complaints-of-photoshop.html

Maybe you are looking for

  • Driver program for MEDRUCK_SCHEDAGR

    Hi All, Can you please let me know standard driver program for Scheduling Agreement (ME31L) Adobe Form MEDRUCK_SCHEDAGR. Thanks, Samrat

  • Java.rmi.ServerException:

    I am new to RMI concept i stuck with the below problem when i execute E:\MyProjects\StockRMI>java -Djava.security.policy=policy.all StockMarketServerStockMarketServer is as shown below import java.rmi.*; import java.rmi.server.UnicastRemoteObject; im

  • Can only render Audio of QT,video is black

    I received a Quick Time file via Dropbox. It's 1280x720, 23.98fps, Compressor H264, Square Pixel. It plays in QT player.  But after I imported it in FCP v7 the video doesn't move, only the Audio plays after being rendered for Playback. The Video cann

  • How to Delete complete package from R/3

    Hello Friends, I've deleted all the subojects of a package and then tried to delete the package name. But still i'm getting a message stating still the package contains subobjects. Please guide me how i can proceed further. Thanks in advance! Best Re

  • How the cache.invoke() works?

    Hi, I am trying to play with the coherence 3.4.2 to find out how the cache.invoke() works. I modified the SimpleCacheExplorer.java coming as the example code as following: 1) I defined a distributed cache as following: <?xml version="1.0"?> <!DOCTYPE