Jump to content

otuncelli

Members
  • Posts

    292
  • Joined

  • Last visited

  • Days Won

    8

Posts posted by otuncelli

  1. You need to derive your plugin class from FileType or PropertyBasedFileType or FileType<TToken, TTWidget> and implement IFileTypeFactory or IFileTypeFactory2 (newer, recommended) interfaces.

     

    Derive from FileType if you don't need to show any settings on Save dialog, 

    Derive from PropertyBasedFileType if you need to show settings on Save dialog using paint.net's internal controls, aka "IndirectUI", 

    Derive from FileType<TToken, TTWidget> if you need to show settings on Save dialog using your own controls

     

    You need to implement your own dialog and controls if you need to show settings when opening a file (in OnLoad method). This isn't something supported officially but possible.

     

    A very simple implementation that derives from FileType:

    https://github.com/PsdPlugin/PsdPlugin/blob/master/PhotoShopFileType/PhotoshopFileType.cs

     

    The code I've posted should go into the Document OnLoad(System.IO.Stream input) method. You create the document using the input stream, return it and then paint.net opens it. 

     

    Also @null54 has lots of open source file type plugins. They helped me a lot when learning stuff.

    https://github.com/0xC0000054?tab=repositories&q=paint.net+filetype

  2. Sure.

     

    using PaintDotNet;
    ...
    ...
    
    // surface contains the pixel data
    Surface surface = new Surface(width, height, SurfaceCreationFlags.DoNotZeroFillHint);
    
    // add your surface to a layer
    BitmapLayer layer = new BitmapLayer(surface, takeOwnership: true)
    {
      Name = "Layer Name",
      Visible = true,
      BlendMode = LayerBlendMode.Normal, 
      Opacity = 255
    };
    
    // then add the layer to a document
    Document document = new Document(width, height);
    document.Layers.Add(layer);

     

    • You're a Smart Cookie! 1
  3. 18 hours ago, janwarming said:

    Does this SVG plugin works fully with the windows store version of paint.net?

     

    Yes. It works with the store version. The installer specifically supports it.

     

    18 hours ago, janwarming said:

    When i open a svg file it display the file as expected, but when i save it, the svg file will be black and white when opened in a browser?

     

    Yes. That's how it works. Colored tracing isn't supported yet. If you need colored tracing i recommend using vtracer or Inkscape.

  4. 6 hours ago, whysomanyquestions said:

    I am getting a No Path image and an error when attempting to export. 

     

     

    Hi, welcome to the forum.

     

    This means the plugin couldn't vectorize your image. It mostly depends on your input image, really. You can't vectorize an empty image e.g. The boundaries/edges need to be clearly visible in your image beforehand for a high quality tracing output. It works best with black/white drawings.

     

    Try changing some settings like Brightness cutoff, Highpass filter radius until it detects the boundaries in your image. You'll be able to export it afterwards.

  5. 58 minutes ago, null54 said:

     

    I am not able to reproduce that crash.

    Here is a new build (version 4.1.8656.35967) with a PDB file, which should give me the line numbers for that crash.

     

    Smudge_41Beta.zip 87.85 kB · 1 download

     

    Tried to debug it myself. `e.Brush` is null for me in this line. I don't have any brushes. Dropdown is empty. It looks for "Smudge Brushes" folder in "paint.net User Files" which I don't have.

    using (Surface brushsource = e.Brush.GetSurface(e.BrushWidth))

     

    Exception details:
    System.NullReferenceException: Object reference not set to an instance of an object.
       at pyrochild.effects.smudge.SmudgeRenderer.OnMouseDown(QueuedToolEventArgs le) in D:\src\pdn-smudge\Smudge\SmudgeRenderer.cs:line 158
       at pyrochild.effects.common.QueuedToolRenderer.Render() in D:\src\pdn-smudge\Smudge\QueuedToolRenderer\QueuedToolRenderer.cs:line 116
       at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
    --- End of stack trace from previous location ---
       at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
  6. It's crashing for me as well. It happens as soon as I click.

     

    Exception details:
    System.NullReferenceException: Object reference not set to an instance of an object.
       at pyrochild.effects.smudge.SmudgeRenderer.OnMouseDown(QueuedToolEventArgs le)
       at pyrochild.effects.common.QueuedToolRenderer.Render()
       at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
    --- End of stack trace from previous location ---
       at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)

     

    • Upvote 1
  7. Updated to v1.0.6.0. This is a big update. Most of the code has been rewritten.

     

    Changelog:

    * Added basic image tracing (vectorization) functionality which works best with black & white drawings. You may save the result as SVG or export as Shape.

    * Switched to use resvg library for rendering engine. It seems to be rendering SVGs much more accurately.

    * Lots of bug fixes and improvements.
    * Fixed auto-switching of theme issue.

    • Like 1
    • Hooray 1
  8. 6 hours ago, Panchdara said:

    PDN 5.0.7

     

     

    C:\Program Files\paint.net\FileTypes\PdfFileTypePlugin\PdfFileType.dll, version 1.0.0.0

    Name: PDF/AI File Type Plugin for Paint.NET
    Type: PdfFileTypePlugin.PdfFileType
    Version: 1.0.0.0
    Author: Osman Tunçelli
    Copyright: Copyright © 2022 Osman Tunçelli
    Website: https://github.com/otuncelli/Portable-Document-Format-Plugin-for-Paint.NET
    This plugin is incompatible with this version of paint.net.
    A required update is available.

     

     

     

    You're using an older version of plugin. Latest one is v1.0.0.1

    • Like 1
  9. 7 hours ago, Robot Graffiti said:

    I'm using ILRepack to merge some ComputeSharp dlls into my plugin DLL and that's working for me (thanks @BoltBait I saw how to use ILRepack in the CodeLab source on GitHub). But I'm stuck on trimming. The trim option in VS only wants to work for a native exe, not for a portable DLL. Do you guys have a suggestion for a tool or method to trim my plugin DLL's dependencies?

     

    You'll need to use both IL Linker Tool (included in dotnet SDK) and ILRepack for this.

     

    Trimming works for DLLs as well if you call it from the command line (using dotnet exec). 

     

    (You'll probably want to fix the path below)

    dotnet exec "C:\Program Files\dotnet\sdk\7.0.101\Sdks\Microsoft.NET.ILLink.Tasks\tools\net7.0\illink.dll" -a "$(TargetPath)" all --trim-mode copy --action copy -d $(TargetDir) --skip-unresolved --action link "ComputeSharp.Core" --action link "ComputeShare.D2D1" -out "$(TargetDir)output"

     

    Here is the post-build event you can use for your plugin: 

      <PropertyGroup>
        <!-- Set Path Variables -->
        <PdnRoot>C:\Program Files\paint.net</PdnRoot>
        <illink>C:\Program Files\dotnet\sdk\7.0.101\Sdks\Microsoft.NET.ILLink.Tasks\tools\net7.0\illink.dll</illink>
      </PropertyGroup>
    
      <!-- Note: Debugging merged/trimmed assemblies can be problematic. So I set a condition that it only works with Release builds. -->
      <Target Name="TrimAndMerge" AfterTargets="PostBuildEvent" Condition="'$(ConfigurationName)' == 'Release'">
        <!-- 1st Step: Trimming with ILLink -->
        <Exec Command="dotnet exec &quot;$(illink)&quot; -a &quot;$(TargetPath)&quot; all &#45;&#45;trim-mode copy &#45;&#45;action copy -d $(TargetDir) &#45;&#45;skip-unresolved &#45;&#45;action link &quot;ComputeSharp.Core&quot; &#45;&#45;action link &quot;ComputeShare.D2D1&quot; -out &quot;$(TargetDir)output&quot;" />
        <!-- 2nd Step: Merge with ILRepack -->
        <Exec Command="ilrepack /internalize /union &quot;$(TargetDir)output\$(TargetName).dll&quot; &quot;$(TargetDir)output\ComputeSharp.Core.dll&quot; &quot;$(TargetDir)output\ComputeSharp.D2D1.dll&quot; /lib:&quot;$(PdnRoot)&quot; /out:&quot;$(TargetPath)&quot;" />
        <!-- 3rd Step: Remove the output directory and its contents created by illink -->
        <Delete Files="$(TargetDir)output" ContinueOnError="false" />
        <RemoveDir Directories="$(TargetDir)output" ContinueOnError="false" />
      </Target>

     

    • Like 1
    • Upvote 1
  10. @Pixey No, you don't need to disable Defender completely. You can add an exclusion.

     

    See here:

    https://support.microsoft.com/en-us/windows/add-an-exclusion-to-windows-security-811816c0-4dfd-af4a-47e4-c301afe13b26?ui=en-US&rs=en-US&ad=US#ID0EBF=Windows_11

     

    If you're having trouble to do this (because Windows being so fast to delete the file), just disable "Real-time Protection" temporarily then add the exclusion.

    • You're a Smart Cookie! 1
  11. 41 minutes ago, BDP said:

    Hi, I tried this Shape, put it into the Shapes folder, but don't see it at all

     

    Brian

     

     

    If you downloaded the zip file you must extract it first. There is a file named nonagon.xaml in it and you must put this file into the Shapes folder, or you can directly extract the zip into the Shapes folder.

     

    ( * I had to zip it because forum doesn't allow uploading as .xaml )

     

     

    1 hour ago, Rle said:

    A Nonagon Shape is in PDN

     

    It goes up to 8, not 9 :) 

    ShapeToolsDropdown.png

  12. Contents of .xaml (Paint.NET Shape) file:

    <ps:SimpleGeometryShape
        xmlns="clr-namespace:PaintDotNet.UI.Media;assembly=PaintDotNet.Framework"
        xmlns:ps="clr-namespace:PaintDotNet.Shapes;assembly=PaintDotNet.Framework"
        DisplayName="Nonagon"
        Geometry="M 250,8.7 L 409.9,66.87,495,214.32,465.44,381.89,335.1,491.3,164.9,491.3,34.56,381.89,5,214.32,90.1,66.87,250,8.7 Z
    "/>

     

    Zipped file:

    nonagon.zip

  13. 1 hour ago, jsoba77 said:

    @otuncelliI tried it but I dont get the same result, same radius aswell

     

     

    Try lower radius values. My sample was too zoomed in so I had to use bigger radius.

     

    1 hour ago, jsoba77 said:

    is there anyway to do this and still keep the previous details as before as this seems to ge make the surface too smooth

     

     

    I don't know. You could try recreating the texture maybe? Because it's easier that way.

     

    I used this texture: https://www.shutterstock.com/image-vector/detailed-woven-fabric-texture-seamless-repeat-1484323856

     

    bFvtqHb.jpeg

     

     

    • Like 1
×
×
  • Create New...