Could this not present a usability issue? It is unlikely your users will expect this behaviour.
A:
Galwegian
2009-02-05 15:58:01
K, let me edit my question. Semi-transparent was the word I needed to use.
Dustin Brooks
2009-02-05 16:00:07
And this probably should have been a comment, not an answer. Just sayin.
Dustin Brooks
2009-02-05 16:01:52
A:
On the top of my head (I would try that first):
- create new bitmap with same size as original, but with ARGB structure
- drawimage: existing bitmap to the new bitmap
- access raw bitmap data, and replace A bytes with 128
You should have nice semitransparent bitmap there.
If performance allows, you can scan for fully transparent pixels and set A to zero for them!
Daniel Mošmondor
2009-09-04 21:39:35
+2
A:
I've tried following example, and it was working fine...
public struct IconInfo
{
public bool fIcon;
public int xHotspot;
public int yHotspot;
public IntPtr hbmMask;
public IntPtr hbmColor;
}
[DllImport("user32.dll")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool GetIconInfo(IntPtr hIcon, ref IconInfo pIconInfo);
[DllImport("user32.dll")] public static extern IntPtr CreateIconIndirect(ref IconInfo icon);
public static Cursor CreateCursor(Bitmap bmp, int xHotSpot, int yHotSpot)
{
IntPtr ptr = bmp.GetHicon();
IconInfo tmp = new IconInfo();
GetIconInfo(ptr, ref tmp);
tmp.xHotspot = xHotSpot;
tmp.yHotspot = yHotSpot;
tmp.fIcon = false;
ptr = CreateIconIndirect(ref tmp);
return new Cursor(ptr);
}
And i've put this on button click event (you can call from where you like):
Bitmap b = new Bitmap("D:/Up.png"); this.Cursor = CreateCursor(b, 5, 5);
And the Up.png image is savd with 75% opacity in AdobePhotoshop.
ZokiManas
2009-09-11 06:52:19