Hi!
Eine Frage: Wie genau funzt das mit Getpixel? Ich möchte einen RGB - Farbwert fix auslesen, aber so ganz steige ich noch nicht dahinter! Vor allem bräuchte ich den Farbwert aufgeteilt in R/G/B!!!
glg
W.
Getpixel delivers a number that is built from three bytes put together. You need to split it in three parts.
If we see this as hexadecimal it gets easier to see how it's connected:
RR GG BB = RRGGBB
Each letter is half a byte, 4 bits. To get one part, just do this:
blue = bAND(color, 0x0000FF) // to get the blue component we remove all other information except the first eight bit (0xFF hex)
green = bAND(color, 0x00FF00) // The green component is shifted eight bits (one byte)
green = green / 0xFF // We divide with 256 (FF hexadecimal) to get it to move back to the lower area and give us a number between 0 and 255
red = bAND(color, 0xFF0000)
red = red / 0xFF
red = red / 0xFF // We need to do it twice for red since it's even higher up. We could also divide with 0xFFFF
This will give you the separate color components if I wasn't thinking wrong somewhere now.
NO! it's BGR, not RGB (little endian).
See here:
http://www.glbasic.com/forum/index.php?topic=1529.0 (http://www.glbasic.com/forum/index.php?topic=1529.0)
Aw, I knew there was something stupid on intel
thx!!! That's really great!
Just making a note for you wpshadow,
since getpixel is so weak in the sense of accuracy.
An easy way to use it, is by detecting non-black colors.
Something like:
if getpixel()>rgb(0,0,0) then a color is detected.
i think the variation of getpixel has to do with the bit of the command, i think it is reading 256 colors.
but i could be wrong here, tho i have been using that command a lot, as you can see:
http://www.glbasic.com/forum/index.php?topic=2417.0 (http://www.glbasic.com/forum/index.php?topic=2417.0)
For the moment I'm working with "themes", but I want give the player a chance to make his own "theme".
Like the red one! I need the colors from this *.PNGs to write them into the DB. That's the idea!
[attachment deleted by admin]
This is a piece from my 3d font object creator.
Use the image below with this image
loadsprite "colorpicker420.png",0
TheColor:
IF init_color=FALSE; init_color=TRUE
LOCAL mx,my,mb1,mb2
CPColor=RGB(255,255,255)
ENDIF
DRAWSPRITE 0,0,0 // draw pick color image
//grab a color
MOUSESTATE mx,my,mb1,mb2
IF mb1
CPColor=GETPIXEL(mx-1,my-1)
ENDIF
//show color selected box
DRAWRECT 500,100,100,100,RGB(255,255,255)
DRAWRECT 504,104,92,92,RGB(0,0,0)
DRAWRECT 504,104,92,92,CPColor
SHOWSCREEN
GOTO TheColor
[attachment deleted by admin]
So, erstens :
HIER ist das Deutsche Forum, hier wird Deutsch geschrieben!
(Hemlos soll sich lieber um die englische Abteilung kümmern)
zweitens:
Getpixel ist einfach zu langsam sowas zu machen, da wirst du keine Freude dran haben !
Schau lieber das du die Sachen die änderbar sein sollen mit verscheidenen Farben hinterlegen kannst.
Sprich:
Du benutzt ja eh PNG's also kannst du die Alphatransparentz ja nutzen und das was nicht veränderbar sein soll so zeichen und alles was ne andere Farbe bekommen soll einfach hinter das PNG setzen!
So schaut es immer duch das PNG durch, und ist um ein 100-Faches schneller als GetPixel
Die codesnip oben ist nicht langsam. : P
ENGLISH:
Hemlos sorry, but that translationtool is realy bad! :puke:
Please write him a PM or something. Some of us can not spreak english as well, so they dont understand what you are posting, if they have the same problem!
WPShadow can post your solution, if its work.
###################################################
DEUTSCH:
Entschuldigung Hemlos, aber der Übersetzer ist echt schelcht! :puke:
Bitte schreibe ihn eine PM oder sowas. Manche von uns können nicht so gut englisch, so das sie nicht verstehen was du schreibst, wenn sie das selbe Problem haben!
WPShadow kann die lösung dann posten, wenn es geht.
Si senior, mi casa est su casa. PM a solution code when i can just post it? We all speak glbasic here dont we?
http://www.glbasic.com/forum/index.php?topic=2448.0 (http://www.glbasic.com/forum/index.php?topic=2448.0)