DirectX: loading bmp's onto surfaces - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

DirectX: loading bmp's onto surfaces

I'm a newby teaching myself c++ and I'm just up to directX. So far I've just been reading online tutorials about how the directdraw objects work, and I've got the surfaces,fliping,screenmodes all working fine, but when I get to loading an image onto the buffer, I get some issues. firstly, can anyone tell me how to extract a PALETTEENTRY(s) from a bmp on disk? I cant find ANYTHING on this. secondly, I'm shaky on HBITMAP stuff, can anyone tell me if this is cos I dont have a palette or something else, when I do this:

hbm = ( HBITMAP )LoadImage( NULL,
"back.bmp",
NULL, Width, Height, LR_LOADFROMFILE | LR_CREATEDIBSECTION);

I get exactly eleven of these kick up at "back.bmp"
error C2018: unknown character '0xa0'

Everything i've read uses a DC to a HBITMAP to blt() onto a (DC to a) surface
If theres a better way to get bmp's onto surfaces i'd love to know, cos as you can see i'm a bit stumped.

Comments

  • afterdeathafterdeath Posts: 14Member
    : I'm a newby teaching myself c++ and I'm just up to directX. So far I've just been reading online tutorials about how the directdraw objects work, and I've got the surfaces,fliping,screenmodes all working fine, but when I get to loading an image onto the buffer, I get some issues. firstly, can anyone tell me how to extract a PALETTEENTRY(s) from a bmp on disk? I cant find ANYTHING on this. secondly, I'm shaky on HBITMAP stuff, can anyone tell me if this is cos I dont have a palette or something else, when I do this:
    :
    : hbm = ( HBITMAP )LoadImage( NULL,
    : "back.bmp",
    : NULL, Width, Height, LR_LOADFROMFILE | LR_CREATEDIBSECTION);
    :
    : I get exactly eleven of these kick up at "back.bmp"
    : error C2018: unknown character '0xa0'
    :
    : Everything i've read uses a DC to a HBITMAP to blt() onto a (DC to a) surface
    : If theres a better way to get bmp's onto surfaces i'd love to know, cos as you can see i'm a bit stumped.
    :

    well, I don't think that you need the palette when you load the BMP using Win32, you need to load the image and blit it to the screen, as for your function, you don't need the LR_CREATEDIBSECTION flag.

    In DirectX, you need to load the image normaly using the LoadImage function and then blit to DirectX surface before you can use it in DirectX. It's the same at blitting the image on screen, you load the image, select it using SelectObject and then blit it to the image. Don't forget to create the DC.

    The only way I know of and used in exctracting the Palette from the image was by writting my own loading function.

    If you can't seem to get it right, I might post a small piece of code to help you with that.

  • afterdeathafterdeath Posts: 14Member
    : I'm a newby teaching myself c++ and I'm just up to directX. So far I've just been reading online tutorials about how the directdraw objects work, and I've got the surfaces,fliping,screenmodes all working fine, but when I get to loading an image onto the buffer, I get some issues. firstly, can anyone tell me how to extract a PALETTEENTRY(s) from a bmp on disk? I cant find ANYTHING on this. secondly, I'm shaky on HBITMAP stuff, can anyone tell me if this is cos I dont have a palette or something else, when I do this:
    :
    : hbm = ( HBITMAP )LoadImage( NULL,
    : "back.bmp",
    : NULL, Width, Height, LR_LOADFROMFILE | LR_CREATEDIBSECTION);
    :
    : I get exactly eleven of these kick up at "back.bmp"
    : error C2018: unknown character '0xa0'
    :
    : Everything i've read uses a DC to a HBITMAP to blt() onto a (DC to a) surface
    : If theres a better way to get bmp's onto surfaces i'd love to know, cos as you can see i'm a bit stumped.
    :

    well, I don't think that you need the palette when you load the BMP using Win32, you need to load the image and blit it to the screen, as for your function, you don't need the LR_CREATEDIBSECTION flag.

    In DirectX, you need to load the image normaly using the LoadImage function and then blit to DirectX surface before you can use it in DirectX. It's the same at blitting the image on screen, you load the image, select it using SelectObject and then blit it to the image. Don't forget to create the DC.

    The only way I know of and used in exctracting the Palette from the image was by writting my own loading function.

    If you can't seem to get it right, I might post a small piece of code to help you with that.

Sign In or Register to comment.