I use wxBufferedPaintDC to draw the big image ,the image size is larger than 10000*5000,I divide the image to blocks,when the image loaded,the blocks size is small(500*500),and then I use a wxBitmap vector to store the blocks.
In OnPaint , I draw block by block, the following is the code what I use, My question is that,
why all the blocks can not be shown in the machine which has 1024M physical memory. but the machine which has 2048M physical memory.
My code:
Divide the pImg;
Code: Select all
m_IsBitmapVectorOK = false;
m_numOfBlocks.x = (int) ceil(pImg->GetWidth()/(float)BLOCKSIZEWIDTH);
m_numOfBlocks.y = (int) ceil(pImg->GetHeight()/(float)BLOCKSIZEHEIGHT);
if (m_vecBitmap.begin()!=m_vecBitmap.end())
{
m_vecBitmap.clear();
}
int index = 0;
for(int j=0;j!=m_numOfBlocks.y;j++)
{
for(int i=0;i!=m_numOfBlocks.x;i++)
{
{
wxImage subImg = pImg->GetSubImage(wxRect( i*BLOCKSIZEWIDTH,
j*BLOCKSIZEHEIGHT,
i==m_numOfBlocks.x-1?m_nOrigWidth-i*BLOCKSIZEWIDTH:BLOCKSIZEWIDTH,
j==m_numOfBlocks.y-1?m_nOrigHeight-j*BLOCKSIZEHEIGHT:BLOCKSIZEHEIGHT));
if (!subImg.IsOk())
{
return false;
}
m_vecBitmap.push_back( wxBitmap(subImg) );
index++;
}
}
}
m_IsBitmapVectorOK = true;
Code: Select all
wxPaintDC dc(this);
wxBufferedDC bufferDc(&dc);
wxMemoryDC memDc;
bufferDc.SetBackground(wxColour(218,218,218));
bufferDc.Clear();
int index = 0;
if (m_IsBitmapVectorOK)
{
bufferDc.DestroyClippingRegion();
bufferDc.SetClippingRegion(wxPoint(0,0),GetClientSize());
for(int j=0;j<m_numOfBlocks.y;j++)
{
for(int i=0;i<m_numOfBlocks.x;i++)
{
{
memDc.SelectObject( m_vecBitmap.at(index) );
bufferDc.SetUserScale( m_dZoomFactor,m_dZoomFactor );
wxPoint pt = wxPoint(
i*BLOCKSIZEWIDTH, //BLOCKSIZEWIDTH is 500
j*BLOCKSIZEHEIGHT //BLOCKSIZEHEIGHT is 500
);
bufferDc.Blit(pt,
wxSize(m_vecBitmap.at(index).GetWidth(),m_vecBitmap.at(index).GetHeight()),
&memDc,
wxPoint(0,0),
wxCOPY);
bufferDc.SetUserScale( 1.0,1.0 );
memDc.SelectObjectAsSource(wxNullBitmap);
}
index++;
}
}
}
first:
Code: Select all
wxBufferedPaintDC bufferDc(this); // when repleace the wxBufferedPaintDC with wxPaintDC ,it will Display all the blocks too, but Flicker
to use the compute which has more physical memory.
I want to know why? Is the bufferDc question?
thanks for all the reply!!