views:

37

answers:

1

Hi, I have images in Resources, and I'd like to get their ID. I dont find the following code from MSDN to be very helpful.

How did it get the number 20624 and 20625?

If I have image accessible with Properties.Resources.Image1 , how can I programmatically get its 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);
}
A: 

The MSDN provides a list of propertyitem ids in hexdecimal format and their corresponding tags.

In your example, 20624 (0x5090) is PropertyTagLuminanceTable and 20625(0x5091) is PropertyTagChrominanceTable

Edit: Just a note, those IDs are not to access the images themselves, but rather metadata about the image.

statenjason
I totally misunderstood what propertyitem ids are for. I thought the id identifies the image, and I can retrieve them using int propId.Thanks.
zaidwaqi