none
Save image with boost::gil problem RRS feed

  • Question

  • Hi all,

    I want to capture the color and depth image from kineck and using boost::gil to save image.

    I have some problem to save the image.

    1. First I add some code to SkeletalViwer(c++) in Nui_GotColorAlert function:

    if( LockedRect.Pitch != 0) { m_pDrawColor->Draw( static_cast<BYTE*>(LockedRect.pBits), LockedRect.size); bgra8_view_t imagefile = interleaved_view( width, height, (bgra8_pixel_t*)(LockedRect.pBits), LockedRect.Pitch);

    tiff_write_view("image.tif", color_converted_view<bgr8_pixel_t>(imagefile)); }

    I use libtiff.lib which version is 3.8.2.

    Then, the saved image is black.

    If I modify "bgra8_view_t " to "bgr8_view_t ", it can give image but not corrently.


    2. In the tiff_write_view function, I cann't pass the imagefile without converting function. If I pass imagefile directly, it will compile error and show this information "error C2338: tiff_write_support<View>::is_supported".

    I don't know how to fix these problem and save color and depth image correctly. 

    Thank you.

    Tuesday, February 14, 2012 4:07 AM

Answers

  • While I'm not familiar with boost::gil, it looks like you need a format such as bgrx8, where each channel has 8 bits, but there are 32 bits per pixel such as you might find in bgr8.  If bgr8 is, in fact, 32bpp (and not 24bpp), then I'm not sure the right format exists for you to do this without manually copying the data and, say, setting each alpha channel to 255.


    -Adam Smith [MSFT]

    • Marked as answer by STWhite Tuesday, February 14, 2012 8:57 AM
    Tuesday, February 14, 2012 7:36 AM

All replies

  • While I'm not familiar with boost::gil, it looks like you need a format such as bgrx8, where each channel has 8 bits, but there are 32 bits per pixel such as you might find in bgr8.  If bgr8 is, in fact, 32bpp (and not 24bpp), then I'm not sure the right format exists for you to do this without manually copying the data and, say, setting each alpha channel to 255.


    -Adam Smith [MSFT]

    • Marked as answer by STWhite Tuesday, February 14, 2012 8:57 AM
    Tuesday, February 14, 2012 7:36 AM
  • Thank you for reply.

    Now, I giveup to use boost::gil.

    I use libtiff to save image.

    If using boost::gil, it need to change alpha channel to 255 manually. (In my first try, I don't change this value and the image can't display anything)

    So, I don't think use interleaved_view function can achieve this object. 

    Tuesday, February 14, 2012 8:56 AM