Sign in to follow this  
Followers 0
KJohn

GUI Alpha Mask

15 posts in this topic

Is it possible to apply an Alpha mask onto an autoit window (I am not talking about uniform transparency using WinSetTrans)? Anyone who will be able to answer this question is sure to know what an alpha mask is but i'll include some information for anyone who refers back to this thread later:

In graphics, a portion of each pixel's data that is reserved for transparency information. 32-bit graphics systems contain four channels -- three 8-bit channels for red, green, and blue (RGB) and one 8-bit alpha channel. The alpha channel is really a mask -- it specifies how the pixel's colors should be merged with another pixel when the two are overlaid, one on top of the other.

Typically, you wouldn't define the alpha channel on a pixel-by-pixel basis, but rather per object. Different parts of the object would have different levels of transparency depending on how much you wanted the background to show through. This allows you to create rectangular objects that appear as if they are irregular in shape -- you define the rectangular edges as transparent so that the background shows through. This is especially important for animation, where the background changes from one frame to the next.

Rendering overlapping objects that include an alpha value is called alpha blending.

Using gdi32.dll or user32.dll in a DllCall as in the following example to create rounded edges for a window?

CODE
Func _GuiRoundCorners($h_win, $i_x1, $i_y1, $i_x3, $i_y3)

Dim $pos, $ret, $ret2

$pos = WinGetPos($h_win)

$ret = DllCall("gdi32.dll", "long", "CreateRoundRectRgn", "long", $i_x1, "long", $i_y1, "long", $pos[2], "long", $pos[3], "long", $i_x3, "long", $i_y3)

If $ret[0] Then

$ret2 = DllCall("user32.dll", "long", "SetWindowRgn", "hwnd", $h_win, "long", $ret[0], "int", 1)

If $ret2[0] Then

Return 1

Else

Return 0

EndIf

Else

Return 0

EndIf

EndFunc ;==>_GuiRoundCorners

I found the above at: http://www.autoitscript.com/forum/index.ph...mp;#entry191072

I'm sure its possible somehow... Plz help!!!

Share this post


Link to post
Share on other sites



Try going to http://www.viksoe.dk/code/alphatut1.htm. It might have what you want...

umm... from what i understood, the 'msimg32.dll' file was used to do per pixel alphablending on 2 bitmaps... BUT what i need to do is per pixel alpha blending on the autoit gui with whatever is beneath it... here's a picture of a gui similar to what I have in mind:

Note the soft shadow around the corners of the window. The program in question uses a PNG file to describe what it should draw. The PNG file is given below.

Now can someone tell me how I should go about making an AutoIt GUI look like that? Forget all my ideas on DLLCall... I am not bothered about the means. Only the end. And it should look something like the screenshot I've put up above. Any ideas? AutoIt team? Is this a feature that can be included into AutoIt?

BTW bert, thanks for the suggestion!!!

Share this post


Link to post
Share on other sites

mybe you should look at the prospeed.udf

it has AlphaTrans and semi_trans in it

jpam

Share this post


Link to post
Share on other sites

mybe you should look at the prospeed.udf

it has AlphaTrans and semi_trans in it

jpam

Jpam, yes I saw the prospeed udf on the forum recently and downloaded it along with the example program. Very impressive I must say. Truly.

