Set BufferedImage alpha mask in Java

I’m too late with this answer, but maybe it is of use for someone anyway. This is a simpler and more efficient version of Michael Myers’ method: public void applyGrayscaleMaskToAlpha(BufferedImage image, BufferedImage mask) { int width = image.getWidth(); int height = image.getHeight(); int[] imagePixels = image.getRGB(0, 0, width, height, null, 0, width); int[] maskPixels = … Read more

SVG fill color transparency / alpha?

You use an addtional attribute; fill-opacity: This attribute takes a decimal number between 0.0 and 1.0, inclusive; where 0.0 is completely transparent. For example: <rect … fill=”#044B94″ fill-opacity=”0.4″/> Additionally you have the following: stroke-opacity attribute for the stroke opacity for the entire object

How to set the opacity/alpha of a UIImage?

I just needed to do this, but thought Steven’s solution would be slow. This should hopefully use graphics HW. Create a category on UIImage: – (UIImage *)imageByApplyingAlpha:(CGFloat) alpha { UIGraphicsBeginImageContextWithOptions(self.size, NO, 0.0f); CGContextRef ctx = UIGraphicsGetCurrentContext(); CGRect area = CGRectMake(0, 0, self.size.width, self.size.height); CGContextScaleCTM(ctx, 1, -1); CGContextTranslateCTM(ctx, 0, -area.size.height); CGContextSetBlendMode(ctx, kCGBlendModeMultiply); CGContextSetAlpha(ctx, alpha); CGContextDrawImage(ctx, area, … Read more

How to set opacity of background colour of graph with Matplotlib

If you just want the entire background for both the figure and the axes to be transparent, you can simply specify transparent=True when saving the figure with fig.savefig. e.g.: import matplotlib.pyplot as plt fig = plt.figure() plt.plot(range(10)) fig.savefig(‘temp.png’, transparent=True) If you want more fine-grained control, you can simply set the facecolor and/or alpha values for … Read more

How to change a bitmap’s opacity?

As far as I know, opacity or other color filters can’t be set on the Bitmap itself. You will need to set the alpha when you use the image: If you’re using ImageView, there is ImageView.setAlpha(). If you’re using a Canvas, then you need to use Paint.setAlpha(): Paint paint = new Paint(); paint.setAlpha(100); canvas.drawBitmap(bitmap, src, … Read more

tech