插入 Catia V5 CATDrawing 时,保存的 png 图像会丢失透明度

问题描述

在插入 Catia V5 CATDrawing 文档时,.png 图像的透明度有问题。使用 System.Drawing.Image.Save() 保存后,图像发生了一些变化。如果用 Paint.NET 打开一个新保存的图像,图像是透明的,一切看起来都很好,但是当插入到 CATDrawing 图像中时,图像没有透明度。我无法找出图像中导致这种透明度损失的更改。 我正在旋转图像,这就是我需要保存它的原因。这是我用来旋转和保存图像的代码

    Bitmap image1 = (Bitmap)Image.FromFile(sImagePath1,true);
    image1.RotateFlip(RotateFlipType.Rotate90FlipNone);
    image1.MakeTransparent();
    image1.Save(sImagePath2,ImageFormat.Png);

我也尝试过使用 NuGet 包 magick.net-Q16-Anycpu 失败

    using (MagickImage mimg = new(sImagePath1))
    {
        mimg.Rotate(90);
        mimg.Write(sImagePath2);
    } 

并带有另存为流

    Bitmap image1 = (Bitmap)Image.FromFile(sImagePath1,true);
    image1.RotateFlip(RotateFlipType.Rotate90FlipNone);
    using (FileStream outputFileStream = new(sImagePath2,FileMode.Create))
    {
        var stream = new MemoryStream();
        image1.Save(stream,ImageFormat.Png);
        stream.Position = 0;
        stream.copyTo(outputFileStream);
    }

问题:是否有其他解决方案可以通过 C# 代码旋转和保存图像?

解决方法

您好,恐怕 Catia V5 无法导入具有透明度的 png。如果手动将图像放入绘图保持透明度,请自行尝试。我试过了,但在我的情况下它不起作用。

在 Catia 中,您可以手动旋转图片,但不能通过 api。

您可以尝试矢量图像而不是位图,但这只是我的猜测。

enter image description here enter image description here