@@ -40,6 +40,23 @@ public static Color Win32GetScreenPixel(int x, int y)
4040 return Color . FromArgb ( 255 , ( byte ) ( ( a >> 0 ) & 0xff ) , ( byte ) ( ( a >> 8 ) & 0xff ) , ( byte ) ( ( a >> 16 ) & 0xff ) ) ;
4141 }
4242
43+ public static PixelColor Win32GetScreenPixelColor ( )
44+ {
45+ CustomPoint cursor ;
46+ GetCursorPos ( out cursor ) ;
47+ IntPtr desk = GetDesktopWindow ( ) ;
48+ IntPtr dc = GetWindowDC ( desk ) ;
49+ int a = ( int ) GetPixel ( dc , cursor . X , cursor . Y ) ;
50+ ReleaseDC ( desk , dc ) ;
51+ var c = new PixelColor ( ) ;
52+ c . Alpha = 255 ;
53+ c . Red = ( byte ) ( ( a >> 0 ) & 0xff ) ;
54+ c . Green = ( byte ) ( ( a >> 8 ) & 0xff ) ;
55+ c . Blue = ( byte ) ( ( a >> 16 ) & 0xff ) ;
56+ return c ;
57+ }
58+
59+
4360 // fix savefiledialog extension https://stackoverflow.com/a/6104319/5452781
4461 public static void UseDefaultExtensionAsFilterIndex ( FileDialog dialog )
4562 {
@@ -95,9 +112,9 @@ public static PixelColor[] LoadPalette(string path, WriteableBitmap targetBitmap
95112 x = y = 0 ;
96113 for ( int i = 0 , len = palette . Length ; i < len ; i ++ )
97114 {
98- SetPixel ( targetBitmap , x , y , ( int ) palette [ i ] . ColorBGRA ) ;
99115 x = i % paletteResolutionX ;
100116 y = ( i % len ) / paletteResolutionX ;
117+ SetPixel ( targetBitmap , x , y , ( int ) palette [ i ] . ColorBGRA ) ;
101118 }
102119
103120 return palette ;
0 commit comments