2
我在Resources中有图像,并且想要获取它们的ID。 我从MSDN中找不到以下代码非常有帮助。在Windows窗体中获取属性ID
它是如何得到数字20624和20625?
如果我有用Properties.Resources.Image1
访问的图像,如何以编程方式获取其ID?
private void DemonstratePropertyItem(PaintEventArgs e)
{
// Create two images.
Image image1 = Image.FromFile("c:\\FakePhoto1.jpg");
Image image2 = Image.FromFile("c:\\FakePhoto2.jpg");
// Get a PropertyItem from image1.
PropertyItem propItem = image1.GetPropertyItem(20624);
// Change the ID of the PropertyItem.
propItem.Id = 20625;
// Set the PropertyItem for image2.
image2.SetPropertyItem(propItem);
// Draw the image.
e.Graphics.DrawImage(image2, 20.0F, 20.0F);
}
我完全误解了propertyitem id的用途。我认为ID标识图像,我可以使用int propId检索它们。 谢谢。 – zaidwaqi 2010-05-06 07:07:04