Ejemplo n.º 1
0
        private void AngleBgImg_PointerPressed(object sender, PointerRoutedEventArgs e)
        {
            _angleImgPressing = true;
            Point currentLocation = e.GetCurrentPoint(AngleGrid).Position;

            double dx  = currentLocation.X - AngleImgCenter.X;
            double dy  = currentLocation.Y - AngleImgCenter.Y;
            double hue = Math2.ComputeH(dx, dy);

            AngleStoryboardStart(hue);
        }
Ejemplo n.º 2
0
        private void AngleBgImg_PointerMoved(object sender, Windows.UI.Xaml.Input.PointerRoutedEventArgs e)
        {
            Point currentLocation = e.GetCurrentPoint(AngleGrid).Position;

            if (_angleImgPressing)
            {
                double dx  = currentLocation.X - AngleImgCenter.X;
                double dy  = currentLocation.Y - AngleImgCenter.Y;
                double hue = Math2.ComputeH(dx, dy);
                AngleIcImgRotation.Angle = hue;
            }
        }
Ejemplo n.º 3
0
        private void Circle_PointerPressed(object sender, PointerRoutedEventArgs e)
        {
            Point currentLocation = e.GetCurrentPoint(RingGrid).Position;

            RingGrid.CapturePointer(e.Pointer);

            PointerEventHandler moved = null;

            moved = (s, args) =>
            {
                currentLocation = e.GetCurrentPoint(RingGrid).Position;
                double dx = currentLocation.X - colorRingCenter.X;
                double dy = currentLocation.Y - colorRingCenter.Y;
                //---
                double hue = Math2.ComputeH(dx, dy);
                //---
                Hue          = Math2.ComputeH(dx, dy);
                CurrentColor = Math2.HSVToRGB(Hue, Saturation, Value);

                CompositeTransform ct = SeletcedColorEllipseCompositeTransform;
                Point targetPoint     = new Point(ct.TranslateX, ct.TranslateY);
                ColorPickerStoryboardStart(Hue, targetPoint);
                SelectedColorShowArea.Fill = new SolidColorBrush(CurrentColor);
            };
            PointerEventHandler released = null;

            released = (s, args) =>
            {
                double dx = currentLocation.X - colorRingCenter.X;
                double dy = currentLocation.Y - colorRingCenter.Y;
                //---
                double hue = Math2.ComputeH(dx, dy);
                //---
                Hue          = Math2.ComputeH(dx, dy);
                CurrentColor = Math2.HSVToRGB(Hue, Saturation, Value);

                CompositeTransform ct = SeletcedColorEllipseCompositeTransform;
                Point targetPoint     = new Point(ct.TranslateX, ct.TranslateY);
                ColorPickerStoryboardStart(Hue, targetPoint);
                SelectedColorShowArea.Fill = new SolidColorBrush(CurrentColor);
                RingGrid.PointerMoved     -= moved;
                RingGrid.PointerReleased  -= released;
            };

            RingGrid.PointerMoved    += moved;
            RingGrid.PointerReleased += released;
        }
Ejemplo n.º 4
0
        private unsafe void ChangeColorRingColorPixel()
        {
            using (BitmapBuffer buffer = colorRingSoftwareBitmap.LockBuffer(BitmapBufferAccessMode.Write))
            {
                using (var reference = buffer.CreateReference())
                {
                    byte *dataInBytes;
                    uint  capacity;
                    ((IMemoryBufferByteAccess)reference).GetBuffer(out dataInBytes, out capacity);

                    // Fill-in the BGRA plane
                    BitmapPlaneDescription bufferLayout = buffer.GetPlaneDescription(0);
                    double imgWidth   = bufferLayout.Width;
                    double imgHeight  = bufferLayout.Height;
                    double imgCenterW = bufferLayout.Width / 2;
                    double imgCenterH = bufferLayout.Height / 2;

                    for (int row = 0; row < imgHeight; row++)
                    {
                        for (int col = 0; col < imgWidth; col++)
                        {
                            double   dx    = col - imgCenterW;
                            double   dy    = row - imgCenterH;
                            double   hue   = Math2.ComputeH(dx, dy);
                            HSVColor hsv   = new HSVColor(hue, 1.0, 1.0);
                            Color    color = hsv.GetRGB();

                            int pixelIndex = bufferLayout.Stride * row + 4 * col;
                            if (dataInBytes[pixelIndex + 3] != 0)
                            {
                                dataInBytes[pixelIndex + 0] = (byte)color.B;
                                dataInBytes[pixelIndex + 1] = (byte)color.G;
                                dataInBytes[pixelIndex + 2] = (byte)color.R;
                            }
                        }
                    }
                }
            }
        }