ImageExporter.CreateBitmap Overload issue
![]() 1/19/2022 9:15 AM
|
---|
Hello Wout. I am trying to export a model to PNG in a fixed size. but no matter what i pass it, it says the parameters is wrong and wants me to use the overload: is this something you have experianced before. |
![]() 1/19/2022 10:32 AM
|
---|
Obviously I would have to see your code to answer that. - Wout |
![]() 1/20/2022 9:18 AM
|
---|
I have this code at the moment and it works but makes all image sizes different C# Code: public static Bitmap ExportPNG(DxfModel model, string Filename, string suffix, bool SaveFile, string OutputFolder) { string folder = Path.Combine(OutputFolder, "PNG"); //@"C:\Temp\DXFProcess\PNG"; string newfilename = Path.GetFileNameWithoutExtension(Filename) + "_" + suffix + ".png"; string output = Path.Combine(folder, newfilename); if (Directory.Exists(folder) == false) Directory.CreateDirectory(folder); GraphicsConfig gc = new GraphicsConfig(); gc.NoOfArcLineSegments = 100; gc.BackColor = new WW.Drawing.ArgbColor(0, 0, 0, 0); gc.ApplyLineType = true; gc.DisplayLineWeight = true; Bitmap bitmap = ImageExporter.CreateAutoSizedBitmap(model, new GDIGraphics3D(gc), SmoothingMode.AntiAlias, Matrix4D.Identity, new Size(200, 200)); if (SaveFile) { using (Stream stream = File.Create(output)) { ImageExporter.EncodeImageToPng(bitmap, stream); } } return bitmap; } If i do the following it gives my a compiler error because it says that there is no overload on the method CreateBitmap with the passed parameters. i have a comment in this code with the moethod overload that should exist. C# Code: public static Bitmap ExportPNG(DxfModel model, string Filename, string suffix, bool SaveFile, string OutputFolder) { string folder = Path.Combine(OutputFolder, "PNG"); //@"C:\Temp\DXFProcess\PNG"; string newfilename = Path.GetFileNameWithoutExtension(Filename) + "_" + suffix + ".png"; string output = Path.Combine(folder, newfilename); if (Directory.Exists(folder) == false) Directory.CreateDirectory(folder); GraphicsConfig gc = new GraphicsConfig(); gc.NoOfArcLineSegments = 100; gc.BackColor = new WW.Drawing.ArgbColor(0, 0, 0, 0); gc.ApplyLineType = true; gc.DisplayLineWeight = true; //public static Bitmap CreateBitmap(DxfModel model, Matrix4D transform, GraphicsConfig graphicsConfig, SmoothingMode smoothingMode, int width, int height); Bitmap bitmap = ImageExporter.CreateBitmap(model, Matrix4D.Identity , new GDIGraphics3D(gc), SmoothingMode.AntiAlias,200, 200); if (SaveFile) { using (Stream stream = File.Create(output)) { ImageExporter.EncodeImageToPng(bitmap, stream); } } return bitmap; } |
![]() 1/20/2022 11:33 AM
|
---|
Try: C# Code: Bitmap bitmap = ImageExporter.CreateBitmap(model, Matrix4D.Identity, gc, SmoothingMode.AntiAlias, 200, 200); - Wout |
![]() 1/20/2022 12:04 PM
|
---|
That removes the compile error but now my images looks wrong. i have attache two before and after images. |
![]() 1/20/2022 2:47 PM
|
---|
You still have to provide the right Matrix4D to scale it to fit into the bitmap rectangle, similar to the example in the Examples\DxfExportExampleCS directory using method DxfUtil.GetScaleTransform. - Wout |