Skip to main content

Image Transparency

Version: 4.0

Image Transparency

The PNG image format support transparency. To accomplish adding transparency to an image, define the appropriate ImageFormat with a ColorFormat of type RGBA. This produces a rasterized image that contains transparency.

The following example illustrates adding transparency to a PNG. It uses the PngImageFormat and PngColorFormat classes, and the PdfRasterizer class's Draw method.

PdfRasterizer rasterizer = new PdfRasterizer(pdfFilePath);
PngImageFormat png = new PngImageFormat(PngColorFormat.RgbA);
rasterizer.Draw(pngFilePath, png, ImageSize.Dpi72);
Dim MyRasterizer As PdfRasterizer = New PdfRasterizer(pdfFilePath)
Dim MyPng As PngImageFormat = New PngImageFormat(PngColorFormat.RgbA)
MyRasterizer.Draw(pngFilePath, MyPng, ImageSize.Dpi72)

[PngRgbaTransparency.cs](https://github.com/DynamicPDF/rasterizer-dotnet-core/blob/master/rasterizer-dotnet-examples-csharp/PngRgbaTransparency.cs){#gitlink-id target=_blank}


[PngRgbaTransparency.vb](https://github.com/DynamicPDF/rasterizer-dotnet-core/blob/master/rasterizer-dotnet-vb/PngRgbaTransparency.vb){#gitlink-id target=_blank}

Documentation version