Jpg文件在vc中怎么打开?
1个回答
展开全部
//
BOOL CJpg::Load(CArchive& ar,BOOL FileFormat)
{
if(FileFormat)
{
int DataSize=sizeof(BITDATA);
ar.Read(&m_BitData,DataSize);
}
CArchiveStream arcstream(&ar);
return Load((IStream*)&arcstream,FileFormat);
}
// 装载信息数据
void CJpg::LoadFileData(CArchive& ar)
{
char c[20];
for(int i=0;i<20;i++)
{
ar>>c[i];
}
/*
// 版本
for(int i=0;i<10;i++)
ar>>m_BitData.Str[i];
// 物体名称
for(i=0;i<20;i++)
ar>>m_BitData.Name[i];
// 水平数量
ar>>m_BitData.Size_x;
// 垂直数量
ar>>m_BitData.Size_y;
// 每片图片的大小
for(i=0;i<10;i++)
{
ar>>m_BitData.PartRect[i][0];
ar>>m_BitData.PartRect[i][1];
ar>>m_BitData.PartRect[i][2];
ar>>m_BitData.PartRect[i][3];
}
*/
// 备用
// for(i=0;i<50;i++)
// ar>>m_BitData.pData[i];
}
//////////////////
// Load from stream (IStream). This is the one that really does it: call
// OleLoadPicture to do the work.
//
BOOL CJpg::Load(IStream* pstm,BOOL FileFormat)
{
Free();
HRESULT hr = OleLoadPicture(pstm, 0, FALSE,
IID_IPicture, (void**)&m_spIPicture);
ASSERT(SUCCEEDED(hr) && m_spIPicture);
return TRUE;
}
//////////////////
// Render to device context. Covert to HIMETRIC for IPicture.
//
BOOL CJpg::Render(CDC* pDC, CRect rc, LPCRECT prcMFBounds) const
{
ASSERT(pDC);
if (rc.IsRectNull()) {
CSize sz = GetBitSize();
rc.right = sz.cx;
rc.bottom = sz.cy;
}
long hmWidth,hmHeight; // HIMETRIC units
GetHIMETRICSize(hmWidth, hmHeight);
m_spIPicture->Render(*pDC, rc.left, rc.top, rc.Width(), rc.Height(),
0, hmHeight, hmWidth, -hmHeight, prcMFBounds);
return TRUE;
}
BOOL CJpg::Render(HDC hdc, CRect rc, LPCRECT prcMFBounds)
{
ASSERT(hdc);
if (rc.IsRectNull()) {
CSize sz = GetBitSize();
rc.right = sz.cx;
rc.bottom = sz.cy;
}
long hmWidth,hmHeight; // HIMETRIC units
GetHIMETRICSize(hmWidth, hmHeight);
m_spIPicture->Render(hdc, rc.left, rc.top, rc.Width(), rc.Height(),
0, hmHeight, hmWidth, -hmHeight, prcMFBounds);
return TRUE;
}
BOOL CJpg::Load(CArchive& ar,BOOL FileFormat)
{
if(FileFormat)
{
int DataSize=sizeof(BITDATA);
ar.Read(&m_BitData,DataSize);
}
CArchiveStream arcstream(&ar);
return Load((IStream*)&arcstream,FileFormat);
}
// 装载信息数据
void CJpg::LoadFileData(CArchive& ar)
{
char c[20];
for(int i=0;i<20;i++)
{
ar>>c[i];
}
/*
// 版本
for(int i=0;i<10;i++)
ar>>m_BitData.Str[i];
// 物体名称
for(i=0;i<20;i++)
ar>>m_BitData.Name[i];
// 水平数量
ar>>m_BitData.Size_x;
// 垂直数量
ar>>m_BitData.Size_y;
// 每片图片的大小
for(i=0;i<10;i++)
{
ar>>m_BitData.PartRect[i][0];
ar>>m_BitData.PartRect[i][1];
ar>>m_BitData.PartRect[i][2];
ar>>m_BitData.PartRect[i][3];
}
*/
// 备用
// for(i=0;i<50;i++)
// ar>>m_BitData.pData[i];
}
//////////////////
// Load from stream (IStream). This is the one that really does it: call
// OleLoadPicture to do the work.
//
BOOL CJpg::Load(IStream* pstm,BOOL FileFormat)
{
Free();
HRESULT hr = OleLoadPicture(pstm, 0, FALSE,
IID_IPicture, (void**)&m_spIPicture);
ASSERT(SUCCEEDED(hr) && m_spIPicture);
return TRUE;
}
//////////////////
// Render to device context. Covert to HIMETRIC for IPicture.
//
BOOL CJpg::Render(CDC* pDC, CRect rc, LPCRECT prcMFBounds) const
{
ASSERT(pDC);
if (rc.IsRectNull()) {
CSize sz = GetBitSize();
rc.right = sz.cx;
rc.bottom = sz.cy;
}
long hmWidth,hmHeight; // HIMETRIC units
GetHIMETRICSize(hmWidth, hmHeight);
m_spIPicture->Render(*pDC, rc.left, rc.top, rc.Width(), rc.Height(),
0, hmHeight, hmWidth, -hmHeight, prcMFBounds);
return TRUE;
}
BOOL CJpg::Render(HDC hdc, CRect rc, LPCRECT prcMFBounds)
{
ASSERT(hdc);
if (rc.IsRectNull()) {
CSize sz = GetBitSize();
rc.right = sz.cx;
rc.bottom = sz.cy;
}
long hmWidth,hmHeight; // HIMETRIC units
GetHIMETRICSize(hmWidth, hmHeight);
m_spIPicture->Render(hdc, rc.left, rc.top, rc.Width(), rc.Height(),
0, hmHeight, hmWidth, -hmHeight, prcMFBounds);
return TRUE;
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询