alpha-transparency

Using an alpha transparent mask on a QWidget?

别来无恙 提交于 2019-12-02 01:14:07
Is it possible to assign an alpha-transparent mask to a QWidget? I know how to set a mask using setMask but it seems it only supports black&white masks. Is it possible to make it support a true alpha channel? i.e. currently I have a PNG like this: and a widget like this: If I load my PNG in a QPixmap and set it as a mask, I get this (notice the edges): However I would like to get this (smooth edges): Any idea how to do that? Note: I'm doing some more complex drawing on the widget, which must be restricted to the mask area, so I cannot simply set my PNG as the widget's background image. sam-w I

Implementing Cursor in Java with some Transparency

不想你离开。 提交于 2019-12-01 18:23:08
问题 I have a 35x40 px. png image I want to use as a custom cursor in a Swing application. The image has a glow so contains alpha transparency values. Problem is when I attempt to use the conventional method of using the Toolkit to generate the custom cursor I get black pixels where alpha transparency values should be. Here is the image I am using for a cursor: https://dl.dropbox.com/u/1186703/cursor.png Here is my code: public static void main(String[] args) throws IOException { new Sandbox().gui

Implementing Cursor in Java with some Transparency

假装没事ソ 提交于 2019-12-01 17:50:49
I have a 35x40 px. png image I want to use as a custom cursor in a Swing application. The image has a glow so contains alpha transparency values. Problem is when I attempt to use the conventional method of using the Toolkit to generate the custom cursor I get black pixels where alpha transparency values should be. Here is the image I am using for a cursor: https://dl.dropbox.com/u/1186703/cursor.png Here is my code: public static void main(String[] args) throws IOException { new Sandbox().gui(); } private Cursor cursor; private Toolkit kit; private Image cursorImage; public void gui() { kit =

Python Image Library - Make area of image transparent

[亡魂溺海] 提交于 2019-12-01 09:25:48
I have a quick question for someone who knows the Python Image Library better than I do. I have a png image with an alpha-channel, and I want the top two rows of pixels to be completely transparent. That's it! So far, my efforts make the top two rows transparent, but the original image loses it's alpha-channel information. Anyone know the best way to achieve this? You can do this way. img = Image.open("withAlpha.png") p = img.load() for y in range(2): for x in range(img.size[0]): t = list(p[x,y]) t[3] = 0 p[x,y] = tuple(t) img.save("result.png") I would do it the following way: img = Image

Rendering QWidget to QImage loses alpha-channel

我怕爱的太早我们不能终老 提交于 2019-12-01 06:54:58
问题 I have a simple Qt widget. It's a QLabel with a simple CSS style applied. The important part of the style is a round border: QString css("border-style: solid;" "border-width: 3px;" "border-radius: 7px;"); It is displayed on screen fine. The corners of the label beyond the border are filled with transparent color, so it looks great on any background. Here's how it looks when displayed over another widget (which has dark grey background color): Now, when I render it to QImage like so QImage

How to draw a bitmap on a canvas, respecting alpha values of the bitmap?

点点圈 提交于 2019-12-01 06:40:36
background i have a master bitmap that i need to draw on it other bitmaps. the master bitmap has some semi-transparent pixels (pixels with variant values for the alpha channel) , so that the other bitmaps that are drawn on it should be merged with it instead of overriding the colors completely. the question how can i set the canvas to draw the bitmaps on the master bitmap with respect to the semi-transparent pixels ? note: the alpha is not for the whole bitmap/s . it's per pixel. Canvas.setXfermode(Xfermode xfermode) . There are a number of Xfermode s you can choose. Desmond Yao public void

Copy image with alpha channel to clipboard with custom background color?

旧街凉风 提交于 2019-12-01 05:51:33
Code : private void Foo(Canvas canvas) { // The content is a bit larger... Size size = new Size(canvas.ActualWidth * 1.1, canvas.ActualHeight * 1.2); // Create a render bitmap and push the surface to it RenderTargetBitmap renderBitmap = new RenderTargetBitmap( (int)size.Width, (int)size.Height, 96d, 96d, PixelFormats.Pbgra32 ); renderBitmap.Render(canvas); // Then copy to clipboard Clipboard.SetImage(renderBitmap); } What I need : Render a canvas with transparent background to image, then copy it to clipboard (Quit simple? Not really) Problem : When paste, I get a ugly image with black

How to draw a bitmap on a canvas, respecting alpha values of the bitmap?

送分小仙女□ 提交于 2019-12-01 05:24:59
问题 background i have a master bitmap that i need to draw on it other bitmaps. the master bitmap has some semi-transparent pixels (pixels with variant values for the alpha channel) , so that the other bitmaps that are drawn on it should be merged with it instead of overriding the colors completely. the question how can i set the canvas to draw the bitmaps on the master bitmap with respect to the semi-transparent pixels ? note: the alpha is not for the whole bitmap/s . it's per pixel. 回答1: Canvas

Copy image with alpha channel to clipboard with custom background color?

∥☆過路亽.° 提交于 2019-12-01 04:11:47
问题 Code : private void Foo(Canvas canvas) { // The content is a bit larger... Size size = new Size(canvas.ActualWidth * 1.1, canvas.ActualHeight * 1.2); // Create a render bitmap and push the surface to it RenderTargetBitmap renderBitmap = new RenderTargetBitmap( (int)size.Width, (int)size.Height, 96d, 96d, PixelFormats.Pbgra32 ); renderBitmap.Render(canvas); // Then copy to clipboard Clipboard.SetImage(renderBitmap); } What I need : Render a canvas with transparent background to image, then

MATLAB: Applying transparent mask over an RGB image and blending with another

旧城冷巷雨未停 提交于 2019-11-30 16:11:20
问题 I have 2 images: a foreground and a background. The foreground is a matrix of numbers ranging from -50 to 300. I display it via imagesc. (I.e. this is no RGB image). The background is a RGB image. I want to first apply a transparency mask on the foreground to alter it's appearance. This is easy enough by using altered_foreground = imagesc(foreground, 'AlphaData', Alphamask) Now, I want to superimpose the altered_foreground on top of the background. The problem is that since I've already used