Jump to content

Ego Eram Reputo

Administrator
  • Posts

    14,572
  • Joined

  • Last visited

  • Days Won

    264

Posts posted by Ego Eram Reputo

  1. Some progress.......

     

    // Name: Box Outlining GPU
    // Submenu: test
    // Author:
    // Title:
    // Version:
    // Desc:
    // Keywords:
    // URL:
    // Help:
    
    // For help writing a GPU Drawing plugin: https://boltbait.com/pdn/CodeLab/help/tutorial/drawing/
    
    #region UICode
    IntSliderControl Amount2 = 35; // [15,100] Size
    IntSliderControl Amount3 = 9; // [2,25] Spacing
    #endregion
    
    protected override unsafe void OnDraw(IDeviceContext deviceContext)
    {
        deviceContext.DrawImage(Environment.SourceImage);  // preserve background
    
        // find out where our selection is located
        RectInt32 selection = Environment.Selection.RenderBounds;
    
        // variables
        int boxSize = Amount2/2;
        int Spacing = Amount3+1;
        int doubleSpacing = Amount3*2;
        int thickness = 2;
        int rndHeight, rndWidth; 
        int step = boxSize*7/10;
    
        // define your brush and stroke style
        ISolidColorBrush fillBrush = deviceContext.CreateSolidColorBrush(LinearColors.LightGray);
        ISolidColorBrush outlineBrush = deviceContext.CreateSolidColorBrush(LinearColors.Black);
        IStrokeStyle boxStrokeStyle = deviceContext.Factory.CreateStrokeStyle(StrokeStyleProperties.Default);
    
        // setup drawing mode
        deviceContext.AntialiasMode = AntialiasMode.Aliased;  // or .PerPrimitive
    
        Random rnd = new Random();
            for (int y = selection.Top; y < selection.Bottom; y += step)
        {
            for (int x = selection.Left; x < selection.Right; x += step)
            {
    
               //if source pixel is opaque )
               
                rndWidth = rnd.Next(Spacing, doubleSpacing);
                rndHeight = rnd.Next(Spacing, doubleSpacing);
    
                deviceContext.FillRectangle(x-rndWidth, y-rndHeight, boxSize, boxSize, fillBrush);    
                deviceContext.DrawRectangle(x-rndWidth, y-rndHeight, boxSize, boxSize, outlineBrush, thickness, boxStrokeStyle);    
            }
        }
    }

     

    I haven't figured out how to poll the source pixel yet, so I'm just filling selections at the moment. Still, I think looks great! :mrgreen:

     

    boxoutliningdemo-GPU.png

     

    • Thanks 1
    • Upvote 2
    • You're a Smart Cookie! 1
  2. 21 hours ago, Tactilis said:

    I think the OPDG uses a fixed set of box sizes

    Hadn't considered that. I'll have a look and see if I can make six or seven boxes work.

     

    16 hours ago, BoltBait said:

    Here is a classic script to help you determine when you are on the edge of a selection...

    Nice! Thank you @BoltBait

     

    14 hours ago, Red ochre said:

    Hope that helps... I've found it better to use 'using' statements to ensure graphics objects get disposed of.

    Thanks Red.

     

    12 hours ago, Rick Brewster said:

    FWIW, the classic effect system is getting deprecated, and soon -- I strongly encourage you to switch to BitmapEffect or GpuEffect (or probably [PropertyBased]GpuDrawingEffect in this case).

    Quite right. I will change of course. The posted code was something from a year or so ago (I just had another play with it to remember where I got to).

    • Upvote 1
  3. I could use a little help on this one ;)

     

    I'm trying to recreate an outlining effect I saw on Watabou's one-page dungeon generator. I want to surround an object with little gray boxes something like this image.

     

    box-outlining.png

    I had a very rough stab at it. Basically my plan was to step through the image and test the transparency of the target pixel. If it was transparent, throw a little box around it. The code I wrote trying to hack this out was truly awful.

     

    Spoiler

     

    /* ========================================================================== */
    /*                                                                            */
    /*   BoxOutline.cs                                                            */
    /*   (c) 2024 Ego Eram Reputo                                                 */
    /*                                                                            */
    /*   Description: surrounds a selection with shaded boxes                     */
    /*                                                                            */
    /* ========================================================================== */
    
    // Name: BoxOutline
    // Author: Ego Eram Reputo
    // Submenu: Render
    // URL: http://www.getpaint.net/redirect/plugins.html
    
    #region UICode
    IntSliderControl Amount2 = 25; // [15,100] Box Size
    ReseedButtonControl Amount1 = 0; // Reseed
    IntSliderControl Amount3 = 5; // [1,25] Spacing
    #endregion
    
    void Render(Surface dst, Surface src, Rectangle rect)
    {
        Rectangle selection = EnvironmentParameters.SelectionBounds;
        int boxSize = Amount2/2;
        int Spacing = Amount3;
        int rndHeight, rndWidth, m,p;
        ColorBgra PrimaryColor = (ColorBgra)EnvironmentParameters.PrimaryColor;
    
        Graphics g = new RenderArgs(dst).Graphics;
        g.Clip = new Region(rect);
        g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
    
        Pen outlinePen = new Pen(PrimaryColor, 2);
        SolidBrush solidBrush = new SolidBrush(Color.Beige);
    
        dst.CopySurface(src,rect.Location,rect);
    
        for (int y = selection.Top; y < selection.Bottom; y += boxSize+Spacing)
        {
            for (int x = selection.Left; x < selection.Right; x += boxSize+Spacing)
            {
                if (src[x,y].A >0 )
                {
                    rndHeight = RandomNumber.Next( boxSize/2.0 )+RandomNumber.Next(boxSize/2);
                    rndWidth = RandomNumber.Next(boxSize/2)+RandomNumber.Next(boxSize/2);
                    
                    m=x-rndWidth-boxSize/2+1;
                    if (m<0) {m=0;}
                    p=y-rndHeight-boxSize/2+4;
                    if (p<0) {p=0;}
    
                    g.FillRectangle(solidBrush, m-rndWidth, p-rndHeight, boxSize*2+rndWidth, boxSize*2+rndHeight);
                    g.DrawRectangle(outlinePen, m-rndWidth, p-rndHeight, boxSize*2+rndWidth, boxSize*2+rndHeight);
                }
            }
        }
    }
    
    

     

     

    Results were ......promising!? (at least it was working right 😁)

     

    boxoutline2.png

     

    Does anyone want to help me write something a little more elegant?

    • You're a Smart Cookie! 2
  4. On 3/17/2024 at 12:57 AM, xod said:

    Since I have no intention of redoing it, I think it would be best to delete this post. Anyway, it's not a big loss for the pdn community.

     

    I disagree. I think this plugin is too good to lose.

     

    If you're willing to release the source code I'm sure someone will recompile and publish it.

    • Upvote 1
  5. April Update

     

    One new plugin this month:

     

    Warp text along a path xod Writes text along a user-specified path. The plugin uses the SkiaSharp library, so you need to put all three files from the ZIP file into the Effects folder.

     

    *please note* this plugin is currently undergoing revision/rerwrite to make it conform to standards.

     

    There is also the inclusion of an older plugin - which had been missed (thanks @toe_head2001) Alpha Mask (aka Apply Alpha Mask) from @BoltBait's Plugin Pack.

     

    • Like 1
    • Upvote 1
  6. ^^ Confirmed. Crash seems to be related to setting the Dither Method to Stucki.

     

    Error message:

    Spoiler

    File: C:\Program Files\paint.net\Effects\SimulateColorDepth.dll
    Name: SimulateColorDepthEffect.SimulateColorDepthEffectPlugin
    Version: 1.0.4211.27729
    Author: Cookies
    Copyright: Copyright © Cookies
    Website: http://cookies.dcsrvdls.com/
    Full error message: PaintDotNet.WorkerThreadException: Worker thread threw an exception
     ---> System.IndexOutOfRangeException: Index was outside the bounds of the array.
       at SimulateColorDepthEffect.ErrorDiffusionSimple.ProcessDither(Surface src, Surface dst, PdnRegion reg, Rectangle rect, Int32 BitDepth)
       at SimulateColorDepthEffect.SimulateColorDepthEffectPlugin.Render(EffectConfigToken parameters, RenderArgs dstArgs, RenderArgs srcArgs, Rectangle[] rois, Int32 startIndex, Int32 length)
       at PaintDotNet.Effects.Effect.ClassicEffectRenderer.Render(ReadOnlySpan`1 renderRects) in D:\src\pdn\src_5_0_x\Effects.Core\Effects\Effect.cs:line 616
       at PaintDotNet.Effects.ClassicEffectDriver.OnRendererRender(IClassicEffectRenderer renderer, ILockedBitmap`1 dstBitmap, ReadOnlySpan`1 renderRects) in D:\src\pdn\src_5_0_x\PaintDotNet\Effects\ClassicEffectDriver.cs:line 95
       at PaintDotNet.Effects.EffectDriver`1.RenderWithClipMask(PooledNativeList`1 rois, Result`1 lazyClipMaskRenderer) in D:\src\pdn\src_5_0_x\PaintDotNet\Effects\EffectDriver`1.cs:line 346
       at PaintDotNet.Effects.EffectDriver`1.RendererContext.RenderTile(Int32 tileIndex) in D:\src\pdn\src_5_0_x\PaintDotNet\Effects\EffectDriver`1.cs:line 254
       at PaintDotNet.Effects.EffectDriver`1.RendererContext.RenderNextTile() in D:\src\pdn\src_5_0_x\PaintDotNet\Effects\EffectDriver`1.cs:line 249
       at PaintDotNet.Effects.EffectDriver`1.<>c__DisplayClass51_0.<ThreadFunction>b__0() in D:\src\pdn\src_5_0_x\PaintDotNet\Effects\EffectDriver`1.cs:line 384
       --- End of inner exception stack trace ---
       at PaintDotNet.Effects.EffectDriver`1.DrainExceptions() in D:\src\pdn\src_5_0_x\PaintDotNet\Effects\EffectDriver`1.cs:line 538
       at PaintDotNet.Effects.EffectDriver`1.Abort() in D:\src\pdn\src_5_0_x\PaintDotNet\Effects\EffectDriver`1.cs:line 494
       at PaintDotNet.Effects.EffectDriver`1.Start(EffectConfigToken effectToken) in D:\src\pdn\src_5_0_x\PaintDotNet\Effects\EffectDriver`1.cs:line 437
       at PaintDotNet.Menus.EffectMenuBase.<>c__DisplayClass47_3.<RunEffectImpl>b__6() in D:\src\pdn\src_5_0_x\PaintDotNet\Menus\EffectMenuBase.cs:line 1003

    Diagnostics:

    Application                                            paint.net 5.0.13 (Stable 5.13.8830.42291)
    Build Date                                             Tuesday, 5 March 2024
    Install type                                           Classic

    Language:                                              en-US
    DPI                                                    1 (1.00x scale)
    UI/Canvas GPU                                          True
    Rendering GPU                                          🚀 Performance (NVIDIA GeForce GTX 1060 6GB)
    Remote session                                         False
    Animations                                             True
    Translucent windows                                    True
    Windows Ink                                            True

    OS                                                     Windows 10 Home x64 (10.0.19045.0)
    Runtime                                                .NET 7.0.16 x64

    Physical Memory                                        24,416 MB (15,363 MB free)
    Paging File                                            28,000 MB (15,598 MB free)

    CPU                                                    Intel(R) Core(TM) i5-4570 CPU @ 3.20GHz
        Speed                                              ~3193 MHz
        Cores / Threads                                    4 / 4
        Features                                           SSE, SSE2, SSE3, SSSE3, SSE4_1, SSE4_2, AVX, AVX2

    Monitor                                                1
        Resolution                                         1920 x 1080, 60 Hz
        DPI                                                96 (1.00x scale)
        Coordinates                                        (L=0, T=0, R=1920, B=1080)
        Bit depth                                          8
        Color space                                        RgbFullGamma22NoneP709
        Connected to                                       NVIDIA GeForce GTX 1060 6GB

    Monitor                                                2
        Resolution                                         1920 x 1080, 60 Hz
        DPI                                                96 (1.00x scale)
        Coordinates                                        (L=1920, T=115, R=3840, B=1195)
        Bit depth                                          8
        Color space                                        RgbFullGamma22NoneP709
        Connected to                                       Intel(R) HD Graphics 4600

    Video Card                                             NVIDIA GeForce GTX 1060 6GB
        Hardware Acceleration                              Supported
        Dedicated Video RAM                                6,052 MB
        Dedicated System RAM                               0 MB
        Shared System RAM                                  12,208 MB
        Driver Version                                     27.21.14.5751
        Vendor ID                                          0x10DE
        Device ID                                          0x1C03
        Subsystem ID                                       0x32831462
        Revision                                           161
        LUID                                               0x0000A1C5
        Flags                                              AcgCompatible, SupportMonitoredFences, KeyedMutexConformance
        Graphics Preemption                                PixelBoundary
        Compute Preemption                                 DispatchBoundary
        Outputs                                            1
        Feature Level                                      Level_12_1
        Features                                           Doubles, ComputeShadersEtc
        DXGI Formats                                       A8_UNorm, B8G8R8A8_UNorm, R16G16B16A16_UNorm, R16G16B16A16_Float, R32G32B32A32_Float
        Buffer Precisions                                  UInt8Normalized, UInt8NormalizedSrgb, UInt16Normalized, Float16, Float32
        Maximum Bitmap Size                                16384

    Video Card                                             Intel(R) HD Graphics 4600
        Hardware Acceleration                              Supported
        Dedicated Video RAM                                112 MB
        Dedicated System RAM                               0 MB
        Shared System RAM                                  2,048 MB
        Driver Version                                     20.19.15.4835
        Vendor ID                                          0x8086
        Device ID                                          0x0412
        Subsystem ID                                       0x85341043
        Revision                                           6
        LUID                                               0x0000ADEE
        Flags                                              SupportMonitoredFences, KeyedMutexConformance
        Graphics Preemption                                PrimitiveBoundary
        Compute Preemption                                 ThreadGroupBoundary
        Outputs                                            1
        Feature Level                                      Level_11_1
        Features                                           Doubles, ComputeShadersEtc
        DXGI Formats                                       A8_UNorm, B8G8R8A8_UNorm, R16G16B16A16_UNorm, R16G16B16A16_Float, R32G32B32A32_Float
        Buffer Precisions                                  UInt8Normalized, UInt8NormalizedSrgb, UInt16Normalized, Float16, Float32
        Maximum Bitmap Size                                16384

    Video Card                                             Microsoft Basic Render Driver
        Hardware Acceleration                              N/A
        Dedicated Video RAM                                0 MB
        Dedicated System RAM                               0 MB
        Shared System RAM                                  12,208 MB
        Driver Version                                     10.0.19041.3636
        Vendor ID                                          0x1414
        Device ID                                          0x008C
        Subsystem ID                                       0x00000000
        Revision                                           0
        LUID                                               0x0000AD9C
        Flags                                              Software, AcgCompatible, SupportMonitoredFences, KeyedMutexConformance
        Graphics Preemption                                InstructionBoundary
        Compute Preemption                                 InstructionBoundary
        Outputs                                            0
        Feature Level                                      Level_12_1
        Features                                           Doubles, ComputeShadersEtc
        DXGI Formats                                       A8_UNorm, B8G8R8A8_UNorm, R16G16B16A16_UNorm, R16G16B16A16_Float, R32G32B32A32_Float
        Buffer Precisions                                  UInt8Normalized, UInt8NormalizedSrgb, UInt16Normalized, Float16, Float32
        Maximum Bitmap Size                                8388608

     

     

  7. ^this.

     

    Make the selection & hit the M key twice to enter "modify-the-selection-mode". Click & drag the nubs and/or rotate the selection border the until you have the perfect alignment of the selection rectangle. Press M once more to revert to normal "Move" mode so you can drag/rotate/resize the image region.

     

    Or, if you want to modify the selection border on the fly.....

     

    Hold down the second mouse button (in addition to the first)! The selection border can be dragged around as you are making the selection. In this mode, the keyboard arrow keys move the selection border by one pixel (or 10 pixels if the CTRL key is also held down) for pixel-perfect placement.

  8. 16 minutes ago, Steelking22 said:

    .I would find the ability to draw an "Eraser LIne" (straight or curved) VERY useful. Draw the line with the line drawing tool, then click on the eraser,

     

    Workaround:

    1. Draw your line on a new blank layer.
    2. Activate the Magic Wand tool 🪄
    3. Click on the transparent area (not the line) to select everything except the line
    4. Invert the selection with Ctrl + I
    5. Activate the layer you want the line removed from
    6. Press the Delete key
    7. Hide or delete the layer you drew the line on.

     

    16 minutes ago, Steelking22 said:

    2. Is Paint.net capable of this type of Text Formation?

     

    Yes, try this brand new plugin by @xod:

     

  9. Google Translate:

    Quote
    Good morning.
    
    Is it possible to reduce the size of a photo, while retaining the number of pixels and the entire photo? In other words, is it possible to reduce the size of a photo while retaining all its quality?
    
    I would be happy to have an answer on this.
    
    Thank you and good luck to you.

     

    Reducing the image size reduces the number of pixels.

    • If you want to print the photo at a smaller size, try increasing the DPI (Dots Per Inch) setting in the printing dialog.
    • If you want the file size to be smaller, choose Save As and specify the JPG extension, then lower the quality setting. Specify a different file name so you don't overwrite the original image.
  10. 11 hours ago, Tankertonian said:

    Sorry didn't make it clear. I uninstalled paint.net properly via Control Panel. I later found some residual files, which I removed.

     

    There may still be files lurking around. Do try the link that @Tactilis suggested:

     

    12 hours ago, Tactilis said:

     

×
×
  • Create New...