Paolo Posted April 23, 2020 Share Posted April 23, 2020 Hello, Is there a way to programmatically import an image as png with alpha channel, without showing up the import dialog as in: def vs.ImportImageFileN(filePath, importPt, mode): return HANDLE I am aware of: def vs.ImportImageFile(filePath, importPt): return HANDLE but I am wondering if there is a way to force the default import preferences (JPEG) as PNG with ALPHA channel. This is needed in my perspective rectifier plugin, where a new image (PNG with ALPHA) is created and imported on the fly. Quote Link to comment
JBenghiat Posted April 23, 2020 Share Posted April 23, 2020 I don’t believe there is a way to do this without the SDK. If these are bitmaps in the drawing, though, setting the fill to none (in vs set the FPat to 0), will make all white pixels transparent and may do the trick. 1 Quote Link to comment
Paolo Posted April 24, 2020 Author Share Posted April 24, 2020 Thank you JBenghiat, it works! Even importing a PNG (with alpha) as JPEG, it maintains its transparency. It appears filled with white, but IT CAN BE set to fill none! I was (for years) convinced that JPEGs couldn't have alpha channels, but I was wrong 🤔 Quote Link to comment
JBenghiat Posted April 24, 2020 Share Posted April 24, 2020 It’s not really an alpha channel, just simply treating white pixels as transparent. Vectorworks has actually had this feature for bitmaps for years, even before importing PNG was an option. Quote Link to comment
Paolo Posted April 24, 2020 Author Share Posted April 24, 2020 If all white pixels become transparent, well, this is not so good. In the PNG with alpha there could be white pixels that must remain opaque! I have to test it… I fear, in the end, I have to show up the import dialog to the user, instructing him to choose PNG with ALPHA option… Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.