Question: Why is the Bitmap scrambled on Palm OS 5.1 when loading it from the memory after using MemMove?



I am developing an application where I need to save a Bitmap which the user has drawn. For this I am using to following Codefragment:

void SaveLayoutRecord(UInt save)
{
       BitmapType* bmp;
       MemHandle t;
       MemPtr winPtr, ptr;
       RectangleType theBoundsPtr;

       UInt16          theIndex = 0;
       MemHandle       theRecHandle;
       BitmapPtr       theRecPtr;
       ULong           theSize;

       theBoundsPtr.topLeft.x = 0;
       theBoundsPtr.topLeft.y = 11;
       theBoundsPtr.extent.x = 160;
       theBoundsPtr.extent.y = 160;

       if((save == 0) || (save == 1))
       {
               if (DmNumRecords( layoutDBRef ) > 0)
                       DmRemoveRecord( layoutDBRef, theIndex );

               t = MemHandleNew(3220);
               if (!t) return;
               ptr=MemHandleLock(t);

WinCopyRectangle(NULL, winBufferH, &theBoundsPtr, 0, 0, winPaint);
bmp = WinGetBitmap(winBufferH);
BmpGetBits(bmp);
winPtr = bmp;


MemMove(ptr, winPtr, 3200); //Achtung!!! Der Fehler liegt bei dieser Zeile

               if (ptr != NULL)
               {
                       // Create a record from our bitmap
                       theSize = MemPtrSize( ptr );
                       theRecHandle = DmNewHandle( layoutDBRef, theSize );
                       if (!theRecHandle)
                               return;

                       // Copy the bitmap data into the new record
                       theRecPtr = MemHandleLock( theRecHandle );
                       DmWrite( theRecPtr, 0, ptr, theSize );
                       MemHandleUnlock( theRecHandle );


// Now, attach the new record to the database
DmAttachRecord( layoutDBRef, &theIndex, theRecHandle, NULL );
}
MemHandleUnlock(t);
}
}


When I run the Application on Palm OS 4.1 evrything works fine. However, when I run the Application on my Tungsten with Palm OS 5.1, the Bitmap is scrambled when loaded. Why does the function MemMove() not work properly for OS5.1. what do I hav to do?

_________________________________________________________________
Tired of spam? Get advanced junk mail protection with MSN 8. http://join.msn.com/?page=features/junkmail



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

Reply via email to