Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Forth Mac > Bitwise ****ft ...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 5 Topic 60 of 160
Post > Topic >>

Bitwise ****ft in Forth?

by customimage@[EMAIL PROTECTED] (Erik Hentell) Apr 13, 2004 at 04:51 PM

Hi,

I'm going over some C code to see if I can rewrite some of it in Mops
(an exercise to learn how the language works).  Things were going well
until I came across this:

>for(w = 0; w < myRect.right; w++, myPixelPtr++){
>   UInt8 r, g, b, a;
>   long myPixel= *myPixelPtr;
>   if ((myPixel & 0x0ffffff) == 0x00ffffff) //pure white
>      continue;
>   a = (myPixel >> 24) & 0x0ff;
>   r = (myPixel >> 16) & 0x0ff;
>   g = (myPixel >> 8) & 0x0ff;
>   b = (myPixel >> 0) & 0x0ff;
>   if ((r > kThreshold) && (g > kThreshold) && (b > kThreshold) {
>      r = g = b = kThreshold;
>      *myPixelPtr = (a << 24) | (kThreshold << 16) | (kThreshold << 8)
>             | (kThreshold << 0);
>   }
>}

It's a for loop that is part of a function which runs through an image
and changes values depending on how close they are to white.  The "&"
and "|" are of course bitwise operators, which have their equivalents
as "and" and "or" in Mops.

The question I have is this: what is the Mops equivalent to "<<" and
">>"?  I haven't found anything on the web in general regarding Forth
and bitwise ****ft operators, and I'm not sure where to look in the
manual.  If someone could point me in the right direction, I'd
appreciate it.

Thanks,
Erik
 




 5 Posts in Topic:
Bitwise Shift in Forth?
customimage@[EMAIL PROTEC  2004-04-13 16:51:14 
Re: Bitwise Shift in Forth?
Doug Hoffman <dhoffman  2004-04-14 09:28:24 
Re: Bitwise Shift in Forth?
customimage@[EMAIL PROTEC  2004-04-14 10:42:53 
Re: Bitwise Shift in Forth?
Doug Hoffman <dhoffman  2004-04-15 09:08:57 
Mops Reference Techniques (was Re: Bitwise Shift in Forth?)
Doug Hoffman <dhoffman  2004-04-15 09:29:27 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Sat Aug 30 8:19:38 CDT 2008.