From 5eb74dd59ad1dfafc6128b07eb778db7beae6672 Mon Sep 17 00:00:00 2001 From: Gleb Khmyznikov Date: Fri, 20 Jun 2025 12:33:36 +0200 Subject: [PATCH] Add Color Picker doc --- doc/devdocs/modules/colorpicker.md | 41 ++++++++++++++++++++++++++++++ doc/devdocs/modules/readme.md | 2 +- 2 files changed, 42 insertions(+), 1 deletion(-) create mode 100644 doc/devdocs/modules/colorpicker.md diff --git a/doc/devdocs/modules/colorpicker.md b/doc/devdocs/modules/colorpicker.md new file mode 100644 index 0000000000..680284dc6e --- /dev/null +++ b/doc/devdocs/modules/colorpicker.md @@ -0,0 +1,41 @@ +# Color Picker + +## Overview +Color Picker is a system-wide color picking utility for Windows that allows users to pick colors from any screen and copy them to the clipboard in a configurable format. + +## Implementation Details + +### Color Capturing Mechanism +The Color Picker works by following these steps to capture the color at the current mouse position: + +1. Obtain the position of the mouse +2. Create a 1x1 size rectangle at that position +3. Create a Bitmap class and use it to initiate a Graphics object +4. Create an image associated with the Graphics object by leveraging the CopyFromScreen function, which captures the pixel information from the specified location + +### Core Color Picking Function +The following code snippet demonstrates the core functionality of how a color is picked from the screen: + +```csharp +private static Color GetPixelColor(System.Windows.Point mousePosition) +{ + var rect = new Rectangle((int)mousePosition.X, (int)mousePosition.Y, 1, 1); + using (var bmp = new Bitmap(rect.Width, rect.Height, PixelFormat.Format32bppArgb)) + { + var g = Graphics.FromImage(bmp); + g.CopyFromScreen(rect.Left, rect.Top, 0, 0, bmp.Size, CopyPixelOperation.SourceCopy); + + return bmp.GetPixel(0, 0); + } +} +``` + +## Features +- Pick colors from any pixel on the screen +- View color information in various formats (RGB, HEX, HSL, etc.) +- Copy color values to clipboard in configurable formats +- Color history for quick access to previously selected colors +- Keyboard shortcuts for quick activation and operation + +## User Experience +When activated, Color Picker displays a magnified view of the area around the cursor to allow for precise color selection. Once a color is selected, it can be copied to the clipboard in the user's preferred format for use in design tools, development environments, or other applications. diff --git a/doc/devdocs/modules/readme.md b/doc/devdocs/modules/readme.md index ef2bfd6e1a..fd043d1167 100644 --- a/doc/devdocs/modules/readme.md +++ b/doc/devdocs/modules/readme.md @@ -7,6 +7,7 @@ This section contains documentation for individual PowerToys modules, including | Module | Description | |--------|-------------| | [Always on Top](alwaysontop.md) | Tool for pinning windows to stay on top of other windows | +| [Color Picker](colorpicker.md) | Tool for selecting and managing colors from the screen | | [Crop and Lock](cropandlock.md) | Tool for cropping application windows into smaller windows or thumbnails | | [Environment Variables](environmentvariables.md) | Tool for managing user and system environment variables | | [FancyZones](fancyzones.md) ([debugging tools](fancyzones-tools.md)) | Window manager utility for custom window layouts | @@ -33,7 +34,6 @@ The following modules currently lack comprehensive documentation. Contributions |--------|-------------| | Advanced Paste | Tool for enhanced clipboard pasting with formatting options | | Awake | Tool to keep your computer awake without modifying power settings | -| Color Picker | Tool for selecting and managing colors from the screen | | Command Not Found | Tool suggesting package installations for missing commands | | File Explorer add-ons | Extensions for enhancing Windows File Explorer functionality | | Image Resizer | Tool for quickly resizing images within File Explorer |