[Home] [Downloads] [Search] [Help/forum]


Register forum user name Search FAQ

Gammon Forum

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  Miniwindows
. . -> [Subject]  Comments about the function WindowTransformImage

Comments about the function WindowTransformImage

It is now over 60 days since the last post. This thread is closed.     [Refresh] Refresh page


Pages: 1 2  

Posted by Nick Gammon   Australia  (22,982 posts)  [Biography] bio   Forum Administrator
Date Fri 27 Aug 2010 03:00 AM (UTC)
Message
Further on from this thread:

http://www.gammon.com.au/forum/bbshowpost.php?id=10527

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Twisol   USA  (2,257 posts)  [Biography] bio
Date Reply #1 on Fri 27 Aug 2010 03:00 AM (UTC)
Message
How might I use this with WindowMergeImageAlpha, if I have a transparency mask I'd like to use?

And is there any way I use this with WindowImageOp so I can clip the image within a fancy, non-rectangular border?

Thanks for the help, Nick.

'Soludra' on Achaea

Blog: http://jonathan.com/
GitHub: http://github.com/Twisol
[Go to top] top

Posted by Nick Gammon   Australia  (22,982 posts)  [Biography] bio   Forum Administrator
Date Reply #2 on Fri 27 Aug 2010 03:22 AM (UTC)
Message
Twisol said:

How might I use this with WindowMergeImageAlpha, if I have a transparency mask I'd like to use?


