gpt4 book ai didi

c# - 使用嵌入的资源而不是文件名设置 ImageAnnoation 图像

转载 作者:行者123 更新时间:2023-12-02 01:20:41 25 4
gpt4 key购买 nike

我正在使用 DataVisualization 库中的图表控件,并且想要在图表上使用图像注释。问题是 ImageAnnotation.Image 属性是图像的路径,并且似乎没有可用于加载图像的公开 Bitmap 属性来自 Resources 对象,就像我对任何其他 .net 控件所做的那样。

无论如何,我是否忽略了使用嵌入式资源加载它,而不是从磁盘读取单独的文件?

最佳答案

我找到了答案。您需要将图像添加到父图表的 NamedImage 集合中。

private string imageName = "myImage";

//in constructor
NamedImage namedImage = new NamedImage(imageName, Properties.Resources.myImage);
mChart.Images.Add(namedImage);

//where creating the annotation
ImageAnnotation imageAnnotation = new ImageAnnotation();
imageAnnotation.Image = imageName;

关于c# - 使用嵌入的资源而不是文件名设置 ImageAnnoation 图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4970003/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com