SetPixel() public method

public SetPixel ( int x, int y, System.Pixel colour ) : void
x int
y int
colour System.Pixel
return void
Beispiel #1
0
        protected override void OnMouseMove(MouseEventArgs e)
        {
            int x = (int)((e.X - ClientRectangle.Left) / Image.ZoomScale);
            int y = (int)((e.Y - ClientRectangle.Top) / Image.ZoomScale);

            if (myMovingSelected)
            {
                if (myMovingLayer && myTempLayer == null && (x != myAnchorPos.X || y != myAnchorPos.Y))
                {
                    myTempLayer = new Layer(Image);
                    bool noSelection = mySelectedArea == 0;
                    for (int px = 0; px < Image.Width; ++px)
                    {
                        for (int py = 0; py < Image.Height; ++py)
                        {
                            if (noSelection || mySelectedPixels[px, py])
                            {
                                PixelSelect(px, py, CurrentLayer.Pixels[px, py] == Pixel.Empty);
                                myTempLayer.SetPixel(px, py, CurrentLayer.Pixels[px, py]);

                                if (!ModifierKeys.HasFlag(Keys.Control))
                                {
                                    CurrentLayer.SetPixel(px, py, Pixel.Empty);
                                }
                            }
                        }
                    }
                }

                UpdateMovedRect(x, y);
            }

            if (myDrawingPencil)
            {
                if (MouseButtons.HasFlag(MouseButtons.Left))
                {
                    DrawPencil(x, y, Image.CurrentPixel);
                }
                else
                {
                    DrawPencil(x, y, Pixel.Empty);
                }
            }

            if (mySelectingPixels || myDrawingBox)
            {
                UpdateBoxPreview(x, y);
            }
        }
Beispiel #2
0
        protected override void OnMouseMove( MouseEventArgs e )
        {
            int x = (int) ( ( e.X - ClientRectangle.Left ) / Image.ZoomScale );
            int y = (int) ( ( e.Y - ClientRectangle.Top ) / Image.ZoomScale );

            if ( myMovingSelected )
            {
                if ( myMovingLayer && myTempLayer == null && ( x != myAnchorPos.X || y != myAnchorPos.Y ) )
                {
                    myTempLayer = new Layer( Image );
                    bool noSelection = mySelectedArea == 0;
                    for ( int px = 0; px < Image.Width; ++px )
                    {
                        for ( int py = 0; py < Image.Height; ++py )
                        {
                            if ( noSelection || mySelectedPixels[ px, py ] )
                            {
                                PixelSelect( px, py, CurrentLayer.Pixels[ px, py ] == Pixel.Empty );
                                myTempLayer.SetPixel( px, py, CurrentLayer.Pixels[ px, py ] );

                                if( !ModifierKeys.HasFlag( Keys.Control ) )
                                    CurrentLayer.SetPixel( px, py, Pixel.Empty );
                            }
                        }
                    }
                }

                UpdateMovedRect( x, y );
            }

            if ( myDrawingPencil )
            {
                if ( MouseButtons.HasFlag( MouseButtons.Left ) )
                    DrawPencil( x, y, Image.CurrentPixel );
                else
                    DrawPencil( x, y, Pixel.Empty );
            }

            if ( mySelectingPixels || myDrawingBox )
                UpdateBoxPreview( x, y );
        }