EDN Admin
Well-known member
<span id="_ctl0_MainContent_PostFlatView <span> Hello,
I am trying to use a CBitmap that is quite a bit larger than the DC
on the Windows Mobile device I am using. As a test, I am blitting this
CBitmap black and then copying it to the buffer DC using an
intermediary DC. However, it is not working. I cannot for the life of
me figure out what is going on!
Here is the code (all the calculations are correct going into the BitBlts):
<font size=2>
</font> <font size=2>RECT screen;</font>
<font size=2>GetClientRect(&screen);</font>
<font color="#0000ff" size=2>int</font><font size=2> bufferWidth = screen.right*Minotour::Constants::BUFFER_SIZEFACTOR;</font>
<font color="#0000ff" size=2>int</font><font size=2> bufferHeight = screen.bottom*Minotour::Constants::BUFFER_SIZEFACTOR;</font>
<font size=2> </font>
<font size=2>CDC* tempDC = </font><font color="#0000ff" size=2>new</font><font size=2> CDC();</font>
<font size=2>tempDC->CreateCompatibleDC(readyBuffer);</font>
<font size=2>CBitmap* test = </font><font color="#0000ff" size=2>new</font><font size=2> CBitmap(); test->CreateCompatibleBitmap(readyBuffer,bufferWidth,bufferHeight);</font>
<font size=2>CBitmap* oldBitmap = tempDC->SelectObject(test);</font>
<font color="#008000" size=2>// use tempDC as window from which to draw onto readyBuffer</font> <font size=2>
</font> <font color="#0000ff" size=2>double</font><font size=2> x = currentExtent->getCenterX();</font>
<font color="#0000ff" size=2>double</font><font size=2> y = currentExtent->getCenterY();</font>
<font color="#0000ff" size=2>double</font><font size=2> percentFromLeft = (x - bufferExtent->getXMin() - currentExtent->getWidth()/2)/bufferExtent->getWidth();</font>
<font color="#0000ff" size=2>double</font><font size=2> percentFromBottom = ( y - bufferExtent->getYMin() - currentExtent->getHeight()/2) / bufferExtent->getHeight();</font>
<font color="#0000ff" size=2>int</font><font size=2> pxFromLeft = MapalesterAPI2::round(percentFromLeft*bufferWidth);</font>
<font color="#0000ff" size=2>int</font><font size=2> pxFromTop = bufferHeight-MapalesterAPI2::round(percentFromBottom*bufferHeight);</font>
<font size=2>VERIFY(tempDC->BitBlt(0,0,bufferWidth, bufferHeight, NULL, 0, 0, BLACKNESS));</font>
<font color="#008000" size=2>//confirmed to wr</font> <font size=2>
VERIFY(readyBuffer->BitBlt(0,0,screen.right,screen.bottom,tempDC, pxFromLeft, pxFromTop, SRCCOPY));
}
<font face="Tahoma,Helvetica,Sans-Serif" size=3>Any help would be much appreciated!</font>
<font face=Tahoma size=3>Thanks!</font>
<font face=Tahoma size=3>-Brent</font> </font>
View the full article
I am trying to use a CBitmap that is quite a bit larger than the DC
on the Windows Mobile device I am using. As a test, I am blitting this
CBitmap black and then copying it to the buffer DC using an
intermediary DC. However, it is not working. I cannot for the life of
me figure out what is going on!
Here is the code (all the calculations are correct going into the BitBlts):
<font size=2>
</font> <font size=2>RECT screen;</font>
<font size=2>GetClientRect(&screen);</font>
<font color="#0000ff" size=2>int</font><font size=2> bufferWidth = screen.right*Minotour::Constants::BUFFER_SIZEFACTOR;</font>
<font color="#0000ff" size=2>int</font><font size=2> bufferHeight = screen.bottom*Minotour::Constants::BUFFER_SIZEFACTOR;</font>
<font size=2> </font>
<font size=2>CDC* tempDC = </font><font color="#0000ff" size=2>new</font><font size=2> CDC();</font>
<font size=2>tempDC->CreateCompatibleDC(readyBuffer);</font>
<font size=2>CBitmap* test = </font><font color="#0000ff" size=2>new</font><font size=2> CBitmap(); test->CreateCompatibleBitmap(readyBuffer,bufferWidth,bufferHeight);</font>
<font size=2>CBitmap* oldBitmap = tempDC->SelectObject(test);</font>
<font color="#008000" size=2>// use tempDC as window from which to draw onto readyBuffer</font> <font size=2>
</font> <font color="#0000ff" size=2>double</font><font size=2> x = currentExtent->getCenterX();</font>
<font color="#0000ff" size=2>double</font><font size=2> y = currentExtent->getCenterY();</font>
<font color="#0000ff" size=2>double</font><font size=2> percentFromLeft = (x - bufferExtent->getXMin() - currentExtent->getWidth()/2)/bufferExtent->getWidth();</font>
<font color="#0000ff" size=2>double</font><font size=2> percentFromBottom = ( y - bufferExtent->getYMin() - currentExtent->getHeight()/2) / bufferExtent->getHeight();</font>
<font color="#0000ff" size=2>int</font><font size=2> pxFromLeft = MapalesterAPI2::round(percentFromLeft*bufferWidth);</font>
<font color="#0000ff" size=2>int</font><font size=2> pxFromTop = bufferHeight-MapalesterAPI2::round(percentFromBottom*bufferHeight);</font>
<font size=2>VERIFY(tempDC->BitBlt(0,0,bufferWidth, bufferHeight, NULL, 0, 0, BLACKNESS));</font>
<font color="#008000" size=2>//confirmed to wr</font> <font size=2>
VERIFY(readyBuffer->BitBlt(0,0,screen.right,screen.bottom,tempDC, pxFromLeft, pxFromTop, SRCCOPY));
}
<font face="Tahoma,Helvetica,Sans-Serif" size=3>Any help would be much appreciated!</font>
<font face=Tahoma size=3>Thanks!</font>
<font face=Tahoma size=3>-Brent</font> </font>
View the full article