亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? winutil.cpp

?? 用DirectX制作高級動畫-[Advanced.Animation.with.DirectX]
?? CPP
?? 第 1 頁 / 共 5 頁
字號:
    // method does nothing but return the same rectangle as we are passed in

    RECT SourceRect = ScaleSourceRect(&m_SourceRect);

    LONG lAdjustedSourceTop = SourceRect.top;
    // if the origin of bitmap is bottom-left, adjust soruce_rect_top
    // to be the bottom-left corner instead of the top-left.
    if (pbmi->biHeight > 0) {
       lAdjustedSourceTop = pbmi->biHeight - SourceRect.bottom;
    }
    // Is the window the same size as the video

    if (m_bStretch == FALSE) {

        // Put the image straight into the window

        SetDIBitsToDevice(
            (HDC) m_hdc,                            // Target device HDC
            m_TargetRect.left,                      // X sink position
            m_TargetRect.top,                       // Y sink position
            m_TargetRect.right - m_TargetRect.left, // Destination width
            m_TargetRect.bottom - m_TargetRect.top, // Destination height
            SourceRect.left,                        // X source position
            lAdjustedSourceTop,                     // Adjusted Y source position
            (UINT) 0,                               // Start scan line
            pbmi->biHeight,                         // Scan lines present
            pImage,                                 // Image data
            (BITMAPINFO *) pbmi,                    // DIB header
            DIB_RGB_COLORS);                        // Type of palette

    } else {

        // Stretch the image when copying to the window

        StretchDIBits(
            (HDC) m_hdc,                            // Target device HDC
            m_TargetRect.left,                      // X sink position
            m_TargetRect.top,                       // Y sink position
            m_TargetRect.right - m_TargetRect.left, // Destination width
            m_TargetRect.bottom - m_TargetRect.top, // Destination height
            SourceRect.left,                        // X source position
            lAdjustedSourceTop,                     // Adjusted Y source position
            SourceRect.right - SourceRect.left,     // Source width
            SourceRect.bottom - SourceRect.top,     // Source height
            pImage,                                 // Image data
            (BITMAPINFO *) pbmi,                    // DIB header
            DIB_RGB_COLORS,                         // Type of palette
            SRCCOPY);                               // Simple image copy
    }

    // This shows the sample reference times over the top of the image which
    // looks a little flickery. I tried using GdiSetBatchLimit and GdiFlush to
    // control the screen updates but it doesn't quite work as expected and
    // only partially reduces the flicker. I also tried using a memory context
    // and combining the two in that before doing a final BitBlt operation to
    // the screen, unfortunately this has considerable performance penalties
    // and also means that this code is not executed when compiled retail

    #ifdef DEBUG
    DisplaySampleTimes(pMediaSample);
    #endif
}


// This is called with an IMediaSample interface on the image to be drawn. We
// decide on the drawing mechanism based on who's allocator we are using. We
// may be called when the window wants an image painted by WM_PAINT messages
// We can't realise the palette here because we have the renderer lock, any
// call to realise may cause an interthread send message to the window thread
// which may in turn be waiting to get the renderer lock before servicing it

BOOL CDrawImage::DrawImage(IMediaSample *pMediaSample)
{
    ASSERT(m_hdc);
    ASSERT(m_MemoryDC);
    NotifyStartDraw();

    // If the output pin used our allocator then the samples passed are in
    // fact CVideoSample objects that contain CreateDIBSection data that we
    // use to do faster image rendering, they may optionally also contain a
    // DirectDraw surface pointer in which case we do not do the drawing

    if (m_bUsingImageAllocator == FALSE) {
        SlowRender(pMediaSample);
        EXECUTE_ASSERT(GdiFlush());
        NotifyEndDraw();
        return TRUE;
    }

    // This is a DIBSECTION buffer

    FastRender(pMediaSample);
    EXECUTE_ASSERT(GdiFlush());
    NotifyEndDraw();
    return TRUE;
}


