Hi, I've been looking at ReadPixel functions that can be found here:
http://www.blitzmax.com/Community/posts.php?topic=49893&hl=readpixel
I've found an odd problem though. The code works as it should with most images I load into it - it prints out the RGB value of each pixel and works great. However, if I load an image which is completely white with the first pixel (0,0) as black, it reports that its rgb value is 255,255,255 (white) instead of 0,0,0(black).
I've got a feeling this might be a compression issue - but I've set compression to 0. I'm using irfanview to save the png's BTW. Has anyone encountered this before?
Below is the code I am using. Thanks
http://www.blitzmax.com/Community/posts.php?topic=49893&hl=readpixel
I've found an odd problem though. The code works as it should with most images I load into it - it prints out the RGB value of each pixel and works great. However, if I load an image which is completely white with the first pixel (0,0) as black, it reports that its rgb value is 255,255,255 (white) instead of 0,0,0(black).
I've got a feeling this might be a compression issue - but I've set compression to 0. I'm using irfanview to save the png's BTW. Has anyone encountered this before?
Below is the code I am using. Thanks
Strict Graphics 800,600,0 Global spline:TImage=Null Global splineArray:pixel[] Global colour:Int Global alpha:Int,red:Int,green:Int,blue:Int Type pixel Field x:Int Field y:Int EndType spline=LoadImage("image.png") If not spline Then RuntimeError "Cannot find file." Local image:TPixmap image=LockImage(spline) Print "******************************************" For Local x=0 To spline.width-1 For Local y=0 To spline.Height-1 colour=ReadPixel(image,x,y) GetRGB(colour,alpha,red,green,blue) If red<255 Print "X: "+x+" Y: "+y+" Red:"+red+" Green: "+green+" Blue: "+blue WaitKey EndIf Next Next Function GetRGB(argb:Int,a Var,r Var, g Var, b Var) a=(argb Shr 24) & $ff r=(argb Shr 16) & $ff g=(argb Shr 8) & $ff b=argb & $ff End Function