⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 showjpegview.cpp

📁 音频水印水印算法
💻 CPP
字号:
// ShowJpegView.cpp : implementation file
//

#include "stdafx.h"
#include "pgm.h"
#include "ShowJpegView.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CShowJpegView

IMPLEMENT_DYNCREATE(CShowJpegView, CView)

CShowJpegView::CShowJpegView()
{
}

CShowJpegView::~CShowJpegView()
{
}


BEGIN_MESSAGE_MAP(CShowJpegView, CView)
	//{{AFX_MSG_MAP(CShowJpegView)
		// NOTE - the ClassWizard will add and remove mapping macros here.
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CShowJpegView drawing

void CShowJpegView::OnDraw(CDC* pDC)
{
	CDocument* pDoc = GetDocument();
	// TODO: add draw code here
}

/////////////////////////////////////////////////////////////////////////////
// CShowJpegView diagnostics

#ifdef _DEBUG
void CShowJpegView::AssertValid() const
{
	CView::AssertValid();
}

void CShowJpegView::Dump(CDumpContext& dc) const
{
	CView::Dump(dc);
}
#endif //_DEBUG

/////////////////////////////////////////////////////////////////////////////
// CShowJpegView message handlers

BOOL CShowJpegView::ShowJpgGif(CDC *pDC, CString strPath, int x, int y)
{
    IStream *pStm;  
    CFileStatus fstatus;  
    CFile file;  
    LONG cb;  

    //打开文件并检测文件的有效性

    if (file.Open(strPath,CFile::modeRead)&&file.GetStatus(strPath,fstatus)&& ((cb = fstatus.m_size) != -1))  

    {  
        HGLOBAL hGlobal = GlobalAlloc(GMEM_MOVEABLE, cb);  

        LPVOID pvData = NULL;  

        if (hGlobal != NULL)  

        {  

            pvData = GlobalLock(hGlobal);

            if (pvData != NULL)  

            {  

                file.ReadHuge(pvData, cb);  

                GlobalUnlock(hGlobal);  

                CreateStreamOnHGlobal(hGlobal, TRUE, &pStm);  

            } 

        } 

    }

    else

    {

        return false;

    } //打开文件结束

    

    //显示JPEG和GIF格式的图片,GIF只能显示一帧,还不能显示动画,

//要显示动画GIF请使用ACTIVE控件。

    IPicture *pPic; 

    //load image from file stream

    if(SUCCEEDED(OleLoadPicture(pStm,fstatus.m_size,TRUE,IID_IPicture,(LPVOID*)&pPic))) 

    { 

        OLE_XSIZE_HIMETRIC hmWidth;  

        OLE_YSIZE_HIMETRIC hmHeight;  

        pPic->get_Width(&hmWidth);  

        pPic->get_Height(&hmHeight);  

        double fX,fY;  

        //get image height and width

        fX = (double)pDC->GetDeviceCaps(HORZRES)*(double)hmWidth/((double)pDC->GetDeviceCaps(HORZSIZE)*100.0);  

        fY = (double)pDC->GetDeviceCaps(VERTRES)*(double)hmHeight/((double)pDC->GetDeviceCaps(VERTSIZE)*100.0);  

        //use render function display image

        if(FAILED(pPic->Render(*pDC,x,y,(DWORD)fX,(DWORD)fY,0,hmHeight,hmWidth,-hmHeight,NULL)))  

        {

            pPic->Release();

            return false;

        }

        pPic->Release();  

    }  

    else  

    {

        return false;  

    }

    return true;

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -