tags:

views:

126

answers:

3

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,Vista,windows7 and windows 7 got different values.

It wouldn't let me post images at all and only one link.

http://img96.imageshack.us/img96/1559/mandrilly.png

img696.imageshack.us/img696/2844/newmany.png

img185.imageshack.us/img185/6124/edmandrilly.png

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.

Thanks for the help, it seems that I am having a hard time explaining my problem.

A: 

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.

David Seiler
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,Vista,windows7 and windows 7 got different values.System.Drawing.Bitmap image = new Bitmap(destination);...Color t = image.GetPixel(j, i);int s = t.R;// I am doing a grey scale image so i just get one valuethe above returns the different values for windows 7.
+1  A: 

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.

MusiGenesis
Yes I mean Bitmap.Getpixel. I am getting one of the RGB values because I am dealing with tiff grayscale images.Color t = image.GetPixel(j, i); int s = t.Rwhen I print s, for example, image(0,0), it is supposed to be 220, it will be 221
If you could post a simple code sample that shows exactly how you're loading the file into a Bitmap, and also the actual TIFF file that is causing the "problem", I'm sure that would help. What's probably happening is that the Windows 7 machine is using a different codec to uncompress the TIFF into a regular bitmap, resulting in slightly different pixel values. You could probably avoid this problem by using BMP files instead of TIFF files, but that may not be practical for your application.
MusiGenesis
System.Drawing.Bitmap image;
image = new Bitmap(destination);
A: 

I just ended up using libtiff.net.

http://bitmiracle.com/libtiff/