[comp.windows.ms.programmer] Huge pointers and large bitmaps

darak@iplmail.orl.mmc.com (dara khani) (05/22/91)

Petzold says that you should use huge pointer for data > 64k, otherwise
use far pointers.  
My question:
 I have a huge pointer to an image (512x512/8), and I want to 
create a DIBitmap of it.  I type cast the huge pointer variable to a 
LPSTR and pass it to the createDIB.... function.
What puzzles me is why a correct bitmap is created when a LPSTR pointer is 
not suppose to go over 64k.

I am using BC++ and small memory model (386).

thanks in advance,

			DaRa

***************************************************************************
Dara T. Khani                          Email: darak@iplmail.orl.mmc.com   *
Martin Marietta Electronic Systems     Tel: 407-356-8439                  *
Orlando, Florida                                                          *
***************************************************************************
 

  

bonneau@hyper.hyper.com (Paul Bonneau) (05/24/91)

In article <1991May22.151149.8892@iplmail.orl.mmc.com> darak@iplmail.orl.mmc.com (dara khani) writes:
>Petzold says that you should use huge pointer for data > 64k, otherwise
>use far pointers.  
>My question:
> I have a huge pointer to an image (512x512/8), and I want to 
>create a DIBitmap of it.  I type cast the huge pointer variable to a 
>LPSTR and pass it to the createDIB.... function.
>What puzzles me is why a correct bitmap is created when a LPSTR pointer is 
>not suppose to go over 64k.
>
A huge pointer is the same as a far pointer from a data
structure point of view (both are a 16bit segment/selector 16
bit offset pair).

The difference is that the compiler emits code to detect when
a huge pointer crosses a segment boundary and patches the
segment/selector accordingly.

So, you can cast a huge pointer to far and vice versa, no
problem.  Internally, windows is using it as a huge (or is
using it in a 32-bit segment where huge is not needed).

cheers - Paul Bonneau.