locked
How to check if picturebox contains image? RRS feed

  • Question

  • Basically I want to check to see if this picturebox contains this image.

    Here's my code:
    if (ptbDrag->Image::get() == System::Drawing::Image::FromFile("Images/Enemies/DragFireLeft.png"))
    	{
    		FireLeft = (XDragLeft - 13);
    		FireRight = (XDragLeft + 13);
    
    	}//endIf

    I can't seem to find another way of figuring this out.
    Any help please?
    Thanks
    Monday, June 15, 2009 4:08 AM

Answers

  • Hello,

    To compare two images, I think there isn't a easy way can be competent, "==" and Equals() just told us whether the references are the same.

    In my idea, we could override the Equals() method like:
    1. Use MemoryStream as the container.
    2. Compare the length of them.
    3. Compare every byte of them.

    It should handle all most of cases.

    Sincerely,
    Wesley
    Please mark the replies as answers if they help and unmark them if they provide no help. Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
    • Marked as answer by Wesley Yao Monday, June 22, 2009 2:46 AM
    Tuesday, June 16, 2009 10:03 AM

All replies

  • Anybody? This seems really simple... Does anybody know how to do it?
    Monday, June 15, 2009 6:18 AM
  • Hello,

    To compare two images, I think there isn't a easy way can be competent, "==" and Equals() just told us whether the references are the same.

    In my idea, we could override the Equals() method like:
    1. Use MemoryStream as the container.
    2. Compare the length of them.
    3. Compare every byte of them.

    It should handle all most of cases.

    Sincerely,
    Wesley
    Please mark the replies as answers if they help and unmark them if they provide no help. Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
    • Marked as answer by Wesley Yao Monday, June 22, 2009 2:46 AM
    Tuesday, June 16, 2009 10:03 AM