Here is an excerpt from one of my plugin functions that does this,
ignore the extraneous code, but it will give you an idea:

static long buildRGBPicture (long imageWidth,long imageHeight, long
imageBitsPerSample,
                                                                        long 
redImageDataAddress, long grnImageDataAddress, long
bluImageDataAddress, long grayImageDataAddress,
                                                                        
REALmemoryBlock RGBlevelsNsatVals, long transferFnAddress,
long pseudocolorMap, REALpicture displayedPic)
{       register long                           xCtr, yCtr, n;
        unsigned char                           *transferFnPtr;
        register unsigned short         *redImageShortDataPtr,
*grnImageShortDataPtr, *bluImageShortDataPtr, *grayImageShortDataPtr;
        long                                            imagePixels, 
imageBytesPerSample;
        register long                           nShiftBits, 
sourceLineAddrOffset, imageDataLineOffset;
        REALpictureDescription          sourceDes = {0};        // Create a 
Picture Description
        PixMapHandle                            sourceMap;
        long                                            sourceWidth, 
sourceHeight, lineLen, j;
        long                                            *sourceData;    // base 
addr of pix data
        register long                           redSample, grnSample, 
bluSample, graySample, RGBmax,
satValue, redColor, grnColor, bluColor;
        register float                          redSatValue, grnSatValue, 
bluSatValue,
graySatValue, redFloorValue, grnFloorValue, bluFloorValue,
grayFloorValue;
        register float                          redLevel, grnLevel, bluLevel, 
grayLevel;
        long*                                           RGBlevelsNsatValsPtr;
        register float                          redSlope, grnSlope, bluSlope, 
graySlope;
        register unsigned char          *redTransferArray, *grnTransferArray,
*bluTransferArray, *grayTransferArray;  // now used to pre-computed
additional transfer fns for efficient sat pix, rather than evaluating
each pixel transfer individually
        register unsigned char          *pseudocolorLUTRed, *pseudocolorLUTGrn,
*pseudocolorLUTBlu;     // used to for new pseudocolor channel display


REALLockPictureDescription( displayedPic , &sourceDes );    // Lock the 
Description
sourceMap = GetGWorldPixMap( (GWorldPtr) sourceDes.pictureData);        //
Get the pixmap
// Get pixmap parameters
sourceWidth = sourceDes.width;
sourceHeight = sourceDes.height;
lineLen = GetPixRowBytes( sourceMap ) / 4;
// Lock the pixmap
if ( !LockPixels( sourceMap ) )
{       REALUnlockPictureDescription( displayedPic ); // lock failed: unlock
Description & return error
        return 3;
}
sourceData = (long*) GetPixBaseAddr( sourceMap );       // get the base addr
of pix data


sourceLineAddrOffset = 0;

imageShortDataPtr = (unsigned short *) imageDataAddress;

{       for (yCtr=0; yCtr<imageHeight; yCtr++)
        {       for (xCtr=0; xCtr<imageWidth; xCtr++)
                {       // get your redSample, grnSample, bluSample your own 
way, range 0..255
                        redSample = redTransferArray[*(imageShortDataPtr++)];
                        grnSample = grnTransferArray[*(imageShortDataPtr++)];
                        bluSample = bluTransferArray[*(imageShortDataPtr++)];

                        sourceData[sourceLineAddrOffset+xCtr] = (redSample << 
16) |
(grnSample << 8) | (bluSample);   // Intel needs to be byte-swapped, see
my recent post
                        
                }
                sourceLineAddrOffset += lineLen;        // an addition may be 
cheaper than
a mult as before
        }
                
}
                        
REALUnlockPictureDescription( displayedPic ); // unlock description
before returning


On 2/17/07, David Linker <[EMAIL PROTECTED]> wrote:
How do I load raw image data, say RGB pixels, into a picture without
doing it one pixel at a time.

I am working on a scanner front end for Mac OS X, and will be getting
the image data as pixels, which may be B/W, grayscale or color, and
the later as separate planes of color or interlaced.

The data will be read into a MemoryBlock, and it seems that there
should be a method for converting at least some of these formats
directly to what used to be a PixMap on Mac OS.

Any ideas?
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>



--
-------------------------------------------------------------------------------
Peter K. Stys, MD
Professor of Medicine(Neurology), Senior Scientist
Ottawa Health Research Institute, Div. of Neuroscience
Ottawa Hospital / University of Ottawa
Ontario, CANADA
tel:    (613)761-5444
fax:    (613)761-5330
http://www.ohri.ca/profiles/stys.asp
-------------------------------------------------------------------------------
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>

Reply via email to