Mouse Cursor transparent image

  • Thread starter Thread starter jjj
  • Start date Start date
J

jjj

hi,

I wonder if it is possible to make mouse cursor image transparent (using
alpha bending).

thanks.
 
Hi jjj
I'm not sure if cursor files (*.cur) support alpha blending. But they have
do have transparent color. Evidently, crusors have hollows and different
shapes.
Do you want translucent cursors?
 
Stoitcho Goutsev (100) said:
Hi jjj
I'm not sure if cursor files (*.cur) support alpha blending. But they have
do have transparent color. Evidently, crusors have hollows and different
shapes.
Do you want translucent cursors?


Hi Stoitcho,

I'm trying to do grid column move(dragdrop), in which, image under cursor
can be done with unmanaged code.

Instead, I used cursor image (without using unmanaged code). The only thing
is that the cursor image is not translucent, hence blocking the grid header
detail.

I think, I have no choice other then using unmanaged code.

Thanks.
 
Hi jjj

What you see in the application giving feedback when drag something over
their windows is not the cursor itself. During D&D the cursor is controlled
by the source application and it is the same for all targets. Yhe target at
the other hand can drag an image along with the cursor to provide visual
feedback to the user. Drawing translucent image can be done in .NET and you
don't have to use nay unmanaged API for that.

Look at the Graphics.DrawImage overloads that take ImageAttribute parameter.
In this image attribute you can set ColorKey or you have a more powerful
option to set a color matrix.

Using color matrix you can draw translucent bitmaps on the screen.
Color matrices works on the same way as transformation matrices with the
difference that they apply on color vectors [RGBAw] where w = 1. I believe
docs say wrong that the vector is [ARGBw]
Anyways, You can draw a translucent image using the following code

ImageAttributes ia = new ImageAttributes();
ColorMatrix cm = new ColorMatrix();
cm.Matrix33 = 0.5F; //50% transparency
ia.SetColorMatrix(cm);

using( Graphics g = CreateGraphics())
{
using(Bitmap bmp = new Bitmap(@"path to some image file"))
{
g.Clear(this.BackColor);
g.DrawImage(bmp, this.ClientRectangle, 0, 0, bmp.Width, bmp.Height,
GraphicsUnit.Pixel, ia);
}
 
Back
Top