I am making some parts of java image transparent b

2020-04-17 07:18发布

The image without transparency is just not visible in other laptops.

Also when I make a new Eclipse project:

  • When I copy paste code in separate class files, it works fine on my machine, but not on others, with same code and project settings.
  • The images in bin are not copied, I have to copy the images separately.

Here is code used for transparency.

public static class Transparency 
    {
          public static Image makeColorTransparent(Image im, final Color color) 
          {
            ImageFilter filter = new RGBImageFilter() 
            {
                  public int markerRGB = color.getRGB() | 0xFF000000;

                  public final int filterRGB(int x, int y, int rgb) 
                  {
                    if ( ( rgb | 0xFF000000 ) == markerRGB ) 
                    {
                      // Mark the alpha bits as zero - transparent
                      return 0x00FFFFFF & rgb;
                    }
                    else 
                    {
                      // nothing to do
                      return rgb;
                    }
                 }
            }; 

        ImageProducer ip = new FilteredImageSource(im.getSource(), filter);
        return Toolkit.getDefaultToolkit().createImage(ip);
        }
    }

I want to make multiplayer game. So its vital that it should run on other laptops...

1条回答
家丑人穷心不美
2楼-- · 2020-04-17 08:05

solved the problem by making the image bmp/png file format, works on both comps, used ImageIO.read to get the bmp imagw

查看更多
登录 后发表回答