getpixels() gets the correct value on xp and vista but is slightly off when used on windows 7
I have a C# program that works correctly on xp and vista but it needs to be used on windows 7, I have not been able to come up with a solution, it appears that getpixels just doesn't work right on windows 7.
I am getting one of the RGB values because I am dealing with tiff grayscale images.
System.Drawing.Bitmap image;// this is in a separate class
image = new Bitmap(destination);// this is in the constructor
Color t = image.GetPixel(j, i); // this is in a separate function
int s = t.R
when I print s, for example, image(0,0), it is supposed to be 220, it will be 221
I am doing edge detection on an image and I have to go through the image pixel by pixel, I have run the exact same program on XP,Vis开发者_JAVA技巧ta,windows7 and windows 7 got different values.
It wouldn't let me post images at all and only one link.
The first image is the original image, the second is the correct image, also the one I get with XP and Vista, the final image is the image when running the same program in Windows 7. There is not much of a visible difference but it matters for what I am doing.
If you mean Bitmap.GetPixel
, that method returns a Color
structure. I assume when you say it's "slightly off" that the RGB values of the returned color are slightly different than the value you're expecting.
This is probably due to your Windows 7 PC/image having a different color depth than your XP or Vista machines, or it may be that Windows 7 does something slightly different under the hood with .Net colors. This really shouldn't matter, except I suspect that your code is looking for a specific color value. It would help if you posted additional details.
Are you sure your program is really correct, according to the documentation? Bugs like this sometimes mean that you're accidentally relying on undefined behavior.
I just ended up using libtiff.net.
http://bitmiracle.com/libtiff/
精彩评论