alphablending
Remove transparency/alpha from any image using PIL
This can be done by checking if the image is transparent def remove_transparency(im, bg_colour=(255, 255, 255)): # Only process if image has transparency (http://stackoverflow.com/a/1963146) if im.mode in (‘RGBA’, ‘LA’) or (im.mode == ‘P’ and ‘transparency’ in im.info): # Need to convert to RGBA if LA format due to a bug in PIL (http://stackoverflow.com/a/1963146) alpha = … Read more
Multiple transparent textures on the same mesh face in Three.js
Use ShaderMaterial and set both textures as uniforms, and then blend them within shader. I made this example: http://abstract-algorithm.com/three_sh/ and that really should be enough. So, you make ShaderMaterial: var vertShader = document.getElementById(‘vertex_shh’).innerHTML; var fragShader = document.getElementById(‘fragment_shh’).innerHTML; var attributes = {}; // custom attributes var uniforms = { // custom uniforms (your textures) tOne: { … Read more
blend two uiimages based on alpha/transparency of top image
This is what I’ve done in my app, similar to Tyler’s – but without the UIImageView: UIImage *bottomImage = [UIImage imageNamed:@”bottom.png”]; UIImage *image = [UIImage imageNamed:@”top.png”]; CGSize newSize = CGSizeMake(width, height); UIGraphicsBeginImageContext( newSize ); // Use existing opacity as is [bottomImage drawInRect:CGRectMake(0,0,newSize.width,newSize.height)]; // Apply supplied opacity [image drawInRect:CGRectMake(0,0,newSize.width,newSize.height) blendMode:kCGBlendModeNormal alpha:0.8]; UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); … Read more
Is it possible to render web content over a clear background using WebKit?
Solved! Through ongoing research, scouring forums and source code repositories, I peiced together the necessary steps to accomplish this using only libwebkit and a standard compiz desktop (any Xorg desktop with compositing should do). For a current libwebkit (1.1.10-SVN), there is an Ubuntu PPA: deb http://ppa.launchpad.net/webkit-team/ppa/ubuntu jaunty main deb-src http://ppa.launchpad.net/webkit-team/ppa/ubuntu jaunty main As far as … Read more
Creating a transparent window in C++ Win32
I was able to do exactly what I wanted by using the code from Part 1 and Part 2 of this series: Displaying a Splash Screen with C++ Part 1: Creating a HBITMAP archive Part 2: Displaying the window archive Those blog posts are talking about displaying a splash screen in Win32 C++, but it … Read more
How to calculate an RGB colour by specifying an alpha blending amount?
The standard blending equation is: out = alpha * new + (1 – alpha) * old Where out, new and old are RGB colors, and alpha is a floating point number in the range [0,1]. So, you have (for red): 240 = 0.1 * newR + 0.9 * 255 Solving for newR, we get: newR … Read more