LoadImage Problem

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • TEST

    LoadImage Problem

    I am saving images out from a camera to bmp using directshow. I can open
    these images in mspaint or any other image program without a problem.

    Using:
    HBITMAP h_Bitmap;
    h_Bitmap = (HBITMAP)LoadIm age(hInstance, L"C:\\DELETE\\1 .bmp", IMAGE_BITMAP,
    0, 0, LR_LOADFROMFILE );

    h_Bitmap is staying null. GetLastError is returning 0. I can successfully
    load a bitmap created with mspaint without a problem using the method above
    so I have to think their is something extra inside the bitmap cauing issues.
    Looking at the properties of a mspaint bitmap and the one I exported the
    only differences I see is that Bit Depth is 32 for the camera and 24 for the
    one using mspaint.


    I can also load these bitmaps with managed code like

    Bitmap obj_Bitmap1 = Bitmap::FromFil e("C:\\DELETE\\ 1.bmp");
    mobj_PictureBox->Image = Image::FromHbit map(obj_Bitmap1 .GetHbitmap());

    which works fine. Any idea's why this would happen or how I can go about
    fixing or finding out whats going on?


  • David Lowndes

    #2
    Re: LoadImage Problem

    >h_Bitmap = (HBITMAP)LoadIm age(hInstance, L"C:\\DELETE\\1 .bmp", IMAGE_BITMAP,
    >0, 0, LR_LOADFROMFILE );
    The hInst parameter should be NULL

    Dave

    Comment

    • TEST

      #3
      Re: LoadImage Problem

      Thanks for the reply Dave.

      Tried it with NULL also. Same result. It acts like its loading fine
      w/getlasterror returning 0. Any other idea?


      "David Lowndes" <DavidL@example .invalidwrote in message
      news:kcuu84h50s 2us55b3akhddprm saurtacj5@4ax.c om...
      h_Bitmap = (HBITMAP)LoadIm age(hInstance, L"C:\\DELETE\\1 .bmp",
      IMAGE_BITMAP,
      >>0, 0, LR_LOADFROMFILE );
      >
      The hInst parameter should be NULL
      >
      Dave

      Comment

      • TEST

        #4
        Re: LoadImage Problem

        Got it. I was somehow corrupting the bitmap when I wrote it to disk. This
        has been corrected. FYI 5 years from now when someone pulls this, I found
        out for sure by checking the bitmapfileheade r

        FILE *file;
        file = fopen("C:\\imag ing\\result.bmp ", "rb");
        BITMAPFILEHEADE R bitmapFileHeade r;
        size_t read = fread(&bitmapFi leHeader, sizeof(BITMAPFI LEHEADER), 1, file);
        fclose(file);

        bfType should be 19778 per the doc's



        "TEST" <test@test.comw rote in message
        news:%23XzGPrb8 IHA.2548@TK2MSF TNGP05.phx.gbl. ..
        Thanks for the reply Dave.
        >
        Tried it with NULL also. Same result. It acts like its loading fine
        w/getlasterror returning 0. Any other idea?
        >
        >
        "David Lowndes" <DavidL@example .invalidwrote in message
        news:kcuu84h50s 2us55b3akhddprm saurtacj5@4ax.c om...
        >h_Bitmap = (HBITMAP)LoadIm age(hInstance, L"C:\\DELETE\\1 .bmp",
        >IMAGE_BITMAP ,
        >>>0, 0, LR_LOADFROMFILE );
        >>
        >The hInst parameter should be NULL
        >>
        >Dave
        >
        >

        Comment

        Working...