Aspose.cad .net (23.7.0.0)dwg中插入图片怎么旋转图片角度。
图片旋转效果图:
1702956815981.png (4.4 KB)
我的插入图片的代码:
Bitmap image = new Bitmap(imagePath);
int iwidth = image.Width;
int iheight = image.Height;
double width = 0.0;
double height = 0.0;
if (imageBox == null)
{
width = image.Width;
height = image.Height;
if (width > iwidth / 10)
{
width = width / 10;
height = height / 10;
}
}
else
{
width = imageBox.MaxX - imageBox.MinX;
height = imageBox.MaxY - imageBox.MinY;
}
//预留20%的空白
width = width * 0.8;
height = height * 0.8;
string newObjectID = “FFFFFF”;
if (cadImage.Header.HeaderProperties.ContainsKey(CadHeaderAttribute.HANDSEED))
{
newObjectID = ((CadStringParameter)cadImage.Header.HeaderProperties[CadHeaderAttribute.HANDSEED][0]).Value;
int nextAvailableID = int.Parse(newObjectID, System.Globalization.NumberStyles.HexNumber) + 1;
((CadStringParameter)cadImage.Header.HeaderProperties[CadHeaderAttribute.HANDSEED][0]).Value = nextAvailableID.ToString(“X”);
}
CadRasterImageDef cadRasterImageDef = new CadRasterImageDef(imagePath, iwidth, iheight);
cadRasterImageDef.ObjectHandle = newObjectID;
Cad3DPoint insertionPoint = insertPoint.ToCad3DPoint();
double proportion = 0; //比例
if (width / iwidth < height / iheight)
{
proportion = width / iwidth;
}
else
{
proportion = height / iheight;
}
Cad3DPoint uVector = new Cad3DPoint(proportion, 0);
Cad3DPoint vVector = new Cad3DPoint(0, proportion);
CadRasterImage cadRasterImage = new CadRasterImage(cadRasterImageDef, insertionPoint, uVector, vVector);
cadRasterImage.ImageDefReference = newObjectID;
cadRasterImage.DisplayFlags = 7;
cadRasterImage.ClippingState = 0;
cadImage.BlockEntities[ModleSpaceHelper.GetModelSpaceName(cadImage)].AddEntity(cadRasterImage);
List list = new List(cadImage.Objects);
list.Add(cadRasterImageDef);
cadImage.Objects = list.ToArray();