Erik Hentell
2004-04-13 23:51:14 UTC
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
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 shift 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
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
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 imageUInt8 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);
}
}
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 shift 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