none
利用directshow如何改變照相得到的圖片大小 RRS feed

  • 問題

  • 大家好:

    如題,目前利用directshow讓PPC可以自動照相,但是照相得到的圖片大小只能為160*120,請問該如何改變圖片大小?我目前利用GetStreamCaps得到三種解析度160*120,320*240,176*144,請問程式該如何寫才能改變圖片大小為320*240,麻煩說詳細一些,謝謝,另外若加入預覽的這個效果,如何改變預覽視窗大小,謝謝

    2006年11月20日 上午 08:19

解答

  • The VIDEO_STREAM_CONFIG_CAPS structure gives the minimum and maximum width and height that can be used for this media type. It also gives you the "step" size, which defines the increments by which you can adjust the width or height. For example, the device might return the following:

    • MinOutputSize: 160 x 120
    • MaxOutputSize: 320 x 240
    • OutputGranularityX: 8 pixels (horizontal step size)
    • OutputGranularityY: 8 pixels (vertical step size)

    Given these numbers, you could set the width to anything in the range (160, 168, 176, ... 304, 312, 320) and the height to anything in the range (120, 128, 136, ... 104, 112, 120).

     

     

     

     

    To set a new frame size, directly modify the AM_MEDIA_TYPE structure returned in GetStreamCaps:

    pVih->bmiHeader.biWidth = 160;
    pVih->bmiHeader.biHeight = 120;
    pVih->bmiHeader.biSizeImage = DIBSIZE(pVih->bmiHeader);
    

    Then pass the media type to the SetFormat method, as described previously.

     

     

    完整說明:

    http://msdn2.microsoft.com/en-us/library/ms782246.aspx

    2007年12月7日 上午 06:24

所有回覆

  • The VIDEO_STREAM_CONFIG_CAPS structure gives the minimum and maximum width and height that can be used for this media type. It also gives you the "step" size, which defines the increments by which you can adjust the width or height. For example, the device might return the following:

    • MinOutputSize: 160 x 120
    • MaxOutputSize: 320 x 240
    • OutputGranularityX: 8 pixels (horizontal step size)
    • OutputGranularityY: 8 pixels (vertical step size)

    Given these numbers, you could set the width to anything in the range (160, 168, 176, ... 304, 312, 320) and the height to anything in the range (120, 128, 136, ... 104, 112, 120).

     

     

     

     

    To set a new frame size, directly modify the AM_MEDIA_TYPE structure returned in GetStreamCaps:

    pVih->bmiHeader.biWidth = 160;
    pVih->bmiHeader.biHeight = 120;
    pVih->bmiHeader.biSizeImage = DIBSIZE(pVih->bmiHeader);
    

    Then pass the media type to the SetFormat method, as described previously.

     

     

    完整說明:

    http://msdn2.microsoft.com/en-us/library/ms782246.aspx

    2007年12月7日 上午 06:24
  •  

    您好:

        謝謝您呦^^雖然這問題我已經解決很久了,還是還很感謝您呦

    2007年12月7日 上午 06:28
  • 請問如果我是用在 filter 中修改 image size

    ex 我原先是設定 1280*720  後來發現 source 進來的影像是 640*480

    請問我該怎麼改呢???

    有sample 可以參考嗎

    我試過很多方法 都不可行

    不知道你是怎麼解決呢??

     

    謝謝你的回覆

    2010年3月23日 上午 03:41