Ejemplo n.º 1
0
        protected unsafe override void OnFillRegionComputed(IBitVector2D stencil)
        {
            Document     doc  = PintaCore.Workspace.ActiveDocument;
            ImageSurface surf = doc.ToolLayer.Surface;

            using (var g = new Context(surf)) {
                g.Operator = Operator.Source;
                g.SetSource(doc.CurrentUserLayer.Surface);
                g.Paint();
            }

            SimpleHistoryItem hist = new SimpleHistoryItem(Icon, Name);

            hist.TakeSnapshotOfLayer(doc.CurrentUserLayer);

            ColorBgra  color  = fill_color.ToColorBgra().ToPremultipliedAlpha();
            ColorBgra *dstPtr = (ColorBgra *)surf.DataPtr;
            int        width  = surf.Width;

            surf.Flush();

            // Color in any pixel that the stencil says we need to fill
            Parallel.For(0, stencil.Height, y =>
            {
                int stencil_width = stencil.Width;
                for (int x = 0; x < stencil_width; ++x)
                {
                    if (stencil.GetUnchecked(x, y))
                    {
                        surf.SetColorBgraUnchecked(dstPtr, width, color, x, y);
                    }
                }
            });

            surf.MarkDirty();

            // Transfer the temp layer to the real one,
            // respecting any selection area
            using (var g = doc.CreateClippedContext()) {
                g.Operator = Operator.Source;
                g.SetSource(surf);
                g.Paint();
            }

            doc.ToolLayer.Clear();

            doc.History.PushNewItem(hist);
            doc.Workspace.Invalidate();
        }
Ejemplo n.º 2
0
        private void DoRotate(RotateZoomData rotateZoomData)
        {
            Document doc = PintaCore.Workspace.ActiveDocument;

            PintaCore.Tools.Commit();

            var oldSurface = doc.CurrentLayer.Surface.Clone();

            doc.CurrentLayer.Rotate(rotateZoomData.Angle);
            doc.Workspace.Invalidate();

            var historyItem = new SimpleHistoryItem("Menu.Layers.RotateZoom.png", Catalog.GetString("Rotate / Zoom Layer"), oldSurface, doc.CurrentLayerIndex);

            doc.History.PushNewItem(historyItem);
        }
Ejemplo n.º 3
0
        private void StopEditing()
        {
            // If we don't have an open document, some of this stuff will crash
            if (!PintaCore.Workspace.HasOpenDocuments)
            {
                return;
            }

            if (!is_editing)
            {
                return;
            }

            try {
                Document doc = PintaCore.Workspace.ActiveDocument;

                doc.ToolLayer.Clear();
                doc.ToolLayer.Hidden = true;

                if (engine.EditMode == EditingMode.Editing)
                {
                    SimpleHistoryItem hist = new SimpleHistoryItem(Icon, Name);
                    hist.TakeSnapshotOfLayer(doc.CurrentLayerIndex);

                    // Redraw the text without the cursor,
                    // and on to the real layer
                    RedrawText(false, false);

                    doc.History.PushNewItem(hist);
                }

                engine.Clear();
                doc.Workspace.Invalidate(old_bounds);
                old_bounds = Rectangle.Zero;
                is_editing = false;
            } catch (Exception) {
                // Just ignore the error
            }
        }