2010-05-06 107 views
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); 
} 

回答

0

MSDN提供了一个list of propertyitem ids in hexdecimal format及其相应的标签。

在你的榜样,20624(0x5090)是PropertyTagLuminanceTable和20625(0x5091)是PropertyTagChrominanceTable

编辑: 刚一说明,这些ID都没有访问图像本身,而是有关的元数据图像。

+0

我完全误解了propertyitem id的用途。我认为ID标识图像,我可以使用int propId检索它们。 谢谢。 – zaidwaqi 2010-05-06 07:07:04