線上訂房服務-台灣趴趴狗聯合訂房中心
發文 回覆 瀏覽次數:1976
推到 Plurk!
推到 Facebook!

如何使用vfw.h 中的ICImagecompress 及 ICImageDecompress

尚未結案
RU
一般會員


發表:5
回覆:3
積分:1
註冊:2003-01-22

發送簡訊給我
#1 引用回覆 回覆 發表時間:2003-09-18 03:18:08 IP:211.75.xxx.xxx 未訂閱
請教一下,如何使用vfw.h 中的ICImagecompress 及 ICImageDecompress 來壓縮及解壓縮影像,有些設定參數不明白 LRESULT PASCAL TVideo::fpVideoCallback(HWND hWnd, LPVIDEOHDR lpVHdr) { DrawDibBegin(video->hdd,video->hdc,-1,-1,&video->bmpinfo.bmiHeader,176,144,NULL); DrawDibDraw(video->hdd,video->hdc,240,30,176,144,&video->bmpinfo.bmiHeader,lpVHdr- >lpData, 0,0,176,144,DDF_SAME_DRAW | DDF_SAME_HDC); } lpVHdr->lpdata是要壓縮的資料 請各位前輩寫個程式範例讓我了解,Thank you
cmf
尊榮會員


發表:84
回覆:918
積分:1032
註冊:2002-06-26

發送簡訊給我
#2 引用回覆 回覆 發表時間:2003-09-20 12:40:43 IP:61.218.xxx.xxx 未訂閱
------
︿︿
cmf
尊榮會員


發表:84
回覆:918
積分:1032
註冊:2002-06-26

發送簡訊給我
#3 引用回覆 回覆 發表時間:2003-09-23 15:00:47 IP:61.218.xxx.xxx 未訂閱
    Date: Sat, 19 Sep 1998 14:33:57 -0700 (PDT)
From: "Eugene Epshteyn" 
To: Zaheer Shamsi 
Subject: Re: Video compression...    On Sun, 20 Sep 1998, Zaheer Shamsi wrote:    > I went thru the iccompressxxx
> fucntions to but confused what to use and how to use.    For audio, you need to setup WAVEFORMATEX structure and pass it to
capSetAudioFormat().  The audio you get in the callback function will be
already compressed.    For video, you need to use ICxxx() functions.  I don't remember what
exactly goes on on decompression side, but I will tell you about the
compression.    Here's how to use ICxxx() compression functions:    (1) At the initialization:    (Here's the example of opening H263 compressor.  You need to choose
compressor, which is apporpriate for your application.)    HIC hic ;    // Open the compressor
hic = ICOpen(ICTYPE_VIDEO, H263, ICMODE_FASTCOMPRESS);    where H263 is defined like this:    #define H263        (mmioFOURCC('h', '2', '6', '3'))    // set compression options    COMPVARS compressopt;    NOTE: you can use ICCompressorChoose() to set COMPVARS structure.  This
function fill bring up a dialog box, which will let you choose the
compressor yourself.    If you don't use ICCompressorChoose(), you will need to assign members of
COMPVARS yourself:    // You need to assign the fields with the input (uncompressed) format
// of the video which you obtain from the video capture
BITMAPINFO* pBitmapIn = NULL ;    DWORD inSize = capGetVideoFormatSize(/* capture window */) ;    pBitmapIn = (BITMAPINFO*) malloc(inSize) ;    Here's the safe way to do it:    capGetVideoFormat(
/* handle to your capture window*/, 
pBitmapIn,
sizeof(BITMAPINFO));    /* modify relevant fields of bitmap_in according to your desired format */    BITMAPINFO* pBitmapOut = NULL ;    DWORD outSize = ICCompressGetFormatSize(hic, pBitmapIn) ;    pBitmapOut = (BITMAPINFO*) malloc(outSize) ;    // get output bitmap format:
ICCompressGetFormat(hic, pBitmapIn, pBitmapOut) ;    compressopt.cbSize = sizeof(COMPVARS);
compressopt.dwFlags = ICMF_COMPVARS_VALID;
compressopt.hic = hic;
compressopt.lpbiOut = pBitmapOut ;
compressopt.lKey = /* up to you: read COMPVARS documentation */ ;
compressopt.lQ = /* up to you */ ;    (1.5) Just before you start capture:    ICSeqCompressFrameStart(&compressopt, pBitmapIn);    (2) In the callback function:    LRESULT CALLBACK VideoCallbackProc(HWND hWnd, LPVIDEOHDR lpVHdr)
{    BOOL keyframe ;
long size = /* maximum desired size; read ICSeqCompressFrame()
documentation */    char* pCompressedFrame = (char*) ICSeqCompressFrame(
        &compressopt,
        0,
        lpVHdr->lpData,
        &keyframe,
        &size) ;    // you should get a pointer to compressed frame; I don't think you need
// to deallocate the data yourself, b/c compressor should do it for you.
// Make sure you send the size along with the data, b/c it will be
// variable.    }
// end of callback function    (2.5) Just after you stop capture:    ICSeqCompressFrameEnd(&compressopt);    (3) Cleanup:    ICCompressorFree(&compressopt);    NOTE: don't do free(pBitmapOut), b/c ICCompressorFree() will do
free(compressopt.lpbiOut), which is the same thing.    NOTE: I don't remember if you need to call ICClose() on hic (see (1)) or
if ICCompressorFree() does it for you.    That should do the compression for you.    -----------------------------------------------    On the decompression side, I _suspect_ you need to use
ICImageDecompress(), where you obtain HIC the same way you obtained it
above (or set it to NULL: see documentation), lpbiIn is the same as
pBitmapOut above, lpbiOut is the same as pBitmapIn above, and lpBits is
the address of the buffer with the bits you received.  What you get back
is the handle to uncompressed DIB, which you can convert to a pointer.    And for audio you probably need to use waveOutOpen() and related
functions.    --Eugene    -- 
------------------------------------ ------------------------------------
~ Yevgeniy 'Eugene' Epshteyn       ~ ~       nyethspE `eneguE` yinegveY ~
~ email: Eugene_Epshteyn@yahoo.com ~ ~ moc.oohay@nyethspE_eneguE :liame ~
~   www: http://eye.seagull.net    ~ ~    ten.llugaes.eye\\:ptth :www   ~
------------------------------------ ------------------------------------         
------
︿︿
系統時間:2024-04-29 22:30:57
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!