How to make image transparent


Author
Message
Kirk Kanjian
Kirk Kanjian
Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)
Group: Forum Members
Posts: 8, Visits: 18
Hello,

I am using the following code to download the renderings as image from NThinDiagramControl.
I need to set the Transparency for the image.
Please let me know how can i set it.

Dim image As INImage = NThinDiagramControl1.GetImage(imageFormat, New NSize(txtImgPixelSize.Text.Trim, txtImgPixelSize.Text.Trim), New NResolution(200, 200))

Thanks

Nevron Support
Nevron Support
Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)
Group: Administrators
Posts: 3.1K, Visits: 4.2K
Hello Kirk,

Generating transparent PNG images is not supported out of the box, but you can try the following workaround:
1. Create a PNG image format with a pixel format that supports transparency
2. Generate a raster image
3. Use the MakeTransparent method of the .NET bitmap object to make the white pixels transparent
4. Save the bitmap to file or stream

Following is a code example:

NPngImageFormat pngFormat = new NPngImageFormat();
pngFormat.PixelFormat = System.Drawing.Imaging.PixelFormat.Format32bppArgb;

NRasterImage image = NThinDiagramControl1.GetImage(pngFormat) as NRasterImage;
image.Bitmap.MakeTransparent(Color.White);
image.Bitmap.Save(@"C:\web-image.png");



Best Regards,
Nevron Support Team


GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Similar Topics

Reading This Topic
2 active, 2 guests, 0 members, 0 anonymous
No members currently viewing this topic!

Login

Explore
Messages
Mentions
Search