You don't, bad luck. If you look at the source you see it does a heap of complex calculations to make it work. There isn't some easy way of achieving it (or at least, I don't know of it).

Twisol said:

And is there any way I use this with WindowImageOp so I can clip the image within a fancy, non-rectangular border?


Make a temporary window with a purple background. Then use that as the transparency when copying and translating.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Twisol   USA  (2,257 posts)  [Biography] bio
Date Reply #3 on Fri 27 Aug 2010 03:40 AM (UTC)
Message
Nick Gammon said:
Twisol said:

How might I use this with WindowMergeImageAlpha, if I have a transparency mask I'd like to use?


You don't, bad luck. If you look at the source you see it does a heap of complex calculations to make it work. There isn't some easy way of achieving it (or at least, I don't know of it).

I Googled and found this, maybe it'll help?

http://www.mvps.org/user32/gditutorial.html

I found the source download for the transparency tutorial to be easier to glance over than the tutorial itself, for some reason.

Nick Gammon said:
Twisol said:

And is there any way I use this with WindowImageOp so I can clip the image within a fancy, non-rectangular border?


Make a temporary window with a purple background. Then use that as the transparency when copying and translating.

I don't like color-based transparency. :S If I could use WindowMergeImageAlpha, I could render it into a scratch window and then draw that rotated.

'Soludra' on Achaea

Blog: http://jonathan.com/
GitHub: http://github.com/Twisol
[Go to top] top

Posted by Nick Gammon   Australia  (22,982 posts)  [Biography] bio   Forum Administrator
Date Reply #4 on Fri 27 Aug 2010 04:40 AM (UTC)
Message
Twisol said:

I don't like color-based transparency. :S If I could use WindowMergeImageAlpha, I could render it into a scratch window and then draw that rotated.


You can. Rotate the image. Rotate the mask. Then merge the rotated image with the rotated mask into the miniwindow.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Nick Gammon   Australia  (22,982 posts)  [Biography] bio   Forum Administrator
Date Reply #5 on Fri 27 Aug 2010 04:43 AM (UTC)
Message
Twisol said:

I Googled and found this, maybe it'll help?

http://www.mvps.org/user32/gditutorial.html


From that page: "GDI has no built in transparency support - you have to implement transparency in bitmaps yourself.".

Now maybe later versions of the GDI do support it, but we will get to the stage where MUSHclient only runs under Windows Vista or onwards, because of pressure to implement features that no-one has wanted so far, to do obscure things like rotating a loaded image and merge it with an alpha mask in order to give an inventory window a slightly better looking shadow that no-one will really care about.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Twisol   USA  (2,257 posts)  [Biography] bio
Date Reply #6 on Fri 27 Aug 2010 04:48 AM (UTC)
Message
Nick Gammon said:

Twisol said:

I don't like color-based transparency. :S If I could use WindowMergeImageAlpha, I could render it into a scratch window and then draw that rotated.


You can. Rotate the image. Rotate the mask. Then merge the rotated image with the rotated mask into the miniwindow.


So you're saying I'd rotate the image and mask into new scratch windows, which would have to be large enough to fit the whole of the rotated image (and with the new area of the alpha mask filled with the transparency color), then apply them to the target window?

I guess that works. Feels awful though.

'Soludra' on Achaea

Blog: http://jonathan.com/
GitHub: http://github.com/Twisol
[Go to top] top

Posted by Twisol   USA  (2,257 posts)  [Biography] bio
Date Reply #7 on Fri 27 Aug 2010 04:51 AM (UTC)

Amended on Fri 27 Aug 2010 04:54 AM (UTC) by Twisol

Message
Nick Gammon said:

Twisol said:

I Googled and found this, maybe it'll help?

http://www.mvps.org/user32/gditutorial.html


From that page: "GDI has no built in transparency support - you have to implement transparency in bitmaps yourself.".

Now maybe later versions of the GDI do support it, but we will get to the stage where MUSHclient only runs under Windows Vista or onwards, because of pressure to implement features that no-one has wanted so far, to do obscure things like rotating a loaded image and merge it with an alpha mask in order to give an inventory window a slightly better looking shadow that no-one will really care about.


Did you look at what it does? It just uses two modes of BitBlt, first applying the trasparency mask and then the image itself. It said it has no built-in, widely-compatible support as a segue for how to do it properly yourself. And I think it might simplify your implementation, too.

Granted, I still don't know if it's exactly what you need, but you haven't said otherwise yet.

'Soludra' on Achaea

Blog: http://jonathan.com/
GitHub: http://github.com/Twisol
[Go to top] top

Posted by Nick Gammon   Australia  (22,982 posts)  [Biography] bio   Forum Administrator
Date Reply #8 on Fri 27 Aug 2010 05:07 AM (UTC)
Message
Twisol said:

Did you look at what it does? It just uses two modes of BitBlt, first applying the trasparency mask and then the image itself. It said it has no built-in, widely-compatible support as a segue for how to do it properly yourself. And I think it might simplify your implementation, too.


The current code does exactly that:


	    // Build mask based on transparent colour at location 0, 0
	    dcTrans.BitBlt (0, 0, iWidth, iHeight, &bmDC, 0, 0, SRCCOPY);

	    // Do the work 
	    dc.BitBlt (0, 0, iWidth, iHeight, &bmDC,    0, 0, SRCINVERT);
	    dc.BitBlt (0, 0, iWidth, iHeight, &dcTrans, 0, 0, SRCAND);
	    dc.BitBlt (0, 0, iWidth, iHeight, &bmDC,    0, 0, SRCINVERT);


However, as he says "One bitmap specifies the image - and all the "transparent" areas are set to black. The other bitmap is monochrome / black and white.".

That is, this is a on/off sort of transparency, the exact thing that is now implemented. Not a 0-255 levels of transparency.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Nick Gammon   Australia  (22,982 posts)  [Biography] bio   Forum Administrator
Date Reply #9 on Fri 27 Aug 2010 05:09 AM (UTC)
Message
Twisol said:

So you're saying I'd rotate the image and mask into new scratch windows, which would have to be large enough to fit the whole of the rotated image (and with the new area of the alpha mask filled with the transparency color), then apply them to the target window?


There is no transparency colour in this particular case. The WindowTranslateImage uses a grayscale image to control the transparency with 256 levels of transparency. That is the thing you have to rotate.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Twisol   USA  (2,257 posts)  [Biography] bio
Date Reply #10 on Fri 27 Aug 2010 05:16 AM (UTC)
Message
Nick Gammon said:

Twisol said:

Did you look at what it does? It just uses two modes of BitBlt, first applying the trasparency mask and then the image itself. It said it has no built-in, widely-compatible support as a segue for how to do it properly yourself. And I think it might simplify your implementation, too.


The current code does exactly that:


	    // Build mask based on transparent colour at location 0, 0
	    dcTrans.BitBlt (0, 0, iWidth, iHeight, &bmDC, 0, 0, SRCCOPY);

	    // Do the work 
	    dc.BitBlt (0, 0, iWidth, iHeight, &bmDC,    0, 0, SRCINVERT);
	    dc.BitBlt (0, 0, iWidth, iHeight, &dcTrans, 0, 0, SRCAND);
	    dc.BitBlt (0, 0, iWidth, iHeight, &bmDC,    0, 0, SRCINVERT);


However, as he says "One bitmap specifies the image - and all the "transparent" areas are set to black. The other bitmap is monochrome / black and white.".

That is, this is a on/off sort of transparency, the exact thing that is now implemented. Not a 0-255 levels of transparency.


The issue was that your implementation is difficult, so I found another. Does the other implementation make it any easier? It seems like it only needs two blits.

Also, I was talking about WindowMergeImageAlpha; why is your code snippet taken from Draw/TranslateImage? :S

Nick Gammon said:
There is no transparency colour in this particular case. The WindowTranslateImage uses a grayscale image to control the transparency with 256 levels of transparency. That is the thing you have to rotate.

The full transparency color, I meant. Fully see-through. Otherwise the space created around the rotation (since I need a bigger canvas) would be visible when it's merged into the target.

'Soludra' on Achaea

Blog: http://jonathan.com/
GitHub: http://github.com/Twisol
[Go to top] top

Posted by Nick Gammon   Australia  (22,982 posts)  [Biography] bio   Forum Administrator
Date Reply #11 on Fri 27 Aug 2010 05:31 AM (UTC)
Message
Twisol said:

The issue was that your implementation is difficult, so I found another. Does the other implementation make it any easier? It seems like it only needs two blits.


I count four in the code. Two in the setup (to set up the mask) and two in the painting area.

My four are all done at once, because I don't know in advance which bitmap you are doing to do it with.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Nick Gammon   Australia  (22,982 posts)  [Biography] bio   Forum Administrator
Date Reply #12 on Fri 27 Aug 2010 05:33 AM (UTC)
Message
Twisol said:

The full transparency color, I meant. Fully see-through. Otherwise the space created around the rotation (since I need a bigger canvas) would be visible when it's merged into the target.


See this:

http://www.gammon.com.au/forum/bbshowpost.php?id=9568

The mask (the black blobby thing) is the thing you would have to copy and rotate. Naturally you need a large enough place to rotate it into, and the background of that larger "canvas" would be white.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Nick Gammon   Australia  (22,982 posts)  [Biography] bio   Forum Administrator
Date Reply #13 on Fri 27 Aug 2010 05:35 AM (UTC)
Message
Twisol said:

I guess that works. Feels awful though.


It works for the hypothetical situation you are proposing. I am waiting for a concrete example of where many people need to rotate and blend in bitmaps with alpha channels, and how the existing system will fail them.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Twisol   USA  (2,257 posts)  [Biography] bio
Date Reply #14 on Fri 27 Aug 2010 05:38 AM (UTC)
Message
Nick Gammon said:

Twisol said:

I guess that works. Feels awful though.


It works for the hypothetical situation you are proposing. I am waiting for a concrete example of where many people need to rotate and blend in bitmaps with alpha channels, and how the existing system will fail them.

Yes, it does work. I have no serious complaints now except for the orthogonality and the feels-awful (which are unsurprisingly linked).

'Soludra' on Achaea

Blog: http://jonathan.com/
GitHub: http://github.com/Twisol
[Go to top] top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


39,620 views.

This is page 1, subject is 2 pages long: 1 2  [Next page]

It is now over 60 days since the last post. This thread is closed.     [Refresh] Refresh page

Go to topic:           Search the forum


[Go to top] top

Quick links: MUSHclient. MUSHclient help. Forum shortcuts. Posting templates. Lua modules. Lua documentation.

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.

[Home]


Written by Nick Gammon - 5K   profile for Nick Gammon on Stack Exchange, a network of free, community-driven Q&A sites   Marriage equality

Comments to: Gammon Software support
[RH click to get RSS URL] Forum RSS feed ( https://gammon.com.au/rss/forum.xml )

[Best viewed with any browser - 2K]    [Hosted at HostDash]