This is my code to draw 24bit bmp data

/*********************************************************************************
 * FUNCTION: DrawBMP24
 *
 * DESCRIPTION:
 *
 * PARAMETERS:
 *      recordP contains bmp data.
 *
 * RETURNED:
 *      True o False e imposta gBtLibRefNum

*********************************************************************************/

Boolean DrawBMP24(MemPtr recordP, UInt16 FWidth, UInt16 FHeight,
                                        Coord WhereX, Coord WhereY, Coord * X, Coord * 
Y)
{
        
        LocalID         localid = 0;
        UInt32          size    = 0;
        BitmapType      *bmpP;
        WinHandle       win,main;
        Err             error;
        RGBColorType prevColor, nowColor;
        Int16           y,x;
        UInt8 *         indiceP = (UInt8 *) recordP;
        
        typedef struct BMPHeaderStruct
        {
        UInt16  bfType;
            Int32       bfSize,
                        bfReserved,
                bfOffBits,
                biSize,
                biWidth,
                biHeight;
            UInt16      biPlanes,
                biBitCount;
            Int32       biCompression,
                biSizeImage,
                biXPelsPerMeter,
                biYPelsPerMeter,
                biClrUsed,
                biClrImportant;
        } BMPHeader;
        BMPHeader *BMPHeaderPtr;
        
        UInt8 ColoreLetto[3];
                
        


BMPHeaderPtr = MemPtrNew(sizeof(BMPHeader));



//LETTURA BITMAPFILEHEADER E BITMAPINFOHEADER
MemMove (BMPHeaderPtr, indiceP,54);
indiceP = indiceP+54;

BMPHeaderPtr->bfSize = InvertInt32(BMPHeaderPtr->bfSize);
BMPHeaderPtr->bfReserved = InvertInt32(BMPHeaderPtr->bfReserved);
BMPHeaderPtr->bfOffBits = InvertInt32(BMPHeaderPtr->bfOffBits);
BMPHeaderPtr->biSize = InvertInt32(BMPHeaderPtr->biSize);
BMPHeaderPtr->biWidth = InvertInt32(BMPHeaderPtr->biWidth);
BMPHeaderPtr->biHeight = InvertInt32(BMPHeaderPtr->biHeight);
BMPHeaderPtr->biPlanes = InvertUInt16(BMPHeaderPtr->biPlanes);
BMPHeaderPtr->biBitCount = InvertUInt16(BMPHeaderPtr->biBitCount);
BMPHeaderPtr->biCompression = InvertInt32(BMPHeaderPtr->biCompression);
BMPHeaderPtr->biSizeImage = InvertInt32(BMPHeaderPtr->biSizeImage);
BMPHeaderPtr->biXPelsPerMeter = InvertInt32(BMPHeaderPtr->biXPelsPerMeter);
BMPHeaderPtr->biYPelsPerMeter = InvertInt32(BMPHeaderPtr->biYPelsPerMeter);
BMPHeaderPtr->biClrUsed = InvertInt32(BMPHeaderPtr->biClrUsed);
BMPHeaderPtr->biClrImportant = InvertInt32(BMPHeaderPtr->biClrImportant);




// CONTROLLI DI FORMATO
if (BMPHeaderPtr->bfType != 'BM' || //non BMP
BMPHeaderPtr->bfReserved != 0 || //non BMP
BMPHeaderPtr->biPlanes !=1 || //non BMP
BMPHeaderPtr->biCompression != 0 || //il file � compresso
BMPHeaderPtr->biBitCount !=24 || //il file non � almeno a 16bit
(BMPHeaderPtr->biWidth != FWidth && FWidth!=0) || //dimensioni non corrette
(BMPHeaderPtr->biHeight != FHeight && FHeight!=0) ) //dimensioni non corrette

{
MemPtrFree(BMPHeaderPtr);
return false;
}
// FINE CONTROLLI DI FORMATO

bmpP = BmpCreate(BMPHeaderPtr->biWidth,BMPHeaderPtr->biHeight,16, NULL, &error);
if (bmpP && error == errNone)
{
win = WinCreateBitmapWindow(bmpP, &error);
if (win && error == errNone)
{

main = WinGetActiveWindow();
WinSetDrawWindow(win);
nowColor.index= 255;
WinSetForeColorRGB(NULL,&prevColor);
for(y=BMPHeaderPtr->biHeight; y >0; y--)
{
for(x = 1; x <= BMPHeaderPtr->biWidth; x++)
{
MemMove(&ColoreLetto,indiceP,3);
indiceP = indiceP+3;
nowColor.r = ColoreLetto[2];
nowColor.g = ColoreLetto[1];
nowColor.b = ColoreLetto[0];
WinSetForeColorRGB(&nowColor,NULL);
WinDrawPixel (x,y);
};
indiceP = indiceP + (BMPHeaderPtr->biWidth % 4);
};
WinSetForeColorRGB(&prevColor,NULL);
WinSetDrawWindow(main);
WinPaintBitmap(bmpP, WhereX,WhereY);
WinDeleteWindow(win,false);
}

}


        MemPtrFree(BMPHeaderPtr);
        *X = (Coord) BMPHeaderPtr->biWidth;
        return true;
}

SLO Revo News wrote:

I'm currently reading whole the bitmap data (in the form of void *) from palm memory, is that necessary to setup the color table first on palm? And how to convert the color table being stored on the source bitmap (Window) to the palm one?


Take a look at the PilRC source code for some clues.

Regards,
Steve Mann
-----
[EMAIL PROTECTED]
Available for Contract Work



--
For information on using the Palm Developer Forums, or to unsubscribe, please see 
http://www.palmos.com/dev/support/forums/

Reply via email to