Hi,
we tried this new code but we experience some problems: basically PNG file result completely white or with some little regions draw.
You can see in the attachments original test file, image printed from a CAD viewer (representing real original image), and the two files exported with Aspose (png and PDF).
The C# code we used is this:
Aspose.Imaging.ImageOptions.CadRasterizationOptions rasterizationOptions = new Aspose.Imaging.ImageOptions.CadRasterizationOptions();
rasterizationOptions.BackgroundColor = Aspose.Imaging.Color.Black;
//rasterizationOptions.PageWidth = ((Aspose.Imaging.Image)m_oDocument).Width;
//rasterizationOptions.PageHeight = ((Aspose.Imaging.Image)m_oDocument).Height;
if (((Aspose.Imaging.FileFormats.Cad.CadImage)m_oDocument).Width > ((Aspose.Imaging.FileFormats.Cad.CadImage)m_oDocument).Height)
{
if (((Aspose.Imaging.FileFormats.Cad.CadImage)m_oDocument).Width > 1024)
{
int iWidth = 1024;
int iHeight = (int)((1024.0f / (float)((Aspose.Imaging.FileFormats.Cad.CadImage)m_oDocument).Width) * (float)((Aspose.Imaging.FileFormats.Cad.CadImage)m_oDocument).Height);
rasterizationOptions.PageWidth = iWidth;
rasterizationOptions.PageHeight = iHeight;
}
}
else
{
if (((Aspose.Imaging.Image)m_oDocument).Height > 1024)
{
int iHeight = 1024;
int iWidth = (int)((1024.0f / (float)((Aspose.Imaging.FileFormats.Cad.CadImage)m_oDocument).Height) * (float)((Aspose.Imaging.FileFormats.Cad.CadImage)m_oDocument).Width);
rasterizationOptions.PageWidth = iWidth;
rasterizationOptions.PageHeight = iHeight;
}
}
rasterizationOptions.DrawColor = Aspose.Imaging.Color.White;
rasterizationOptions.DrawType = Aspose.Imaging.FileFormats.Cad.CadDrawTypeMode.UseDrawColor;
rasterizationOptions.Layers = new List { "layer1" };
rasterizationOptions.LayoutName = "layout1";
Aspose.Imaging.ImageOptions.PngOptions OptionsI = new Aspose.Imaging.ImageOptions.PngOptions();
OptionsI.ColorType = Aspose.Imaging.FileFormats.Png.PngColorType.TruecolorWithAlpha;
OptionsI.TransparentColor = new Aspose.Imaging.TransparentColorSetting(Aspose.Imaging.Color.Transparent);
Aspose.Imaging.ResolutionSetting oResI = new Aspose.Imaging.ResolutionSetting(Convert.ToDouble(m_iResolution), Convert.ToDouble(m_iResolution));
OptionsI.ResolutionSettings = oResI;
OptionsI.VectorRasterizationOptions = rasterizationOptions;
((Aspose.Imaging.Image)m_oDocument).Save(_oOutputStream, OptionsI);
as you can see we tried to change background colors or draw colors, excluding text layer and so on but we can obtain only a white image or a black image.
with pdf export, even if is the same code, we obtain a partial file with some drawings (but not all and none of text layer )
The real file contains drawings and text (over draw layer and in the right part box).
This is the first (and the one) problem: a second problem is document resizing lack in Aspose.Imaging.FileFormats.Cad.CadImage class
we use this code for all type of images (works for all images):
m_oDocument = Aspose.Imaging.Image.Load(_oInputStream);
m_iPageCount = 1;
//resize
if (((Aspose.Imaging.Image)m_oDocument).Width > ((Aspose.Imaging.Image)m_oDocument).Height)
{
if (((Aspose.Imaging.Image)m_oDocument).Width > 1024)
{
int iWidth = 1024;
int iHeight = (int)((1024.0f / (float)((Aspose.Imaging.Image)m_oDocument).Width) * (float)((Aspose.Imaging.Image)m_oDocument).Height);
((Aspose.Imaging.Image)m_oDocument).Resize(iWidth, iHeight, Aspose.Imaging.ResizeType.NearestNeighbourResample);
}
}
else
{
if (((Aspose.Imaging.Image)m_oDocument).Height > 1024)
{
int iHeight = 1024;
int iWidth = (int)((1024.0f / (float)((Aspose.Imaging.Image)m_oDocument).Height) * (float)((Aspose.Imaging.Image)m_oDocument).Width);
((Aspose.Imaging.Image)m_oDocument).Resize(iWidth, iHeight, Aspose.Imaging.ResizeType.NearestNeighbourResample);
}
}
but if we use for dwg files, like this:
m_oDocument = (Aspose.Imaging.FileFormats.Cad.CadImage)Aspose.Imaging.Image.Load(_oInputStream);
m_iPageCount = 1;
//if (((Aspose.Imaging.FileFormats.Cad.CadImage)m_oDocument).Width > ((Aspose.Imaging.FileFormats.Cad.CadImage)m_oDocument).Height)
//{
// if (((Aspose.Imaging.FileFormats.Cad.CadImage)m_oDocument).Width > 1024)
// {
// int iWidth = 1024;
// int iHeight = (int)((1024.0f / (float)((Aspose.Imaging.FileFormats.Cad.CadImage)m_oDocument).Width) * (float)((Aspose.Imaging.FileFormats.Cad.CadImage)m_oDocument).Height);
// ((Aspose.Imaging.FileFormats.Cad.CadImage)m_oDocument).Resize(iWidth, iHeight, Aspose.Imaging.ResizeType.NearestNeighbourResample);
// }
//}
//else
//{
// if (((Aspose.Imaging.Image)m_oDocument).Height > 1024)
// {
// int iHeight = 1024;
// int iWidth = (int)((1024.0f / (float)((Aspose.Imaging.FileFormats.Cad.CadImage)m_oDocument).Height) * (float)((Aspose.Imaging.FileFormats.Cad.CadImage)m_oDocument).Width);
// ((Aspose.Imaging.FileFormats.Cad.CadImage)m_oDocument).Resize(iWidth, iHeight, Aspose.Imaging.ResizeType.NearestNeighbourResample);
// }
//}
the instruction .Resize throw in an Exeption “method not implemented”
Why and how we can solve? Maybe it is related with first problem?
We solved moving that code in the method (above) that exports DWG to PNG but, as we said, resulting image is completely white (or black or other background color)
Can you try our code and our test Dwg file and give us correct solution to obtain a complete png (and pdf) file like the example file we attached (that represent what we see opening with a DWG viewer)?
Thank you