BOOL CDrawImage::DrawVideoImageHere(
    HDC hdc,
    IMediaSample *pMediaSample,
    LPRECT lprcSrc,
    LPRECT lprcDst
    )
{
    ASSERT(m_pMediaType);
    BITMAPINFOHEADER *pbmi = HEADER(m_pMediaType->Format());
    BYTE *pImage;

    // Get the image data buffer

    HRESULT hr = pMediaSample->GetPointer(&pImage);
    if (FAILED(hr)) {
        return FALSE;
    }

    RECT SourceRect;
    RECT TargetRect;

    if (lprcSrc) {
        SourceRect = *lprcSrc;
    }
    else  SourceRect = ScaleSourceRect(&m_SourceRect);

    if (lprcDst) {
        TargetRect = *lprcDst;
    }
    else  TargetRect = m_TargetRect;

    LONG lAdjustedSourceTop = SourceRect.top;
    // if the origin of bitmap is bottom-left, adjust soruce_rect_top
    // to be the bottom-left corner instead of the top-left.
    if (pbmi->biHeight > 0) {
       lAdjustedSourceTop = pbmi->biHeight - SourceRect.bottom;
    }


    // Stretch the image when copying to the DC

    BOOL bRet = (0 != StretchDIBits(hdc,
                                    TargetRect.left,
                                    TargetRect.top,
                                    TargetRect.right - TargetRect.left,
                                    TargetRect.bottom - TargetRect.top,
                                    SourceRect.left,
                                    lAdjustedSourceTop,
                                    SourceRect.right - SourceRect.left,
                                    SourceRect.bottom - SourceRect.top,
                                    pImage,
                                    (BITMAPINFO *)pbmi,
                                    DIB_RGB_COLORS,
                                    SRCCOPY));
    return bRet;
}


// This is called by the owning window object after it has created the window
// and it's drawing contexts. We are constructed with the base window we'll
// be drawing into so when given the notification we retrive the device HDCs
// to draw with. We cannot call these in our constructor as they are virtual

void CDrawImage::SetDrawContext()
{
    m_MemoryDC = m_pBaseWindow->GetMemoryHDC();
    m_hdc = m_pBaseWindow->GetWindowHDC();
}


// This is called to set the target rectangle in the video window, it will be
// called whenever a WM_SIZE message is retrieved from the message queue. We
// simply store the rectangle and use it later when we do the drawing calls

void CDrawImage::SetTargetRect(RECT *pTargetRect)
{
    ASSERT(pTargetRect);
    m_TargetRect = *pTargetRect;
    SetStretchMode();
}


// Return the current target rectangle

void CDrawImage::GetTargetRect(RECT *pTargetRect)
{
    ASSERT(pTargetRect);
    *pTargetRect = m_TargetRect;
}


// This is called when we want to change the section of the image to draw. We
// use this information in the drawing operation calls later on. We must also
// see if the source and destination rectangles have the same dimensions. If
// not we must stretch during the drawing rather than a direct pixel copy

void CDrawImage::SetSourceRect(RECT *pSourceRect)
{
    ASSERT(pSourceRect);
    m_SourceRect = *pSourceRect;
    SetStretchMode();
}


// Return the current source rectangle

void CDrawImage::GetSourceRect(RECT *pSourceRect)
{
    ASSERT(pSourceRect);
    *pSourceRect = m_SourceRect;
}


// This is called when either the source or destination rectanges change so we
// can update the stretch flag. If the rectangles don't match we stretch the
// video during the drawing otherwise we call the fast pixel copy functions
// NOTE the source and/or the destination rectangle may be completely empty

