For classes such as IMAGE, the value of group code 91, which indicates the instance count, appears to become 0 in version 3.6.35 even though instances actually exist.
It works correctly in version 3.4.9.
As a result, images sometimes fail to display correctly in DWG TrueView.
using System;
using System.IO;
using ACadSharp;
using ACadSharp.IO;
using ACadSharp.Entities;
using ACadSharp.Objects;
using CSMath;
public static class B
{
public static void Run(string outDxf)
{
// 画像のピクセルサイズを取得
var bytes = File.ReadAllBytes(@"C:\test\acadsharp_image_bug\sample.png");
int pw = (bytes[16] << 24) | (bytes[17] << 16) | (bytes[18] << 8) | bytes[19];
int ph = (bytes[20] << 24) | (bytes[21] << 16) | (bytes[22] << 8) | bytes[23];
var doc = new CadDocument(ACadVersion.AC1032);
var def = new ImageDefinition
{
FileName = "sample.png",
Name = Guid.NewGuid().ToString(),
IsLoaded = true,
Size = new XY(pw, ph),
};
var img = new RasterImage(def)
{
InsertPoint = new XYZ(0, 0, 0),
UVector = new XYZ(1, 0, 0),
VVector = new XYZ(0, 1, 0),
Size = new XY(pw, ph),
Flags = ImageDisplayFlags.ShowImage,
ClipType = ClipType.Rectangular,
ClippingState = false,
};
img.ClipBoundaryVertices.Add(new XY(-0.5, -0.5));
img.ClipBoundaryVertices.Add(new XY(pw - 0.5, ph - 0.5));
doc.ModelSpace.Entities.Add(img);
using (var w = new DxfWriter(outDxf, doc, false)) w.Write();
Console.WriteLine("wrote " + outDxf);
}
public static void Main()
{
Run(@"C:\test\acadsharp_image_bug\image.dxf");
}
}
For classes such as IMAGE, the value of group code 91, which indicates the instance count, appears to become 0 in version 3.6.35 even though instances actually exist.
It works correctly in version 3.4.9.
As a result, images sometimes fail to display correctly in DWG TrueView.
image_bug.zip