Profile Picture

How to make image transparent

Posted By Kirk Kanjian 2 Years Ago
Author
Message
Kirk Kanjian
Problem Posted 2 Years Ago
View Quick Profile
Forum Newbie

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
Last Active: 2 Years Ago
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
Posted 2 Years Ago
View Quick Profile
Supreme Being

Supreme Being (4,329 reputation)Supreme Being (4,329 reputation)Supreme Being (4,329 reputation)Supreme Being (4,329 reputation)Supreme Being (4,329 reputation)Supreme Being (4,329 reputation)Supreme Being (4,329 reputation)Supreme Being (4,329 reputation)Supreme Being (4,329 reputation)

Group: Forum Members
Last Active: Last Year
Posts: 3,039, Visits: 3,746
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





Similar Topics


Reading This Topic