BPPBMAP.TXT - Directly Accessing Memory Bitmaps with Borland PowerPack Q: I am using Borland PowerPack and trying to access a local memory grafMaps mapTable and rowTables directly so that I can fool around with the bitmaps pixels myself. When I try to do this I get an exception. What's going on? This worked in real-mode. A: Ok, this is a bit complicated. When running under PowerPack, our code executes in a different address space than your program does. We use a data segment that encompasses your data address space, as well as the graphics adapters bitmap address space. When you allocate raster lines (or if we allocate raster lines) they will be in your address space. In order to access them in our expanded address space, we need to add a delta to every address (32 bit offset) that you give us (or that malloc gives us). Once we have added this delta, we can access the data at your pointers. The drawback is that you can't anymore. What you have to do is un-fixup what we have done in order to get the memory pointers back to their original values. To do this, you need to get the value in the mapAltMgr field of the grafMap. Subtract this value from all mapTable and rowtable values and they will be good pointers for your program again. But don't do it directly or we will no longer be able to access the bitmap, so make a copy of the maptable and rowTable pointer that you modify. For example: grafPort *myPortPtr; // pointer to grafPort grafMap *myMapPtr; // pointer to graMap Byte **rowTable; // pointer to rowTable array of raster line pointers Byte *pixelPtr; // pointer to start of 1st raster line data // create the local memory bitmap (return a port pointer) myPortPtr = CreateBitmap(...); // get the pointer to the grafMap structure for the bitmap myMapPtr = myPortPtr->portMap; // get address to the bitmap rowTable (table of pointers to each raster) // (fixup mapTable value since it's relative to MW's private selector) rowTable = (Byte **)( (long)myMapPtr->mapTable[0] - (long)myMapPtr->mapAltMgr ); // get address to the first raster line of pixels // (fixup rowTable value since it's relative to MW's private selector) pixelPtr = (Byte *)( (long)*rowTable - (long)myMapPtr->mapAltMgr ); /* End of File - BPPBMAP.TXT */