Advertisement
| 07.12.2008 at 12:50PM PDT, ID: 23559949 |
|
[x]
Attachment Details
|
||
|
[x]
The Solution Rating System
|
||
|
With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.
Your Input Matters If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support. Thank you! |
||
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: |
public static Bitmap CreateMask (Bitmap bmp, int crTransparent)
{
// get the desktop dc
IntPtr hDC = Win32.GetWindowDC(IntPtr.Zero);
// create the source and mask dcs
IntPtr hSrcDC = Win32.CreateCompatibleDC(hDC);
IntPtr hMaskDC = Win32.CreateCompatibleDC(hDC);
// create the mask
IntPtr hSrcBmp = bmp.GetHbitmap();
IntPtr hMaskBmp = Win32.CreateBitmap(bmp.Width, bmp.Height, 1, 1, IntPtr.Zero);
// release the desktop dc
Win32.ReleaseDC(IntPtr.Zero, hDC);
// select the source and mask bmps
IntPtr hOldSrcBitmap = Win32.SelectObject(hSrcDC, hSrcBmp);
IntPtr hOldMaskBitmap = Win32.SelectObject(hMaskDC, hMaskBmp);
// create mask
int nOldBkColor = Win32.SetBkColor(hSrcDC, crTransparent);
Win32.BitBlt(hMaskDC, 0, 0, bmp.Width, bmp.Height, hSrcDC, 0, 0, (int)Win32.ROP.SRCCOPY);
Win32.SetBkColor(hSrcDC, nOldBkColor);
/*
for (int y = 0; y < 32; y++)
for (int x = 0; x < 32; x++)
Win32.SetPixel(hMaskDC, x, y, Win32.GetPixel(hSrcDC, x, y) == crTransparent ? 0x00FFFFFF : 0);
*/
// clean up the dcs
Win32.SelectObject(hSrcDC, hOldSrcBitmap);
Win32.SelectObject(hMaskDC, hOldMaskBitmap);
// Delete the helper DC
Win32.DeleteDC(hMaskDC);
Win32.DeleteDC(hSrcDC);
// delete the source handle we created
Win32.DeleteObject(hSrcBmp);
// create a bitmap object from the handle
Bitmap b = Bitmap.FromHbitmap(hMaskBmp);
// finally, delete the mask handle
Win32.DeleteObject(hMaskBmp);
return b;
}
|
Advertisement