I've been going through it, and yes alphatrans is something like what I'm looking for. While Alphatrans works between 2 images both provided by the user, I need the effect on 3 different images superimposed (for simplicity, I will assume that the areas of the GUI where I intend to apply any level of transparency doesn't contain any controls other than a pic):

Image 1: The actual GUI image itself

Image 2: The PNG mask I will be using

Image 3 (and I don't know how to get this): The portion of the screen directly below the GUI.

Getting Image 3 algorithm (no feasibility check):

- Take screenshot

- Query present position and size of GUI

- Calculate top left and bottom right pixel coordinates of GUI and cut that section out of the screenshot

Do the 3 level masking on this. Now if this wasn't processor intensive enough, this process has to be repeated as fast as possible over and over to compensate for:

- change in screen information

- change in GUI position

So its pretty obvious that it is not a useful solution......

Posted Image

Now I have a lead: Analyzing an existing program that uses this effect (not compiled in AutoIt):

- Go to http://www.launchy.net/#documentation

- Notice reference to gdiplus.dll (for Win 2000 but it is worth noting anyway; I am only interested in Windows XP)

- Now if any of you are savvy enough, you can go through the source of the program (from what I understand it is open-source), and find out what DLLCalls are made...

- SourceForge link: http://sourceforge.net/projects/launchy/

I feel that many of you are interested in having this feature in AutoIt (AlphaTrans on GUI), so even if you can't help leave a comment. If there are enough people wanting this, I'll put up a feature request....

Share this post


Link to post
Share on other sites

Here's an additional link:

http://www.codeproject.com/gdi/pxalphablend.asp

The trail seems to be getting hot. Will somebody capable of doing so, compile the ImgDecoder.dll library and tell what function to call from it and how to go about do so? I will be really grateful.

Here's another idea: user32.dll

MSDN information: http://msdn.microsoft.com/library/default....yeredwindow.asp

Somebody... Anybody... Plz help... I've been doing a hell of a lot of research so plz don't let it go in waste because my level of expertise wasn't enough to cross a few crucial bridges along the way!!

Share this post


Link to post
Share on other sites

Here's a list of alpha methods from CxImageATL.dll library.

Never used alpha methods so i don't know if its what you need or even suitable.

http://www.autoitscript.com/forum/index.ph...mp;#entry298211

HRESULT AlphaCreate();

[id(0x0000004a), helpstring("Deallocates the alpha channel.")]

HRESULT AlphaDelete();

[id(0x0000004b), helpstring("Resets the alpha channel.")]

HRESULT AlphaClear();

[id(0x0000004c), helpstring("Inverts the alpha channel.")]

HRESULT AlphaInvert();

[id(0x0000004d), helpstring("Mirrors the alpha channel.")]

HRESULT AlphaMirror();

[id(0x0000004e), helpstring("Flips the alpha channel.")]

HRESULT AlphaFlip();

[id(0x0000004f), helpstring("Imports an existing alpa channel from another image with the same width and height.")]

HRESULT AlphaCopy([in] IDispatch* from);

[id(0x00000050), helpstring("Blends the alpha channel and the alpha palette with the pixels. The result is a 24 bit image. The background color can be selected using SetTransColor().")]

HRESULT AlphaStrip();

[id(0x00000051), helpstring("Exports the alpha channel in a 8bpp grayscale image.")]

HRESULT AlphaSplit([in] IDispatch* dest);

[id(0x00000052), helpstring("Sets the alpha level for the whole image.")]

HRESULT AlphaSetAll([in] long level);

[id(0x00000053), helpstring("Sets the alpha level for a single pixel ")]

HRESULT AlphaSet(

[in] long x,

[in] long y,

[in] long level);

[id(0x00000054), helpstring("Returns the alpha level for the specified pixel.")]

HRESULT AlphaGet(

[in] long x,

[in] long y,

[out, retval] long* level);

[id(0x00000055), helpstring("Get global Alpha (opacity) value applied to the whole image.")]

HRESULT AlphaGetMax([out, retval] long* level);

[id(0x00000056), helpstring("Set global Alpha (opacity) value applied to the whole image.")]

HRESULT AlphaSetMax([in] long nAlphaMax);

[id(0x00000057), helpstring("Checks if the image has a valid alpha channel.")]

HRESULT HasAlpha([out, retval] VARIANT_BOOL* has);

[id(0x00000058), helpstring("Resets the alpha palette.")]

HRESULT AlphaPaletteClear();

[id(0x00000059), helpstring("Enables the alpha palette, so the Draw() function changes its behavior.")]

HRESULT AlphaPaletteEnable([in, optional, defaultvalue(-1)] VARIANT_BOOL bEnable);

[id(0x0000005a), helpstring("True if the alpha palette is enabled for painting.")]

HRESULT IsAlphaPaletteEnabled([out, retval] VARIANT_BOOL* isenabled);

[id(0x0000005b), helpstring("Checks if the image has a valid alpha palette.")]

HRESULT HasAlphaPalette([out, retval] VARIANT_BOOL* has);

[id(0x0000005c), helpstring("Returns the size in byte of the internal hDib object.")]

Share this post


Link to post
Share on other sites

@Will66:

From a cursory look, it appears that even your solution is about alpha blending WITHIN the autoit window. Forgive me if I am wrong, for I won't be able to take a good look at it till thursday...

If anyone has an alternate solution where the autoit GUI is alphablended with WHATEVER IS BEHIND IT, please post it here. I'll definitely look into it. Just because I might not reply till thursday should not be taken as a sign that I've abandoned this cause.

Soliciting more help!!!

Share this post


Link to post
Share on other sites

Isn't anyone interested in getting Windows like the one I'm describing? I personally think it is uber-cool, coz u can get Vista like UIs in XP if alpha masking was enabled... I have to admit having a GUI like that isn't a NECESSITY but it would be a big step for AutoIt!!!

Share this post


Link to post
Share on other sites

Isn't anyone interested in getting Windows like the one I'm describing? I personally think it is uber-cool, coz u can get Vista like UIs in XP if alpha masking was enabled... I have to admit having a GUI like that isn't a NECESSITY but it would be a big step for AutoIt!!!

Yes, I would like to have such GUI.

Have a look on http://www.planet-source-code.com/vb/scrip...5&lngWId=10

They are using VB.net code and I think it's easier to convert it to autoit code than the C++ you found. I would be happy to help, but I can't find any time left to do so.

Share this post


Link to post
Share on other sites

Yes, I would like to have such GUI.

Have a look on http://www.planet-source-code.com/vb/scrip...5&lngWId=10

They are using VB.net code and I think it's easier to convert it to autoit code than the C++ you found. I would be happy to help, but I can't find any time left to do so.

Thanks for the support!

I've downloaded the source... I'm not familiar with VB (more of a C++ guy), but I'll try going through it to get an idea of how its done. As far as I've read, it seems to agree with all the Microsoft documentation I've read at MSDN pertaining to this (refer above).

Anyone else who can help out on this? Someone good at VB?

Share this post


Link to post
Share on other sites

#12 ·  Posted (edited)

What you are looking for is RGB32 Alpha Blended window. It isn't 3 levels, because you are not getting what's behind your window and setting your window to that. If you do, your whole system will grind to a halt, or you will get lag trails under your window. It will look horrid. It's been tried a million times. You can do it on Linux with some trickery by stalling the XServer display refresh while you fiddle about.

Recently (with Windows XP, and gdiplus.dll upgrade on 2K) you can get RGB32 windows in Windows natively, the only other way to do this, is to translate the whole screen to a DirectX layer, and manually insert your window using DirectX calls... somehow. I didn't understand the descussions on this, and it meant a lot of code which only just about worked in a reasonable time scale, provided no other program tried it and you didn't try to... play a game or watch a video, or TVin.

GDI+ makes it possible. Don't ask me how, all I know is that a GDI Plus window is nothing like a regular window. You can't add a switch or tag to a window to make it a GDI+ window like you can uniform transparency in 2k+ and from what I can tell, if you use a GDI+ window you have to forgo buttons, lists, combo boxes and all the other ctrl3d.dll controls you are used to, and just draw the entire UI manually using GDI+ and DirectX calls to your new Windows Layer.

This isn't going to be "added" to any standard AutoIt GUI commands, but would need to be a whole new library in it's self.

How about AveDesk with AveScripter? or Samurize would they not be more suited? You can get AutoIt to run invisible and interact with these, I have done so, and it works. It's not easy though, but I don't think any solution will be till someone comes out with a UFD which links nicely to the APIs in gdiplus.dll.

PS. if you think your C++ to AutoIt is up to the job I'd love to hear from you. :whistle:

Edit: I should have mentioned that this all came about because OS X has always had it natively with it's updated PDF like Cocoa and Aqua interfaces. Linux has a fix for this in recent variants, but it isn't IFAIK a standard part of X as yet. It is, however a large part of the new DirectX 11 compatible cards, and a large part of the new specs in PCI-E low level APIs which OS X and Windows Vista can then take advantage of as new hardware acceleration. Hence the push for PCI-E in order to use Vistas new transparency effects. A fast AGP card can cope with 4/5 of these things but then starts to grind to a halt without the Hardware and API specs to handel it. In DirectX games you don't normally have more than a couple of layers, for HUD or what have you. In the Windows Desktop you could well have 30-40 in an Office PC. :)

Edited by bobsobol

Share this post


Link to post
Share on other sites

hey. Any updates on this? This seems like it'd be really cool. I'm trying to do something like this now.

Share this post


Link to post
Share on other sites

Jpam, yes I saw the prospeed udf on the forum recently and downloaded it along with the example program. Very impressive I must say. Truly.

I've been going through it, and yes alphatrans is something like what I'm looking for. While Alphatrans works between 2 images both provided by the user, I need the effect on 3 different images superimposed (for simplicity, I will assume that the areas of the GUI where I intend to apply any level of transparency doesn't contain any controls other than a pic):

Image 1: The actual GUI image itself

Image 2: The PNG mask I will be using

Image 3 (and I don't know how to get this): The portion of the screen directly below the GUI.

Getting Image 3 algorithm (no feasibility check):

- Take screenshot

- Query present position and size of GUI

- Calculate top left and bottom right pixel coordinates of GUI and cut that section out of the screenshot

Do the 3 level masking on this. Now if this wasn't processor intensive enough, this process has to be repeated as fast as possible over and over to compensate for:

- change in screen information

- change in GUI position

So its pretty obvious that it is not a useful solution......

Posted Image

Now I have a lead: Analyzing an existing program that uses this effect (not compiled in AutoIt):

- Go to http://www.launchy.net/#documentation

- Notice reference to gdiplus.dll (for Win 2000 but it is worth noting anyway; I am only interested in Windows XP)

- Now if any of you are savvy enough, you can go through the source of the program (from what I understand it is open-source), and find out what DLLCalls are made...

- SourceForge link: http://sourceforge.net/projects/launchy/

I feel that many of you are interested in having this feature in AutoIt (AlphaTrans on GUI), so even if you can't help leave a comment. If there are enough people wanting this, I'll put up a feature request....

Hi Koshy, I'm interested in the same thing. But I'm a nebiew. If you have solved the problem, could you please share it with me. I need Launchy type skinning window. Could you please help me.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0