void CDrawImage::SetStretchMode()
{
    // Calculate the overall rectangle dimensions

    LONG SourceWidth = m_SourceRect.right - m_SourceRect.left;
    LONG SinkWidth = m_TargetRect.right - m_TargetRect.left;
    LONG SourceHeight = m_SourceRect.bottom - m_SourceRect.top;
    LONG SinkHeight = m_TargetRect.bottom - m_TargetRect.top;

    m_bStretch = TRUE;
    if (SourceWidth == SinkWidth) {
        if (SourceHeight == SinkHeight) {
            m_bStretch = FALSE;
        }
    }
}


// Tell us whose allocator we are using. This should be called with TRUE if
// the filter agrees to use an allocator based around the CImageAllocator
// SDK base class - whose image buffers are made through CreateDIBSection.
// Otherwise this should be called with FALSE and we will draw the images
// using SetDIBitsToDevice and StretchDIBitsToDevice. None of these calls
// can handle buffers which have non zero strides (like DirectDraw uses)

void CDrawImage::NotifyAllocator(BOOL bUsingImageAllocator)
{
    m_bUsingImageAllocator = bUsingImageAllocator;
}


// Are we using the image DIBSECTION allocator

BOOL CDrawImage::UsingImageAllocator()
{
    return m_bUsingImageAllocator;
}


// We need the media type of the connection so that we can get the BITMAPINFO
// from it. We use that in the calls to draw the image such as StretchDIBits
// and also when updating the colour table held in shared memory DIBSECTIONs

void CDrawImage::NotifyMediaType(CMediaType *pMediaType)
{
    m_pMediaType = pMediaType;
}


// We store in this object a cookie maintaining the current palette version.
// Each time a palettised format is changed we increment this value so that
// when we come to draw the images we look at the colour table value they
// have and if less than the current we know to update it. This version is
// only needed and indeed used when working with shared memory DIBSECTIONs

LONG CDrawImage::GetPaletteVersion()
{
    return m_PaletteVersion;
}


// Resets the current palette version number

void CDrawImage::ResetPaletteVersion()
{
    m_PaletteVersion = PALETTE_VERSION;
}


// Increment the current palette version

void CDrawImage::IncrementPaletteVersion()
{
    m_PaletteVersion++;
}


// Constructor must initialise the base allocator. Each sample we create has a
// palette version cookie on board. When the source filter changes the palette
// during streaming the window object increments an internal cookie counter it
// keeps as well. When it comes to render the samples it looks at the cookie
// values and if they don't match then it knows to update the sample's colour
// table. However we always create samples with a cookie of PALETTE_VERSION
// If there have been multiple format changes and we disconnect and reconnect
// thereby causing the samples to be reallocated we will create them with a
// cookie much lower than the current version, this isn't a problem since it
// will be seen by the window object and the versions will then be updated

CImageAllocator::CImageAllocator(CBaseFilter *pFilter,
                                 TCHAR *pName,
                                 HRESULT *phr) :
    CBaseAllocator(pName,NULL,phr,TRUE,TRUE),
    m_pFilter(pFilter)
{
    ASSERT(phr);
    ASSERT(pFilter);
}


// Check our DIB buffers have been released

#ifdef DEBUG
CImageAllocator::~CImageAllocator()
{
    ASSERT(m_bCommitted == FALSE);
}
#endif


// Called from destructor and also from base class to free resources. We work
// our way through the list of media samples deleting the DIBSECTION created
// for each. All samples should be back in our list so there is no chance a
// filter is still using one to write on the display or hold on a pending list

void CImageAllocator::Free()
{
    ASSERT(m_lAllocated == m_lFree.GetCount());
    EXECUTE_ASSERT(GdiFlush());
    CImageSample *pSample;
    DIBDATA *pDibData;

    while (m_lFree.GetCount() != 0) {
        pSample = (CImageSample *) m_lFree.RemoveHead();
        pDibData = pSample->GetDIBData();
        EXECUTE_ASSERT(DeleteObject(pDibData->hBitmap));
        EXECUTE_ASSERT(CloseHandle(pDibData->hMapping));
        delete pSample;
    }

    m_lAllocated = 0;
}


