ArianeSoft - Programming and development for Windows and Windows Mobile :: Forums :: PPL - Pocket Programming Language :: Support |
|
<< Previous thread | Next thread >> |
specific color |
Moderators: kornalius, bmanske, PointOfLight
|
Author | Post | ||
Nicknack |
| ||
Registered Member #132 Joined: Wed Nov 01 2006, 10:50amPosts: 99 | how can i get a specific color value from a pixel? for example i read the rgb-values at 10,10, increase the red value about 100 and then draw a pixel with this new red value at that position. | ||
Back to top | | ||
zehlein |
| ||
Registered Member #30 Joined: Tue Sep 12 2006, 03:00pmPosts: 449 | g_GetPixel() is your friend. There is a crack, a crack in everything. That's how the light gets in. (L. Cohen) | ||
Back to top | | ||
Nicknack |
| ||
Registered Member #132 Joined: Wed Nov 01 2006, 10:50amPosts: 99 | i don't want to draw the same color i get with g_rgb, i want to read the color, change one of its values (red,green or blue) and then draw the new color example: 1. i read the pixel at 10,10 and get the values red=0, blue=50 and green=100 2. now i increase blue about 100 ( blue = 150) 3. i set the pixel g_rgb(red,green,blue) 4.the pixel has the values red=0, blue=150 and green=100 my problem is that g_rgb mix the the three values up into one long value, so i can't change the three values separately. | ||
Back to top | | ||
Mike Halliday |
| ||
Registered Member #671 Joined: Tue Sep 25 2007, 12:22pmPosts: 400 | Hi NickNack You can use this formula; G_SetPixel(100, 100, g_rgb(255,255, 255)); lColor$ = g_GetPixel(100, 100); iRed$ = lColor$ Mod 256; iGreen$ = (lColor$ / 256) Mod 256; iBlue$ = (lColor$ / 256 / 256) Mod 256; Unfortunately it looks like there is a bug in G_GetPixel as it is only returning 65535 instead of 16777215 - thus the blue value is always 0. Alain, can you confirm that this is a bug or am I missing something here? My calculations show that 256 * 256 * 256 is 16777215. I have checked this on a VB site and their code does the same as mine but the VB getpixel returns 16777215 :S Confused now. Editor of \'Voice of the PPL\' the newsletter for the PPL by the PPL! Still trying to get people to contribute to the newsletter! | ||
Back to top | | ||
PointOfLight |
| ||
Registered Member #49 Joined: Sun Sep 17 2006, 03:02pmPosts: 1129 | Actually, it's not G_GETPIXEL that's incorrect, it's G_RGB. If I do this: color$ = G_RGB(100, 200, 50); r$ = color$ mod 256; g$ = (color$ / 256) mod 256; b$ = (color$ / 256 / 256) mod 256; I get: r$ = 70, g$ = 102, b$ = 0 However, if I do: color$ = RGB(100, 200, 50); r$ = color$ mod 256; g$ = (color$ / 256) mod 256; b$ = (color$ / 256 / 256) mod 256; Then r$ = 100, g$ = 200, b$ = 100 I'm not sure why there's two RGB functions, and sadly I appear to have not documented RGB, but it looks like G_RGB is the true culprit. Eric Pankoke Founder Point Of Light Software http://www.polsoftware.com/ | ||
Back to top | | ||
Mike Halliday |
| ||
Registered Member #671 Joined: Tue Sep 25 2007, 12:22pmPosts: 400 | I still think there is an issue with G_Getpixel Heres why; G_SetPixel(100,100,rgb(255,255,255)) - Sets pixel at 100x100 to white result$ = G_GetPixel(100,100) The long value returned is 65535 (this is yellow) result = RGB(255,255,255) The long value returned is 16777215 Looks like G_GetPixel is only returning an unsigned 16 bit number instead of an unsigned 24 bit number. (65535 vs 16777215) Editor of \'Voice of the PPL\' the newsletter for the PPL by the PPL! Still trying to get people to contribute to the newsletter! | ||
Back to top | | ||
PointOfLight |
| ||
Registered Member #49 Joined: Sun Sep 17 2006, 03:02pmPosts: 1129 | Actually, now that I think about it I probably stopped testing after I discovered that G_RGB wasn't working, so I actually wouldn't have noticed that g_getpixel also wasn't working. My bad. At least g_setpixel works right Eric Pankoke Founder Point Of Light Software http://www.polsoftware.com/ | ||
Back to top | | ||
Mike Halliday |
| ||
Registered Member #671 Joined: Tue Sep 25 2007, 12:22pmPosts: 400 | yeah, set pixel works fine Editor of \'Voice of the PPL\' the newsletter for the PPL by the PPL! Still trying to get people to contribute to the newsletter! | ||
Back to top | | ||