Page 1 of 2 12 LastLast
Results 1 to 10 of 12

Thread: PNGOUT with transparent background option

  1. #1
    Wish List Administration
    Join Date
    2011-08
    Posts
    4,581

    Default PNGOUT with transparent background option

    Summary: PNGOUT image for command macros.

    Description: The most difficult part of adding CUI commands is creating images for them. It's the only process not installed with AutoCAD. Having the ability to create images for command macros that could automatically be added to both the *.mnr and *_light.mnr files would make customizing AutoCAD and it's verticals much easier.

    Product and Feature: AutoCAD - User Interface

    Submitted By: Tom Beauford on 10/08/2018


  2. #2
    Administrator BlackBox's Avatar
    Join Date
    2009-11
    Posts
    5,719

    Default Re: PNGOUT with transparent background option

    This should help with converting image backgrounds to be transparent PNG:

    http://adndevblog.typepad.com/autoca...nsparency.html
    Last edited by BlackBox; 2018-10-08 at 03:56 PM.
    "How we think determines what we do, and what we do determines what we get."

    Sincpac C3D ~ Autodesk Exchange Apps

    Computer Specs:
    Dell Precision 3660, Core i9-12900K 5.2GHz, 64GB DDR5 RAM, PCIe 4.0 M.2 SSD (RAID 0), 16GB NVIDIA RTX A4000

  3. #3
    Administrator BlackBox's Avatar
    Join Date
    2009-11
    Posts
    5,719

    Default Re: PNGOUT with transparent background option

    I see what you mean now, Tom.

    Having just tried using PNGOUT for the first time to see how I might help with this, it's like Autodesk just duplicated the BMPOUT Command code to export a PNG instead of BMP file extension, but otherwise appears to be identical output.

    Methinks I can combine the Document.CapturePreviewImage() Method to produce a BMP, then employ the above-linked Bitmap.MakeTransparent() + Bitmap.Save(<FileName>, ImageFormat.Png) Methods to produce the desired result in one go... I'll need some time to tinker between projects.
    "How we think determines what we do, and what we do determines what we get."

    Sincpac C3D ~ Autodesk Exchange Apps

    Computer Specs:
    Dell Precision 3660, Core i9-12900K 5.2GHz, 64GB DDR5 RAM, PCIe 4.0 M.2 SSD (RAID 0), 16GB NVIDIA RTX A4000

  4. #4
    Certifiable AUGI Addict
    Join Date
    2001-03
    Location
    Tallahassee, FL USA
    Posts
    3,667

    Default Re: PNGOUT with transparent background option

    I've been using https://www298.lunapic.com/editor/ to resize to 32×32 and set the background transparent and it seemed to work fine. Some took a few tries and I had to rename them each time as they didn't seem to overwrite as I expected. When I imported the 2018 custom CUI into 2019 many of the image backgrounds were off and some of the icons were hokee.

    It's the only CUI interface customization I do that requires separate software to do. Just think they could do a better job.

  5. #5
    Administrator BlackBox's Avatar
    Join Date
    2009-11
    Posts
    5,719

    Default Re: PNGOUT with transparent background option

    Quote Originally Posted by Tom Beauford View Post
    Just think they could do a better job.
    A thousand times... This.

    FWIW, you don't need to resize the icons - AutoCAD will automagically resize them for you - as example, I use 1000x1000 PNGs for both small & large.
    "How we think determines what we do, and what we do determines what we get."

    Sincpac C3D ~ Autodesk Exchange Apps

    Computer Specs:
    Dell Precision 3660, Core i9-12900K 5.2GHz, 64GB DDR5 RAM, PCIe 4.0 M.2 SSD (RAID 0), 16GB NVIDIA RTX A4000

  6. #6
    Administrator BlackBox's Avatar
    Join Date
    2009-11
    Posts
    5,719

    Default Re: PNGOUT with transparent background option

    Okay - Well, that was easy. Haha

    Code:
                    //<snip>
                    Color color = bmp.GetPixel(0, 0);
                    bmp.MakeTransparent(color);
                    bmp.Save(outFile, ImageFormat.Png);
                    //<snip>
    Putting together an app .bundle to upload (tomorrow?), which implements a custom PNGOUTMODE system variable, that when PNGOUTMODE == 1 the native Command is Veto()-ed and my replacement is called which automagically makes the background color to be transparent. Set PNGOUTMODE == 0 to restore native functionality.
    "How we think determines what we do, and what we do determines what we get."

    Sincpac C3D ~ Autodesk Exchange Apps

    Computer Specs:
    Dell Precision 3660, Core i9-12900K 5.2GHz, 64GB DDR5 RAM, PCIe 4.0 M.2 SSD (RAID 0), 16GB NVIDIA RTX A4000

  7. #7
    Certifiable AUGI Addict
    Join Date
    2001-03
    Location
    Tallahassee, FL USA
    Posts
    3,667

    Default Re: PNGOUT with transparent background option

    That will make my life easier.
    Thanks!

  8. #8
    Administrator BlackBox's Avatar
    Join Date
    2009-11
    Posts
    5,719

    Default Re: PNGOUT with transparent background option

    Do you really use the 'selected objects' or just right click/<Enter> to use 'all objects and viewports'?

    I ask, because having this default to the latter is really easy and precludes the need to prompt user at all (relying on the user to first freeze/thaw the needed layers, etc), which makes it more efficient for why I would use this (but not everyone works the same)... Whereas replicating the OOTB Command will take a bit longer.

    For 'selected objects' the code-behind either sets Entity.Visible==false for the objects not selected prior to Document.CapturePreviewImage(), or it uses the selection to produce a Block and P/Invokes a BlockTableRecord.PreviewIcon (not sure which until I test it).
    "How we think determines what we do, and what we do determines what we get."

    Sincpac C3D ~ Autodesk Exchange Apps

    Computer Specs:
    Dell Precision 3660, Core i9-12900K 5.2GHz, 64GB DDR5 RAM, PCIe 4.0 M.2 SSD (RAID 0), 16GB NVIDIA RTX A4000

  9. #9
    Certifiable AUGI Addict
    Join Date
    2001-03
    Location
    Tallahassee, FL USA
    Posts
    3,667

    Default Re: PNGOUT with transparent background option

    Whichever is easier is fine by me. Either would make my life simpler.

    I'd used WMFOUT for years to paste into Word documents as the background since with WMFBKGND OFF sets the background color is transparent. Good for lines only and didn't support width. Sadly there's no PNGBKGND.

  10. #10
    Administrator BlackBox's Avatar
    Join Date
    2009-11
    Posts
    5,719

    Default Re: PNGOUT with transparent background option

    Quote Originally Posted by Tom Beauford View Post
    Whichever is easier is fine by me. Either would make my life simpler.
    PM me you email address and I'll send you something tomorrow.
    "How we think determines what we do, and what we do determines what we get."

    Sincpac C3D ~ Autodesk Exchange Apps

    Computer Specs:
    Dell Precision 3660, Core i9-12900K 5.2GHz, 64GB DDR5 RAM, PCIe 4.0 M.2 SSD (RAID 0), 16GB NVIDIA RTX A4000

Page 1 of 2 12 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •