alpha

php - set alpha of each pixel in image

此生再无相见时 提交于 2019-12-08 10:49:11
问题 I want to set the alpha of each pixel in image using php gd functions. So far i have this: $src = imagecreatefrompng('image.png'); $w = imagesx($src); $h = imagesy($src); $alpha = 204; for ($x = 0; $x < $w; $x++) { for ($y = 0; $y < $h; $y++) { // set $alpha for each pixel in $src } } imagepng($src); imagedestroy($src); 回答1: Alpha have to be defined into 0 and 127. Then you have to use imagealphablending() and imagesavealpha() to save and use alpha. $src = imagecreatefrompng('image.png');

GTK drawable area transparent background color

陌路散爱 提交于 2019-12-08 10:43:59
问题 I have a GTK drawing area and I want to have an image display as the background for it, while other things can be drawn over it. My first attempt at this involved me simply taking the image, putting it into a pixmap, and drawing it before I draw other objects. This resulted in the objects backgrounds completely covering my background image. Now I am thinking I need to change the object's pixmap's gtk.gdk.GC so the background color it has is transparent. Here is where I am having problems. I

Subtraction of colours - Need to get the transparent value of a colour

我们两清 提交于 2019-12-08 09:52:35
问题 I was just trying to get the rgba value of a rgb-colour (#ebfcff). The rgb-colour is the rgba when put on a white background. (a stands for alpha) So: searchedColour + #ffffff = #ebfcff In my assessment the solution would be to subtract white from #ebfcff. But how do you subtract colours ? I already searched for an adequate solution. Does anyone know how to subtract white from a given RGB-Colour to get a new colour, which is in rgba-format, that equals the given colour when it gets overlapped

Why doesn't alpha blending work in ortho?

时光总嘲笑我的痴心妄想 提交于 2019-12-08 05:23:00
问题 This is how I turn on ortho projection after drawing 3D objects: glMatrixMode(GL_PROJECTION); glLoadIdentity(); glOrtho(0,Screen_Width,Screen_Height,0,0,1); And this is how I turn on blending and draw textures in ortho after drawing 3D objects: glEnable(GL_TEXTURE_2D); glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA); glColor4f(1,1,1,1); glBindTexture(GL_TEXTURE_2D,Texture1); glBegin(GL_QUADS); //draw 1st quad glEnd(); glBindTexture(GL_TEXTURE_2D,Texture2); glBegin(GL

How to create semi transparent white window in XLib

老子叫甜甜 提交于 2019-12-08 04:28:08
问题 I would like to create a semi transparent white window in XLib, but the window is not semi translucent, it remains fully opaque. I use the compton compositor and there are transparent windows in the system, so the problem is in the code: #include <X11/Xlib.h> #include <X11/Xutil.h> #include <stdio.h> int main(int argc, char* argv[]) { Display* display = XOpenDisplay(NULL); XVisualInfo vinfo; XMatchVisualInfo(display, DefaultScreen(display), 32, TrueColor, &vinfo); XSetWindowAttributes attr;

Drawing a transparent BufferedImage over a non-transparent BufferedImage

时光怂恿深爱的人放手 提交于 2019-12-08 04:11:08
问题 I'm having a problem when it comes to drawing BufferedImages. I'm working on a 2D tile-based map editor and when I draw a tile, it first draws the lower layer followed by the top layer. like so: public void paintComponent(Graphics g) { super.paintComponent(g); g.drawImage(tileLayer, 0, 0, null); g.drawImage(objectLayer, 0, 0, null); } Note that this method is in a class which extends JLabel. It's actually redrawing the ImageIcon which was set. Now, to understand the problem you must realize

Hide UIView using alpha when user starts scrolls on UITableView?

ⅰ亾dé卋堺 提交于 2019-12-08 01:24:06
问题 viewController is composed of 2 main views. A container view and a table view. The container view is the top section with all the labels such as the day and score. I want this container view to hide when a user starts scrolling through the days of the table view. So far I have: Hooked up an IBOutlet for this container view so I could reference it in the code. Conformed to the UIScrollViewDelegate Implimented all required methods for the UITableView I know UITableView is a subclass of

iPhone OpenGL ES 2.0 blending with Cocos2D gives unexpected results

Deadly 提交于 2019-12-07 10:24:52
问题 I have very simple CCScene with ONLY 1 CCLayer containing: CCSprite for background with standard blending mode CCRenderTexture to draw paint brushes, with its sprite attached to root CCLayer above background sprite: _bgSprite = [CCSprite spriteWithFile:backgroundPath]; _renderTexture = [CCRenderTexture renderTextureWithWidth:self.contentSize.width height:self.contentSize.height]; [_renderTexture.sprite setBlendFunc:(ccBlendFunc){GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA}]; [self addChild:_bgSprite

Imagemagick gif overlay preserves alpha on background

*爱你&永不变心* 提交于 2019-12-07 09:29:43
问题 I am using this code to build an animated gif from a sequence of pngs: convert -dispose previous -resize 400x400 -delay 10 *.png -loop 0 -coalesce -layers Optimize output.gif. it creates a gif with transparency, but when I overlay it over a jpg background, I get a weird result where a transparent box remains in the final image under my moving gif but over the jpg. From my tests, it seems this is a problem with the way I am building the original gif, but I have no idea. Also, I am stuck using

Add alpha to shader in Unity3D

风流意气都作罢 提交于 2019-12-07 07:58:56
问题 I don't have any idea about shader programming but right now I need to add alpha to the shader that I want to use. Actually I want to fade in and fade out my sprite but it's not in the shader that I use. Shader : Shader "Sprites/ClipArea2Sides" { Properties { _MainTex ("Base (RGB), Alpha (A)", 2D) = "white" {} _Length ("Length", Range(0.0, 1.0)) = 1.0 _Width ("Width", Range(0.0, 1.0)) = 1.0 } SubShader { LOD 200 Tags { "Queue" = "Transparent" "IgnoreProjector" = "True" "RenderType" =