Categories: MSDN / DotNet / Java / Scripts / Linux / PHP Ask - La ask - La Answer

Different image obtained using API and Pure VB method

Hi Guys,

I have a problem here...I am writing this program which creates a LUT, convert the grayscale image loaded in the picturebox into the pseudo color according to the LUT.

I am using 2 different rountines to convert:
1. API - GetPixel() and SetPixel()
2. Pure VB - Point() and PSet()

Since the LUT used is the same, upon conversion, I shld get 2 identical image right? But then, the thing is, I got 2 different pseudo color image. I noticed that certain black in the API converted image is blue in PureVB converted image. Why is this so? I have attached the project in this thread, can someone run it and explain why is this happening?

Thanks alot guys.

Regards,
Justin
[731 byte] By [ootnitsuj] at [2007-11-11 8:10:16]
# 1 Re: Different image obtained using API and Pure VB method
When building the LUT you have this:

For i = 64 To 127
oleColor(i) = 4 * (i - 192) * &H100 'green shade
Next

But this generates negative green values, you want:
oleColor(i) = 4 * (i - 64) * &H100

I suggest using the RGB function to generate the colours, it is much easier than multiplying by &H100 etc
zagarat at 2007-11-11 17:25:53 >
# 2 Re: Different image obtained using API and Pure VB method
Hi zagarat,

Thanks for your advice...but the thing is, why is it that the same LUT, even if it gives a -ve value between certain range of i, the 2 methods give 2 diff images? I thought that it shld be the same anyway??

Thanks for your time...

Justin
ootnitsuj at 2007-11-11 17:26:53 >