Jump to content

midora

Members
  • Posts

    1,782
  • Joined

  • Last visited

  • Days Won

    26

Posts posted by midora

  1. 1 hour ago, Tito said:

    I use the rotate and zoom tool on layers, but it's really hard to use it with trackballs. It's too imprecise to do a flip on an image

     

    Typically it's easier to use the numeric controls to fine-tune the effect. But as @Pixeymentioned sometimes it's better to use a perspective plugin (depending on the effect you like to achieve).

  2. New tools, new challenges, more fun 😉

    I remember when I first had to use this machine to create holes on cards to program the computer on university. Just 40 years have been passed and nowadays we are fighting with gigabits of data per second in mobile communication and still trying to debug and understand what's going on there.

  3. As @null54said. It looks like that you placed your whole project inside of the paint.net folder.

    You should locate it somewhere outside of paint.net folders and just copy the plugin dll from the output folder to the Effect folder using a post-build command.

    It's standard that VS copies your dll and all dependencies and .pdb into the output folder.

     

     

    • Thanks 1
  4. No complains about unsafe code in plugins? 😉

     

    I put the code in an extension method for Surfaces.

     

    Spoiler

            public unsafe static void FromRasterBGRA(this Surface surface, byte[] rasterBGRA)
            {
                int width = surface.Width;
                int height = surface.Height;
                fixed (byte* rasterPtr = rasterBGRA)
                {
                    int row = 0;
                    long srcStride = width * 4;
                    var srcPtr = rasterPtr;
                    var srcRasterEndPtr = srcPtr + srcStride * height;
                    while (srcPtr < srcRasterEndPtr)
                    {
                        var dstPtr = surface.GetRowPointerUnchecked(row);
                        System.Buffer.MemoryCopy(srcPtr, dstPtr, srcStride, srcStride);
                        srcPtr += srcStride;
                        row++;
                    }
                }
            }

     

     

    Pointer operations are fast compared to for loops. If the stride is small then they are beating method calls because of the overhead.

    Sometimes your raster is not in BGRA order. This can be handled easily using pointers.

     

    Still I would like to avoid unsafe code at this level.

    So surface methods to copy from/to part of a row would be great. I.e.

     

    void CopyToRow(byte[] src, long srcOffset, int row, int column, int length);

    void CopyFromRow(byte[] dst, long dstOffset, int row, int column, int length);

     

    void CopyToRow(uint[] src, long srcOffset, int row, int column, int columns);

    void CopyFromRow(uin[] dst, long dstOffset, int row, int column, int columns);

     

    or for a whole raster

     

    void CopyToImage(byte[] src, int srcStride);

    void CopyFromImage(byte[] dst, int dstStride);

     

    void CopyToImage(uint[] src, int srcStride);

    void CopyFromImage(uint[] dst, int dstStride);

     

    Sorry that I have to use spoilers instead of code sections but I'm tired to wait that it opens here (and most of the time it fails).

     

  5. Assuming there is a pixel array containing all pixels of the image in BGRA top-left to bottom-right order. There are many surface methods (let's exclude the obsolete one) which may be helpful. So what's the proposed way for filetype plugins.

     

    Is unsafe code acceptable (like the following).

     

    Spoiler

            unsafe void SurfaceFromRasterBGRA(Surface surface, byte[] rasterBGRA)
            {
                int width = surface.Width;
                int height = surface.Height;
                fixed (byte* rasterPtr = rasterBGRA)
                {
                    int row = 0;
                    var srcPtr = (uint*)rasterPtr;
                    var srcRastercEndPtr = srcPtr + width * height;
                    while (srcPtr < srcRastercEndPtr)
                    {
                        var srcRowEndPtr = srcPtr + width;
                        var dstPtr = (uint*)surface.GetRowPointerUnchecked(row);
                        while (srcPtr < srcRowEndPtr)
                        {
                            *dstPtr++ = *srcPtr++;
                        }
                        row++;
                    }
                }

            }

     

    is the surface data locked during the operation or is there the potential risk of a crash.

     

    I would prefer to use a paint.net method to copy from/to a raster but I didn't find a good method.

     

     

     

     

  6. Thanks for the effort @null54. I just found the topic about the Treatment. Then I looked for Treatment in the registry and found

    HKEY_CLASSES_ROOT\SystemFileAssociations\image
        Key: Treatment Value: 2  (means Photo Border)

    Then I checked the .pdn entry and found

        Key: PerceivedType Value: image

    And that's it. Setting this key to .bmrl shows the drop shadow after a restart of the FileExplorer.

    That's what I expected in the beginning: There must be a kind of file category marker.

    Now I have to figure out how do do this using the sharpshell library. Maybe I have to patch it...

     

  7. Maybe the issue is related to this comment:

     

    An implementation of this interface for photo thumbnails is supplied in Microsoft Windows as CLSID_PhotoThumbnailProvider. Applications that use the supplied implementation must define a constant CLSID identifier using the GUID {C7657C4A-9F68-40fa-A4DF-96BC08EB3551}.

     

     

  8. We know the documentation of these COM interfaces is limited. .NET 4.0 is needed to implement the interfaces in c#.

    I didn't expect that a lot of people are experienced with this. But you never know.

     

    The handler uses COM IThumbnailProvider and returns BGRA (or you couldn't see through 😉

    No idea what's going on there. Just the standard image format thumbnails are showing the shadow AND .pdn.

    It's for sure not important but I really like to understand what's going on.

    In the moment the code for .bmrl draws the image a little bit higher into the bitmap just to reduce the missing shadow offset effect.

    This way the top line of the images in all the thumbnails is adjusted (otherwise the .bmrl thumbnails would sit a bit deeper).

    This seems to work for all thumbnail sizes.

     

    In the moment I'm creating a InfoTipHandler to show some properties of .bmrl files.

     

    Maybe paint.net could add one to show the dimensions of the image.

     

  9.  Sorry the ReadMe file in the shellextensions zip was empty. Which makes it a bit difficult to install the dlls 😞

     

    So here is a new zip WITH installation guide.

     

    bmp+bmrl.thumbnail.shellextension.zip

     

    Before installation (.bmrl already assigned to open with paint.net)

     

    1900869739_XDropShadowThumbnails-2AlwaysOpenWithPaint_net.thumb.png.3f0c2d92b0e423bb7c3166f3ba4a1667.png

     

    After installation

     

    900747822_XDropShadowThumbnails-3AfterRegistration.thumb.png.52bc7eb6af00bf401e8d04d279c52424.png

    .bmps containing athe BMRL format are showing RL in the top left corners. And .bmrl files the image plus the associated application.

     

    • Like 1
  10. The files with extension .bmp and .bmrl are using my new shell extension to create the thumbnails.

    The 'DropShadow bmrl.bmp' file ist just a renamed copy of the 'DropShadow.bmrl' which I saved from paint.net with the bmrl filetype plugin.

    This 'DropShadow bmrl.bmp' is just to show that thumbnails for files with .bmp extension but .bmrl content are showing now a thumbnail. This is not the case without the shell extension for .bmp because Windos detects these .bmp not as bitmap files.

     

    412463290_DropShadowThumbnails.png.8e68a004684a8ebf29224d98e320dcc3.png

    Same effect in Windows light mode.

    So the question is, how does Windows know that .pdn should get a drop shadow but not .bmrl (latest Windows 10).

     

  11. I'm wondering why the thumbnail of a .pdn file shows a drop shadow in FileExplorer icon views (or the preview panel).

    Typically just .bmps are showing the drop shadow and no other file types (on my Windows 10 laptop).

    Any idea/hint why this is the case for .pdn files? I would like to get it for .bmrl.

    I can not imagine that the drop shadow is part of the thumbnail. Because it uses exact the same colors as .bmps in dark and light mode.

    Does it depend on the type of registration?

     

  12. I created shell extensions to show thumbnails of .bmrl files and .bmp files (containing bmrl) in the Windows FileExplorer.

     

    (removed .zip)

     

    First time I did it in c# (based on a project on github, see readme). Astonishing that this works 😉

     

    Maybe it would make sense to add a RL Marker to the .bmp thumbnails so that users already know that they can't be opened easily in a image processing tool.

     

     

    • Like 1
  13. This version of the plugin allows to save as .bmrl.

    There is a restriction in the amount of colors which can be handled (Not more than 251 different RGBAs in a row).

    The reason is that in this case a quantizer has to be called. But this a little bit special if you are working in a 16-bit 565 color space with 5-bit alpha.

    The source calls WuQuantizer16() to do the job. But this source is not included. If the source is available I would use this one.

    We may also quantize the BGRA image to 256 colors first. But not now. Typically icons are small enough that there is no issue with the code.

    Some png test images should be created to stress the save method.

     

     

     

     

     

     

    • Like 1
  14. 3 hours ago, Rick Brewster said:

    Fixed a crash when trying to save an image that does not support loading

    Verified 😉 Still I would prefer not to get a preview at all in this case instead a text like "No preview available". In the moment there is again the original image visible which shows transparency.

    • Like 1
×
×
  • Create New...