I am trying to grab pixels from an offscreen pixmap, and work on them, then set them back in 16 and /or 24 bit color if necessary. (Using a suggested way courtesy MarsSaxman...thanks Mars)
Two main problems:
1. Just grabbing the pixels as a test, setting them to RGB bits as below, then converting them back and resetting the pixel back to its same self, works fine on one computer, but not my other one. The colors go crazy on the 603e Umax, works fine on a PPC 601 upgrade on a Quadra 630. Both running OS 8.1 Becomes a multibanded and hued square.
2. When it is working, I would like to be able to work on the individual RGB channels using integer math, but I don't think they are in the proper format as is. Since RGB channels are in 0-65535 value wise typically (are they not?) how can red5bits% be an integer variable versus a long integer, rgb5Bits&. Am I missing something here?
Is there another conversion to be made? The one to destColor doesn't seem to help in this regard, if I go that extra step, then convert all back to MyPixelM%, there is a slight hue change too. Maybe PRINT is not showing the real values when I use that within the loop to output to an info window.
Anyone have any suggestions, fixes or FN's that do what I want to do that they could share?
Robert Covington
<snip>
targetPixMap& = FN GETGWORLDPIXMAP(offPort&)
locked = FN LOCKPIXELS(targetPixMap&)
LONG IF locked
pixArrayBase& = targetPixMap&..baseAddr&
pixRowWidth% = targetPixMap&..rowBytes% AND &3FFF
FOR y=0 TO 200
FOR x=0 TO 200
myPixelM% = {pixArrayBase& + (y% * pixRowWidth%) + (x% * 2)}
red5bits% = (myPixelM% >> 10) AND &001F
green5bits% = (myPixelM% >> 5) AND &001F
blue5bits% = myPixelM% AND &001F
'destColor.red% = red5bits% << 11 OR red5bits% << 6 OR red5bits% << 'to work in RGB record style
'destColor.green% = green5bits% << 11 OR green5bits% << 6 OR green5bits% << 1
'destColor.blue% = blue5bits% << 11 OR blue5bits% << 6 OR blue5bits% << 1
'myPixelM% = (destColor.red% >> 1) AND &7C00 'other method
'myPixelM% = myPixelM% OR ((destColor.green% >> 6) AND &03E0)
'myPixelM% = myPixelM% OR ((destColor.blue% >> 11) AND &001F)
myPixelM% = red5bits% << 10 'comment out for above conversion.
myPixelM% = myPixelM% OR green5bits% << 5
myPixelM% = myPixelM% OR blue5bits%
'SET IT BACK
% pixArrayBase& + (y% * pixRowWidth%) + (x% * 2), myPixelM%
NEXT x
IF LEN(INKEY$) THEN STOP ' Enable Program Stopping, otherwise grow old and die waiting.
NEXT y
'Set it back
CALL COPYBITS(#offPort&+2,#wndPort&+2,rect,rect,_srcCopy,0)
CALL UNLOCKPIXELS(FN GETGWORLDPIXMAP(offPort&))
END IF
<snip>