/// <summary>
/// 获取部件的预览图
/// </summary>
/// <param name="part">部件对象</param>
/// <returns></returns>
public static Bitmap GetPreview(Part part)
{
part.GetPreviewImage(out int width, out int height, out int[] pixels);
if (width > 0 && height > 0)
{
Bitmap bm = new Bitmap(width, height);
for (int y = 0; y < height; y++)
{
for (int x = 0; x < width; x++)
{
int pixel = pixels[y * width + x];
Color col1 = Color.FromArgb(pixel);
Color col2 = Color.FromArgb(255, col1);
bm.SetPixel(x, y, col2);
}
}
return bm;
}
else
{
MessageBox.Show("Part has no valid preview", "Information");
return null;
}
}
NX二次开发 获取部件的预览图
最新推荐文章于 2024-01-30 22:00:00 发布