Hello!<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />
Thank you for your inquiry.
This code meets general idea. But I can recommend checking some details.
Black background doesn’t depend on destination image format. If you are rendering a transparent metafile then background pixels won’t change anyway. A newly created non-transparent bitmap seems to be black and a transparent has initially “full-transparent color”. I was unable to find any promise from Microsoft that it is a constraint. So that’s you choose whether to rely on that or not. If you know more please share that with the community. Maybe it’s an implication from that .NET Framework always initializes objects to respective zeroes (numeric zero, false, null).
You should either know what background will be and fill the bitmap before rendering or create a transparent bitmap. First case is not universal. For instance, you cannot determine from the document model what color could be in background of a floating image. It could be anything, even another image. Second case is not perfect because Aspose.Pdf makes images “pixellated” as you expressed. It is so-named transparency moire at the boundary between transparent and non-transparent areas. The same dilemma we experience inside Aspose.Words and try to determine background ourselves wherever possible. I asked Aspose.Pdf Team about rendering quality but they seemingly postponed the issue.
Regarding destination image size I meant what is returned by Aspose.Words.Drawing.ShapeBase.SizeInPoints property of the current shape. That’s what I would start with because Aspose.Words chooses this size when scaling. If you take image size in pixels from ImageData containing a metafile then you get something calculated according metafile’s resolution and intended size. That’s not what you need since we are trying to change resolution. Image in terms of MS Word and Aspose.Words is a kind of shape. That’s why terminology is a bit confusing.
You can play with Graphics class to improve quality. For instance, try setting InterpolationMode.HighQualityBicubic.
If you can change metafile resolution somehow manually or programmatically then you won’t need rendering at all. Resetting resolution stored in images to zero will default it to SaveOptions.PdfExportMetafileResolution that you originally tried to set. Aspose.Words API related to image scaling and resolution looks tricky. We tried to make it clearer but that’s not easy too. If you have any idea how to improve it please share it with us.