Why isn't this working?
Blitz3D Forums/Blitz3D Beginners Area/Why isn't this working?
| ||
This should turn every pixel with a green value between 44 and 250 to 0,255,0. However, when i check it with my paint program it has missed some pixels that fall within that range I set. ?? For x=0 To ImageWidth(Image60) For y=0 To ImageHeight(Image60) GetColor x,y If ColorGreen()>44 And ColorGreen()<250 Then Color 0,255,0 Plot x,y EndIf Next Next |
| ||
Actualy this isn't changing any pixels. I just compared the result with the original. hmm |
| ||
For goodness sakes. I need to Grabimage so i can save the results. LOL. |
| ||
Are you grabbing AND setting values from the image's buffer?SetBuffer ImageBuffer(Image60) For X = 0 to ImageWidth(Image60)-1 ;Pixel coordinates are zero-based, so that's why the "-1". For Y = 0 To ImageHeight(Image60)-1 GetColor X,Y If ColorGreen() > 44 And ColorGreen() < 250 Then Color 0,255,0 Plot X,Y EndIf Next NextSee if this works. (make sure to use the CODE tags to preserve indentation). |
| ||
and a faster way of doing this using the information suppliedlockbuffer imagebuffer(image60) for x = 0 to imagewidth(image60) - 1 for y = 0 to imageheight(image60) - 1 rgb=readpixelfast(x,y,imagebuffer(image60)) green = (rgb shr 8) and 255 if green > 44 and green < 250 then red = (rgb shr 16) and 255 blue = (rgb and 255) writepixelfast(x,y,(red shl 16) or (255 shl 8) or blue,imagebuffer(image60) endif next next unlockbuffer imagebuffer(image60) |
| ||
Thanks for the input guys. All is well. |