Well, considering that you not only have to have to find the base address of the pixmap, but you also have to take into account how the grafport's rectangle may be offset within the pixmap rectangle, _and_ take into account whether each pixel is 1, 2, 4, 8, 16 or 24 bits wide, _and_, if pixel values are indexed, take into account how the RGB color you want is mapped to the index values...
...then the most efficient _general_ way to do it, I would think, would be just to call SETCPIXEL. _If_ you can make certain fixed assumptions about the above issues, then you can probably write a custom algorithm that's more efficient.
If you are working with a 32 bit grafport you can do it like this. I have never worked other bit depths but this may give you a starting point with those also.
First make a 32 bit gWorld (note the 32 in the NEWGWORLD fn).
CALL SETRECT(rect, 0, 0, Wd, Ht))
QDErr = FN NEWGWORLD(theWorld&,32,#@rect.top,0,0,0)
Then get the pixel map address like this:
colorMapHand& = FN GETGWORLDPIXMAP(colorWorld&)
locked = FN LOCKPIXELS(colorMapHand&)
Then you can poke values directly into the pixels like this:
remainderOfDivide = Wd MOD 4
FOR y=0 TO Ht-1 'do coloring
FOR x=0 TO Wd-1
wdNum=Wd+4-remainderOfDivide 'Need to add 4-remainderOfDivide to Wd to make it work
'get color values somehow
POKE adr1&+1, rCol
POKE adr1&+2, gCol
POKE adr1&+3, bCol
CALL UNLOCKPIXELS(colorMapHand&) 'unlock when done
A few notes:
The width of the 32 bit gWorld in pixels is evenly divideable by four even if the width of the rect that you use to create it is not.
Each pixel is represented by four bytes even though only 3 bytes are actualy used to display color.
If you have an 6 byte rgb record that stores the color value that you want to poke into your gWorld (DIM PixColor.rgbColor), then you can get the color to poke into the gWorld from it like this:
bCol=PEEK (@PixColor.blue%)(You only need the high byte from each of the colors.)