In my C# & MC++ app there is some drawing done through GDI (not +, but
win32).
I would like to be able to create a translucent HBRUSH.
the RGB macro create only solid color...
and, anyway, CreateSolidBrus h ignore the higher byte.
Any idea?
I though I might do some trick with CreateDIBPatter nBrush but I'm not sure
on what to do...
Any tips wellcome! 7 3335
You are on the right track!
1)You could create an alpha channel DIB and select it into
a device context (i.e., use BITMAPV5HEADER) .
2)Create your brushes and draw them to the device backed by
the DIB.
3) Using the bits, change the alpha byte to the level of
translucency that you desire.
4) Premultiply the alpha channel against the RGB values.
5) Use the AlphaBlend function to draw your translucent brush.
"Lloyd Dupont" <net.galador@ld > wrote in message
news:ON******** ******@TK2MSFTN GP14.phx.gbl... In my C# & MC++ app there is some drawing done through GDI (not +, but win32). I would like to be able to create a translucent HBRUSH.
the RGB macro create only solid color... and, anyway, CreateSolidBrus h ignore the higher byte.
Any idea?
I though I might do some trick with CreateDIBPatter nBrush but I'm not sure on what to do...
Any tips wellcome!
hu.....
thanks for your tips!
"Michael Phillips, Jr." <mp*********@no spam.jun0.c0m> wrote in message
news:%2******** ********@TK2MSF TNGP09.phx.gbl. .. You are on the right track!
1)You could create an alpha channel DIB and select it into a device context (i.e., use BITMAPV5HEADER) .
2)Create your brushes and draw them to the device backed by the DIB.
3) Using the bits, change the alpha byte to the level of translucency that you desire.
4) Premultiply the alpha channel against the RGB values.
5) Use the AlphaBlend function to draw your translucent brush. "Lloyd Dupont" <net.galador@ld > wrote in message news:ON******** ******@TK2MSFTN GP14.phx.gbl... In my C# & MC++ app there is some drawing done through GDI (not +, but win32). I would like to be able to create a translucent HBRUSH.
the RGB macro create only solid color... and, anyway, CreateSolidBrus h ignore the higher byte.
Any idea?
I though I might do some trick with CreateDIBPatter nBrush but I'm not sure on what to do...
Any tips wellcome!
mmhh.. well..
There are some problem with this approch.
I created a 1x1 pixel bitmap of the right color, get its HBITMAP< select it
in a memory, screen compatible, DC and AlphaBlend it.
But translucent color get a blue tint.
In fact worst than that, they get a blue tint.. most of the time (but not
always).
Fiu..
I think I will forgot about translucent painting in GDI...
"Michael Phillips, Jr." <mp*********@no spam.jun0.c0m> wrote in message
news:%2******** ********@TK2MSF TNGP09.phx.gbl. .. You are on the right track!
1)You could create an alpha channel DIB and select it into a device context (i.e., use BITMAPV5HEADER) .
2)Create your brushes and draw them to the device backed by the DIB.
3) Using the bits, change the alpha byte to the level of translucency that you desire.
4) Premultiply the alpha channel against the RGB values.
5) Use the AlphaBlend function to draw your translucent brush. "Lloyd Dupont" <net.galador@ld > wrote in message news:ON******** ******@TK2MSFTN GP14.phx.gbl... In my C# & MC++ app there is some drawing done through GDI (not +, but win32). I would like to be able to create a translucent HBRUSH.
the RGB macro create only solid color... and, anyway, CreateSolidBrus h ignore the higher byte.
Any idea?
I though I might do some trick with CreateDIBPatter nBrush but I'm not sure on what to do...
Any tips wellcome!
> There are some problem with this approach. I created a 1x1 pixel bitmap of the right color, get its HBITMAP< select it in a memory, screen compatible, DC and AlphaBlend it.
Could you be more specific. Did you follow my steps and
premultiply the alpha channel?
If you don't create and use the bitmap correctly with the
AlphaBlend function, you will get a blue tint.
If you use BitBlt, you will see the blue tinted background.
When you use AlphaBlend correctly with premultiplied
alpha channel, you will not see a blue tint.
There is another approach. You can define a mask to
represent the translucency and use MaskBlt.
You will not be able to define an opacity in the range of 0 -100%
with the MaskBlt approach.
ok, I will be at work in 2 hours.
could gives me more detail?
what do you mean by:
4) Premultiply the alpha channel against the RGB values.
I created the bitmap in 2 ways.
SD.Bitmap.GetHB itmap()
or as in the code sample in AlphaBlend documentation with CreateDibBitmpa (),
using a BITMAPHEADER (and not a BITMAPV5HEADER)
in the BLENDFUNCTION I used opaque value: 0xff.
could you give me some more tips?
and thanks for your tips so far ;-)
if I set the
"Michael Phillips, Jr." <mp*********@no spam.jun0.c0m> wrote in message
news:%2******** **********@TK2M SFTNGP12.phx.gb l... There are some problem with this approach. I created a 1x1 pixel bitmap of the right color, get its HBITMAP< select it in a memory, screen compatible, DC and AlphaBlend it.
Could you be more specific. Did you follow my steps and premultiply the alpha channel?
If you don't create and use the bitmap correctly with the AlphaBlend function, you will get a blue tint.
If you use BitBlt, you will see the blue tinted background. When you use AlphaBlend correctly with premultiplied alpha channel, you will not see a blue tint.
There is another approach. You can define a mask to represent the translucency and use MaskBlt.
You will not be able to define an opacity in the range of 0 -100% with the MaskBlt approach.
You usually premultiply the alpha channel against the RGB colors
when you use AlphaBlend with SourceConstantA lpha = 0xFF.
However the technique that I outlined does not work. I tried creating both
solid and hatch DIB pattern brushes but GDI still ignores the
alpha channel whether I premultiply or set different opacity
levels in the range 0 - 1. I guess you have to roll your own
FillRect or Rectangle function to accept alpha channel brushes.
I believe that GIMP can create translucent brushes.
You may want to download the code to see how they
accomplish the effect.
"Lloyd Dupont" <net.galador@ld > wrote in message
news:Ot******** ********@TK2MSF TNGP09.phx.gbl. .. ok, I will be at work in 2 hours. could gives me more detail?
what do you mean by:
4) Premultiply the alpha channel against the RGB values.
I created the bitmap in 2 ways. SD.Bitmap.GetHB itmap() or as in the code sample in AlphaBlend documentation with CreateDibBitmpa (), using a BITMAPHEADER (and not a BITMAPV5HEADER)
in the BLENDFUNCTION I used opaque value: 0xff.
could you give me some more tips?
and thanks for your tips so far ;-)
if I set the "Michael Phillips, Jr." <mp*********@no spam.jun0.c0m> wrote in message news:%2******** **********@TK2M SFTNGP12.phx.gb l... There are some problem with this approach. I created a 1x1 pixel bitmap of the right color, get its HBITMAP< select it in a memory, screen compatible, DC and AlphaBlend it.
Could you be more specific. Did you follow my steps and premultiply the alpha channel?
If you don't create and use the bitmap correctly with the AlphaBlend function, you will get a blue tint.
If you use BitBlt, you will see the blue tinted background. When you use AlphaBlend correctly with premultiplied alpha channel, you will not see a blue tint.
There is another approach. You can define a mask to represent the translucency and use MaskBlt.
You will not be able to define an opacity in the range of 0 -100% with the MaskBlt approach.
Thanks Michael!
Anyway translucent GDI brush is not that essential at this stage. So I just
dropped it.
I'm just a bit frustrated, that's all.
"Michael Phillips, Jr." <mp*********@no spam.jun0.c0m> wrote in message
news:%2******** **********@TK2M SFTNGP09.phx.gb l... You usually premultiply the alpha channel against the RGB colors when you use AlphaBlend with SourceConstantA lpha = 0xFF.
However the technique that I outlined does not work. I tried creating both solid and hatch DIB pattern brushes but GDI still ignores the alpha channel whether I premultiply or set different opacity levels in the range 0 - 1. I guess you have to roll your own FillRect or Rectangle function to accept alpha channel brushes.
I believe that GIMP can create translucent brushes. You may want to download the code to see how they accomplish the effect.
"Lloyd Dupont" <net.galador@ld > wrote in message news:Ot******** ********@TK2MSF TNGP09.phx.gbl. .. ok, I will be at work in 2 hours. could gives me more detail?
what do you mean by:
4) Premultiply the alpha channel against the RGB values.
I created the bitmap in 2 ways. SD.Bitmap.GetHB itmap() or as in the code sample in AlphaBlend documentation with CreateDibBitmpa (), using a BITMAPHEADER (and not a BITMAPV5HEADER)
in the BLENDFUNCTION I used opaque value: 0xff.
could you give me some more tips?
and thanks for your tips so far ;-)
if I set the "Michael Phillips, Jr." <mp*********@no spam.jun0.c0m> wrote in message news:%2******** **********@TK2M SFTNGP12.phx.gb l... There are some problem with this approach. I created a 1x1 pixel bitmap of the right color, get its HBITMAP< select it in a memory, screen compatible, DC and AlphaBlend it.
Could you be more specific. Did you follow my steps and premultiply the alpha channel?
If you don't create and use the bitmap correctly with the AlphaBlend function, you will get a blue tint.
If you use BitBlt, you will see the blue tinted background. When you use AlphaBlend correctly with premultiplied alpha channel, you will not see a blue tint.
There is another approach. You can define a mask to represent the translucency and use MaskBlt.
You will not be able to define an opacity in the range of 0 -100% with the MaskBlt approach.
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Rene |
last post by:
I would like to get a reference to a Brush using the color name of the
brush. For example, right now if I want a brush with a certain color, I
would hard code something like Brushes.PeachPuff, this will get me a
PeachPuff brush, but what if my brush depended on a string passed by the
user? If all I had was a string with the name "PeachPuff" how can I create
Brushes.PeachPuff using the string value?
Thank you.
|
by: boxim |
last post by:
having a moment,
cant you just
Brush br = new Brush(Color.Black);??? saying you cant cos it's an abstract
class
need to get to a brush from a color
tia
sam martin
|
by: Rudolph Araujo |
last post by:
Hi,
I needed to build a data grid in which the first column has
hyperlinks rather than simple text. I found the following code on this
newsgroup and it works fine except for one problem. When I click the
column headers all the columns sort except the hyperlink one. I
checked the underlying dataview and that does get sorted so it seems
like it is more of a display issue. I am guessing it has something to
do with the hashtable used by the...
|
by: Dennis |
last post by:
When I instantiate a Brush resource such as a solidbrush, do I need to
dispose the resource when I'm finished or will it automatically be disposed
when the function/sub it's used in ends? Thank you for any replies.
--
Dennis in Houston
|
by: UJ |
last post by:
I have a WinForm program that has stuff on the form. I want to add something
to it that will have an image over a portion of the window that is
translucent. How can I do this?
Also - I need to have a popup window that is transparent. Is there any way
to do this?
TIA - Jeff.
| |
by: Lou |
last post by:
I have a picture box with an image loaded into it from an Image list (Its a
solid Black Image).
Next I draw some lines into the picture box.
The resulting image with the lines is NOT the return value of
PictureBox1.Image????
In the exapmle below control "D" shows only the picture(Black Image) without
the lines I added using the brush?
The Picturebox shows the lines nicely but the lines don't seem to be part of
the controls "Inage"...
|
by: tristanlbailey |
last post by:
I have been attempting to solve this problem for a few weeks now, but I'm not having much luck...
I would like to create a seamless fading effect on each form/window in my program; one that, when an image is clicked with a mouse and held, the window fades away by approximately 50% transparency, and when the mouse button is released, fades back to opaque.
I have been able to do this to an extent, with the SetLayeredWindowAttributes...
|
by: Johnny J. |
last post by:
I've got an inherited control where I want the user to be able to specify a
color property. Using that color, I'm drawing a line
private m_UserDefinedColor as Color
.....
Dim g as Graphics=this.CreateGraphics
Dim myPen as Pen = new Pen(m_UserDefinedColor)
g.DrawLine(myPen, X1, Y, X2 - 1, Y)
|
by: Tom P. |
last post by:
I am doing quite a bit of custom painting and it means I have to
create a lot of brushes (think one for every file system object in a
directory) per paint. How expensive is this? Should I find a way to
create the brushes once, store them in an member variable, and use
them when I need them? Or is creating brushes a throw-away process
that doesn't take a lot of work?
Thanks for the info.
Tom P.
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |