|
|
CDC或CBitmap的尺寸有上限??
我建立一??CDC的??=5400,高=4320,然後?⒁??CImge(file.png 600x480)?到我建立的CDC上
我??了一段?y?程式如下,????DC的每??pixel?Υ嫫?磲?每??pixel都是黑色的
可是我如果建立一??CDC(??=600*8,高=480*8)的?,??Image(file.png)也?到???CDC上,a.bmp的?果是正?的.所以我在想CDC或CBitmap是不是有一?????
int nTmpWidth,nTmpHeight;
nTmpWidth=BACK_BUFFER_WIDTH*nGridScale;
nTmpHeight=BACK_BUFFER_HEIGHT*nGridScale;
CSize GridSize=m_GridSetBar.GetGridSize();
HRESULT hr;
CAppGDI tmpGDI;
WCHAR szFilename[MAX_PATH];
wsprintf(szFilename,L"%s\\%s\\%s",m_pMainFrame->GetWorkingDirectory(),WRK_DIR_TMP,L"file.png");
m_ImageBG.Destroy();
hr=m_ImageBG.Load(szFilename);
int nBPP_image;
nBPP_image=m_ImageBG.GetBPP();
tmpGDI.CreateAppDC(this,nTmpWidth,nTmpHeight);
BOOL b=m_ImageBG.Draw(tmpGDI.GetDC()->m_hDC,0,0,nTmpWidth,nTmpHeight);
{
CImage testImage;
testImage.Create(nTmpWidth,nTmpHeight,nBPP_image,1);
//BOOL c=StretchBlt(tmpGDI.GetDC()->m_hDC,0,0,nTmpWidth,nTmpHeight,m_ImageBG.GetDC(),0,0,m_ImageBG.GetWidth(),m_ImageBG.GetHeight(),SRCCOPY);
COLORREF color_ref;
for (int y=0;y<nTmpHeight;y++)
{
for (int x=0;x<nTmpWidth;x++)
{
color_ref=tmpGDI.GetDC()->GetPixel(x,y);
stColor tmpColor;
tmpColor.SetColor(color_ref);
BYTE* byte_mix=(BYTE*)testImage.GetPixelAddress(x,y);
*(byte_mix+0)=(BYTE)tmpColor.b;//127 blue
*(byte_mix+1)=(BYTE)tmpColor.g;//126 green
*(byte_mix+2)=(BYTE)tmpColor.r;//125 red
*(byte_mix+3)=255;//255 alpha
}
}
HRESULT hr;
hr=testImage.Save(L"a.bmp",Gdiplus::ImageFormatBMP);
return ;
}
void CAppGDI::CreateAppDC(CWnd* pWnd,int nWidth,int nHeight)
{
m_nWidth=nWidth;
m_nHeight=nHeight;
CClientDC adc(pWnd);
m_pBufferDC=new CDC;
m_pBufferDC->CreateCompatibleDC(&adc);
m_pTempBmp=new CBitmap;
m_pTempBmp->CreateCompatibleBitmap(&adc,m_nWidth,m_nHeight);
m_pBufferDC->SelectObject(m_pTempBmp);
} |
|