java

How to make a JLabel/BufferedImage semi-transparent?  #angularjs #reactjs

  • I want a picture that I take from my webcam to appear semi-transparent on TOP of this webcam feed.
  • I know that I can take this picture – when I do this, img2 appears on screen, completely covering up the webcam panel, and it is not at all transparent
  • Stack Overflow works best with JavaScript enabled
  • So first you learn how to make any image transparent, then you apply the knowledge to an image retrieved from the webcam.
  • layers = new JLayeredPane(); layers.setPreferredSize(WebcamResolution.VGA.getSize()); layers.setVisible(true); layers.setLocation(18, 0); webcam.setViewSize(WebcamResolution.VGA.getSize()); panel = new WebcamPanel(webcam); panel.setFPSDisplayed(false); panel.setDisplayDebugInfo(false); panel.setImageSizeDisplayed(true); panel.setMirrored(false); panel.setOpaque(true); panel.setBounds(layers.getX(), layers.getY(), WebcamResolution.VGA.getSize().width, WebcamResolution.VGA.getSize().height); /* * I set depth=9 for WebcamPanel, so as to set depth = 10 on pictures * you want to display, or to play a movie on the screen on TOP of the * WebcamPanel */ layers.add(panel, new Integer(0)); add(layers);

I’ve got a BufferedImage, which I add to a JLabel, and that I’m trying to make semi-transparent. Here’s how I’m doing it right now:

@ng_real_ninja: How to make a JLabel/BufferedImage semi-transparent? #angularjs #reactjs

, and that I’m trying to make semi-transparent. Here’s how I’m doing it right now:

so then I take a picture, called img, and I create a copy of it below and try to make it semi transparent, and add it to this JLayeredPane. I know that I can take this picture – when I do this, img2 appears on screen, completely covering up the webcam panel, and it is not at all transparent

, the bottom layer of which is a live webcam feed. I want a picture that I take from my webcam to appear semi-transparent on TOP of this webcam feed. But right now the picture doesn’t even show up. What am I doing wrong here?

I can’t speak for others, but it would be hard to tell what is wrong without a decent Minimal, Complete, and Verifiable example / sscce. – Hovercraft Full Of Eels 1 hour ago

My bad – I added more and I hope this helps – dgamz 1 hour ago

@dgamz, How can we compile and execute that code? Also, I doubt many people will have the webcam class. So any code you post should just be based on a simple frame with a JLabel and image. We are not testing your application, but the concept. So first you learn how to make any image transparent, then you apply the knowledge to an image retrieved from the webcam. – camickr 38 mins ago

java

You might also like More from author

Comments are closed, but trackbacks and pingbacks are open.