|
Image.Equals does a reference comparison and it will always return false since they may be pointing to two different Image objects in memory, even if you loaded them from the same file.
You can achieve this behavior by setting a flag during the loading of these images into the picture boxes by checking if they are loaded from the same file.
|
|
|
|
|
Oh, i forgot to say that the images that the two pictureBox get came from an imagelist.
|
|
|
|
|
The problem is that the PictureBox.Equals method[^] is inherited from object, and is a reference test (as PictureBox is a reference object). What that means in English is that Equals compares the references (in C or C++ that would be a pointer) rather than comparing them bit - by - bit. If the pointers are to different ememory, then the Equals test will return false even if the two images are bitwise identical. You will have to do a bitwise comparison to check they are realy different.
No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced.
This message is made of fully recyclable Zeros and Ones
"Rumour has it that if you play Microsoft CDs backwards you will hear Satanic messages.Worse still, is that if you play them forwards they will install Windows"
|
|
|
|
|
How can i do the bitwise comparison if the images i get came from an imageList?
|
|
|
|
|
The same way as if they came from anywhere else
|
|
|
|
|
As Harold says, same way as anything else: iterate through the bytes of the image and compare! Won't be quick though!
The MD5 suggestion is not bad - it should be quick, and it will identify non-identical pictures. It could however give false positives. If this is a game, then I assume you have a limited number of different pictures? Take the MD5 hash of each of them and modify the pictures to ensure they all have different MD5 hashes. Then use the MD5 to identify whether the picture is the same, or not. Moves the processing work to offline, so it doesn't become noticable at run time.
No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced.
This message is made of fully recyclable Zeros and Ones
"Rumour has it that if you play Microsoft CDs backwards you will hear Satanic messages.Worse still, is that if you play them forwards they will install Windows"
|
|
|
|
|
I used a code that uses memorystream so i can save the image to a specific location then convert it to base64String and use that location to compare the two images. I think it does the work i want so i think i'm okay with that. I'll just use the md5 hash code as a backup in case something goes wrong..anyway thanks for the suggestions
|
|
|
|
|
If you already have the image as a MemoryStream, then why go to all that bother? Isn't it simpler to use
byte[] bytes = ms.GetBuffer(); and then compare the two buffers directly?
No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced.
This message is made of fully recyclable Zeros and Ones
"Rumour has it that if you play Microsoft CDs backwards you will hear Satanic messages.Worse still, is that if you play them forwards they will install Windows"
|
|
|
|
|
Does the MD5 Hash Code Work for you ?
MD5 is embedded in C# .NET
try to get hash for the two images
I know nothing , I know nothing ...
|
|
|
|
|
I have made extensive use of generics in some areas of my reusable framework. However using some of the types in the framework can be troublesome to type. For instance.
NodeHeap<Node<SimplePathFinder<TTileMap, TTile, TData>, TTileMap, TTile, TData>,
SimplePathFinder<TTileMap, TTile, TData>, TTileMap, TTile, TData>
openList = new NodeHeap<Node<SimplePathFinder<TTileMap, TTile, TData>, TTileMap, TTile, TData>,
SimplePathFinder<TTileMap, TTile, TData>, TTileMap, TTile, TData>();
I find that to be very bothersome and troublesome. This wouldn't be so much of a problem if I could use #define like I could in C++.
Has anyone else experienced problems like this? Is there anyway I can hide or compact all of that nonsense?
|
|
|
|
|
If your classes are not sealed, you can create a derived class that points to the most used case.
For example:
public sealed class List:
List<object>
{
}
(the List<T> must not be sealed, the new class can be sealed).
Or, at the unit where you must use the type a lot, you can create a using.
For example:
using MyClass = System.Collections.Generic.List<string>
The main problem with this case is that when you declare a using clause you must always use the full path of every type.
|
|
|
|
|
Excellent. I just create a private nested class for each of the super generic types. It will be relieving to encapsulate all of that craziness.
Never mind, I can't do that. This is enough to make me switch to C++ permanently.
modified on Wednesday, November 25, 2009 3:15 PM
|
|
|
|
|
How about:
public class MyComplexList: NodeHeap<Node<SimplePathFinder<TTileMap, TTile, TData>, TTileMap, TTile, TData>,
SimplePathFinder<TTileMap, TTile, TData>, TTileMap, TTile, TData>
{
};
MyComplexList openList = new MyComplexList();
|
|
|
|
|
I was about to do that, until I realized that it wouldn't work the way I intend because many methods take arguments that require the complex generic types. They are all intertwined.
Its a complex situation with no solution other than to suck it up. I'm very disappointed.
|
|
|
|
|
Make an alias with a using directive?
CaptainSeeSharp wrote: use #define like I could in C
Yeah, you could do that; I pass my C# through C pre-processor (just because I can).
|
|
|
|
|
PIEBALDconsult wrote: I pass my C# through C pre-processor (just because I can).
Are you a Linux user?
Greetings - Jacek
|
|
|
|
|
|
A little insight into the classes would let me be more sure, but I'm guessing that you have more generic parameters than you need. Also, this is a great place to use var
I would guess that you could declare the classes something like this:
class Node<TTileMap, TTile, TData>
{
private SimplePathFinder<TTileMap, TTile, TData> finder;
private TTileMap map;
private TTile tile;
private TData data;
}
class NodeHeap<TTileMap, TTile, TData>
{
private Node<TTileMap, TTile, TData> _nodes[];
}
var opelList = new NodeHeap<TTileMap, TTile, TData>();
|
|
|
|
|
Here is a quick glimpse...
public class SimplePathFinder<TTileMap, TTile, TData>
where TTileMap : TileMap<TTile, TData>
where TTile : Tile<TData>, new()
where TData : struct
{
#region Fields
private Dictionary<TData, byte> m_resistanceDict;
private byte[] m_resistanceMap;
private Node<SimplePathFinder<TTileMap, TTile, TData>, TTileMap, TTile, TData>[] m_openListRegestry;
private TTileMap m_workingMap;
private Node<SimplePathFinder<TTileMap, TTile, TData>, TTileMap, TTile, TData> m_startNode, m_endNode;
private bool _allowDiaginals;
private bool _updated;
private Coordinate[] _currPath;
private uint _currPathIndex;
...
public class Node<TAStarAlg, TTileMap, TTile, TData> : IEquatable<Node<TAStarAlg, TTileMap, TTile, TData>>, IComparable<Node<TAStarAlg, TTileMap, TTile, TData>>
where TAStarAlg : SimplePathFinder<TTileMap, TTile, TData>
where TTileMap : TileMap<TTile, TData>
where TTile : Tile<TData>, new()
where TData : struct
{
.....
public static bool operator ==(Node<TAStarAlg, TTileMap, TTile, TData> a, Node<TAStarAlg, TTileMap, TTile, TData> b)
{
return Object.Equals(a, b);
}
....
public class NodeHeap<TNode, TAStarAlg, TTileMap, TTile, TData>
where TNode : Node<TAStarAlg, TTileMap, TTile, TData>
where TAStarAlg : SimplePathFinder<TTileMap, TTile, TData>
where TTileMap : TileMap<TTile, TData>
where TTile : Tile<TData>, new()
where TData : struct
{
#region "Fields"
private Node<TAStarAlg, TTileMap, TTile, TData>[] m_nodeHeap;
private uint m_lastNodeIndex;
#endregion
.....
|
|
|
|
|
Hello,
I want to learn how a windows is drawn by the system. The reason for doing this is that I want to create a whole interface my self. I want to change the window's frame, close button etc. Hope you guys are understanding me . Can anyone point me to a tutorial on how i can do this please?
|
|
|
|
|
A tutorial? A really don't know.
But there are many things to understand.
First, if you want to draw the window interface yourself but will still use windows from the operating system, simple create a borderless window, and draw everything you need in it.
Second, if you want to create a full "window support" yourself, you will need to understand how to create and group regions. But by the type of the question I think you only need the first one.
|
|
|
|
|
So in the first one what you mean is that i draw the titlebar close button etc with GDI?
|
|
|
|
|
Yes... you can even create your own controls that look and behave like the title-bar.
|
|
|
|
|
Hi,
I am looking for some help in integrating my UI designer with Visual Studio. The idea is silmiar to VS Class designer or Entity designer.
1. when the file is select, the designer is open.
2. it updates the file when the visual elements are changed.
3. it generates source code file. One visual elements represents one class. When the visual elements change, the source code also change accordingly. for example, the element is renamed, then the class name is changed and all reference are changed automatically like renaming a class in Visual Studio.
Any information is appreciated.
Thanks
Carey
|
|
|
|
|
Hi, instead u can create ur own designer that will accept name and type and location, those u can save to XML,DB. and afterwords u can draw the form at runtime as u want. even u can change the design of form at runtime via refreshing the XML or DB.
Avinash S. Godse
|
|
|
|
|