// Prepare the allocator by checking all the input parameters

STDMETHODIMP CImageAllocator::CheckSizes(ALLOCATOR_PROPERTIES *pRequest)
{
    // Check we have a valid connection

    if (m_pMediaType == NULL) {
        return VFW_E_NOT_CONNECTED;
    }

    // NOTE We always create a DIB section with the source format type which
    // may contain a source palette. When we do the BitBlt drawing operation
    // the target display device may contain a different palette (we may not
    // have the focus) in which case GDI will do after the palette mapping

    VIDEOINFOHEADER *pVideoInfo = (VIDEOINFOHEADER *) m_pMediaType->Format();

    // When we call CreateDIBSection it implicitly maps only enough memory
    // for the image as defined by thee BITMAPINFOHEADER. If the user asks
    // for an image smaller than this then we reject the call, if they ask
    // for an image larger than this then we return what they can have

    if ((DWORD) pRequest->cbBuffer < pVideoInfo->bmiHeader.biSizeImage) {
        return E_INVALIDARG;
    }

    // Reject buffer prefixes

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
粉嫩久久99精品久久久久久夜| 一区二区在线观看免费| 欧美性感一区二区三区| 成人av午夜影院| 国产成a人无v码亚洲福利| 国产永久精品大片wwwapp| 国产精品一二三在| 成人综合激情网| a亚洲天堂av| 色噜噜久久综合| 欧美在线观看你懂的| 欧美男男青年gay1069videost| 9191国产精品| 精品国精品国产尤物美女| 欧美精品一区二区三区很污很色的| 日韩女优毛片在线| 国产视频一区在线观看| 亚洲人成在线观看一区二区| 一区二区三区在线观看网站| 亚洲国产日韩a在线播放| 爽爽淫人综合网网站| 日本精品一区二区三区高清| 欧美日韩国产免费一区二区| 日韩欧美在线不卡| 欧美韩国日本综合| 亚洲国产欧美一区二区三区丁香婷| 日日夜夜精品视频免费| 加勒比av一区二区| 99国产精品国产精品毛片| 欧美性猛片xxxx免费看久爱| 欧美tickling网站挠脚心| 亚洲色图在线播放| 麻豆一区二区三| 99国产精品久久久| 欧美xingq一区二区| 一区二区三区小说| 蜜桃视频一区二区三区在线观看| 成人午夜激情视频| 91精品国产色综合久久| 国产精品国产自产拍高清av王其| 石原莉奈在线亚洲三区| 成人免费看黄yyy456| 欧美美女网站色| 国产精品少妇自拍| 另类欧美日韩国产在线| 欧美在线综合视频| 国产喷白浆一区二区三区| 日韩电影在线观看一区| 91一区二区在线| 国产欧美精品一区| 蜜桃在线一区二区三区| 欧洲av在线精品| 国产精品三级av| 狠狠色综合色综合网络| 在线不卡免费av| 一卡二卡三卡日韩欧美| 成人av在线电影| 欧美videossexotv100| 亚洲va韩国va欧美va| 色综合久久综合网欧美综合网| 久久精品一区二区三区不卡| 青青草国产精品97视觉盛宴| 欧美日韩在线精品一区二区三区激情| 欧美国产日韩一二三区| 精品伊人久久久久7777人| 在线欧美日韩国产| 18欧美亚洲精品| 成人涩涩免费视频| 欧美国产一区在线| 成人国产亚洲欧美成人综合网| 精品国内二区三区| 国产一二三精品| wwwwww.欧美系列| 国产在线视频不卡二| 欧美大片在线观看一区| 看电影不卡的网站| 欧美成人aa大片| 韩国av一区二区三区| 久久久久久久久久久电影| 国产一区三区三区| 欧美激情一区不卡| 99精品视频中文字幕| 日韩一区中文字幕| 欧美婷婷六月丁香综合色| 亚洲综合自拍偷拍| 欧美一区二区三区思思人| 精久久久久久久久久久| 久久精品无码一区二区三区| 国产91精品在线观看| 亚洲欧洲av一区二区三区久久| 91蜜桃视频在线| 无吗不卡中文字幕| 亚洲精品一区二区三区在线观看| 国产精品小仙女| 亚洲精品日韩综合观看成人91| 欧美人妇做爰xxxⅹ性高电影| 奇米888四色在线精品| 欧美精品一区视频| 色综合色综合色综合色综合色综合| 亚洲综合色噜噜狠狠| 日韩欧美亚洲国产另类| 99视频国产精品| 日日摸夜夜添夜夜添精品视频| 久久久久国产成人精品亚洲午夜| 93久久精品日日躁夜夜躁欧美| 亚洲在线观看免费| 精品电影一区二区| 日本久久电影网| 狠狠网亚洲精品| 亚洲一区在线视频| 久久日韩粉嫩一区二区三区| 91在线观看一区二区| 天天色图综合网| 国产精品免费视频一区| 欧美久久一二区| 99国产精品久久久久久久久久| 日韩精品电影一区亚洲| 国产精品久久久久久久久久免费看 | 国产欧美日韩在线看| 91免费看视频| 国产麻豆精品在线| 亚洲大片在线观看| 国产精品灌醉下药二区| 日韩欧美国产系列| 欧美在线免费视屏| 成人动漫一区二区| 激情文学综合插| 日本怡春院一区二区| 亚洲激情第一区| 国产精品人成在线观看免费| 日韩午夜在线观看| 8x福利精品第一导航| 91麻豆福利精品推荐| 国产99久久久国产精品潘金 | 国产高清成人在线| 日韩成人av影视| 五月天亚洲精品| 亚洲精品免费在线| 综合色中文字幕| 欧美国产激情一区二区三区蜜月| 精品国产乱码久久久久久牛牛| 欧美日韩亚洲丝袜制服| 色偷偷久久人人79超碰人人澡| 丁香五精品蜜臀久久久久99网站| 久久国产视频网| 免费观看在线色综合| 蜜臀av一区二区三区| 另类人妖一区二区av| 久久av资源站| 国产麻豆日韩欧美久久| 国产一区视频导航| 懂色av中文字幕一区二区三区 | 欧美蜜桃一区二区三区| 色爱区综合激月婷婷| 在线观看免费一区| 欧美性欧美巨大黑白大战| 在线观看视频欧美| 欧美性色欧美a在线播放| 欧美亚洲动漫另类| 4hu四虎永久在线影院成人| 欧美日韩国产成人在线免费| 欧美精品在欧美一区二区少妇| 欧美日韩1234| 欧美电视剧在线看免费| 久久久久久久久蜜桃| 国产精品日韩成人| 亚洲精品写真福利| 午夜亚洲国产au精品一区二区| 日韩av不卡一区二区| 国产一区二区三区四区在线观看 | 91成人网在线| 欧美精品 国产精品| 日韩精品一区二区三区中文不卡| 精品国产区一区| 中文字幕一区在线观看视频| 一区二区在线观看视频| 裸体一区二区三区| 国产成人在线看| 欧洲精品视频在线观看| 日韩欧美的一区| 亚洲欧美自拍偷拍色图| 亚洲一区二区av在线| 久久黄色级2电影| 99r精品视频| 欧美一区二区视频观看视频| 国产免费成人在线视频| 亚洲成人一区在线| 国产激情视频一区二区三区欧美| 一本色道久久综合亚洲aⅴ蜜桃| 欧美精品自拍偷拍动漫精品| 国产女主播在线一区二区| 亚洲第一电影网| 高清视频一区二区| 欧美精品免费视频| 国产精品久久久久久久久久免费看 | 亚洲黄色性网站| 国产尤物一区二区| 欧美久久婷婷综合色| 国产精品久久久久久久午夜片 | 国产亚洲精品资源在线26u|