I am attempting to generate partially transparent images for PNG Export
, but seem to run to the following issue. If I Rasterize
a simple piece of Graphics
with Background -> None
(transparent) it looks worse:
rings = Image[
Rasterize[
Graphics[{Black, Disk[], White, Disk[{1, 1}/64, 1 - Sqrt[2]/64]}],
Background -> #, RasterSize -> 400, ImageSize -> 400]] & /@ {None, White}
First version appears jagged, as a circle drawn using a too simple polygon would do. I can verify this with ImageDifference
:
ImageAdjust[ImageDifference @@ (RemoveAlphaChannel[#, White] & /@ rings)]
Jagged pattern is clearly visible.
How to use Rasterize
with Background -> None
(or anything similar generating an alpha-channel image) and achieve good output quality without resorting to generating primitives such as Disk
using hand-crafted code?
Clarification:
I want alpha channel on the output to behave as it does on Rasterize[..., Background -> None]
. That is, the image having conceptually three regions: transparent background, black outer disk and white (non-transparent) inner disk.
(These screenshots were taken on Mathematica 9.0.1.0 running on OS X 10.8.4.)
Background -> None
inGraphics
is that it alone is not enough to produce an alpha-channel image, and if the same is done also inRasterize
, the issue creeps up again. $\endgroup$