From: Starscream on
I'm stuck with getting CBitmap object from HDC.
I'm using ecw SDK to view ecw files, and I need my soft to return
CBitmap object of this .ecw file.
in SDK there is a method:

DrawImage( HDC DeviceContext, LPRECT pClipRect, IEEE8 dWorldTLX, IEEE8
dWorldTLY, IEEE8 dWorldBRX, IEEE8 dWorldBRY );

wich works just fine, it draws picture into givet device context.

DrawImage(hdc, &m_Rect, m_dTLX, m_dTLY, m_dBRX, m_dBRY);
CBitmap bitmap;
CBitmap * bmp=bitmap.FromHandle((HBITMAP)hdc);

is this right?? if DrawImage method drawed picture into HDC already?.
From: Joseph M. Newcomer on
If you have an HDC, and it has a bitmap selected into it, you can call the
CDC::GetCurrentBitmap method.

If you have an HBITMAP, you can create a CBitmap object from it by doing

HBITMAP bmp;
.....get handle to bitmap

CBitmap * result = CBitmap::FromHande(bmp);

But what you wrote will treat the handle to the DC AS IF it were a handle to a bitmap,
which it is not. Therefore, that code cannot work.
joe

On Mon, 26 May 2008 03:10:52 -0700 (PDT), Starscream <dima.petchonkin(a)gmail.com> wrote:

>I'm stuck with getting CBitmap object from HDC.
>I'm using ecw SDK to view ecw files, and I need my soft to return
>CBitmap object of this .ecw file.
>in SDK there is a method:
>
>DrawImage( HDC DeviceContext, LPRECT pClipRect, IEEE8 dWorldTLX, IEEE8
>dWorldTLY, IEEE8 dWorldBRX, IEEE8 dWorldBRY );
>
>wich works just fine, it draws picture into givet device context.
>
>DrawImage(hdc, &m_Rect, m_dTLX, m_dTLY, m_dBRX, m_dBRY);
>CBitmap bitmap;
>CBitmap * bmp=bitmap.FromHandle((HBITMAP)hdc);
>
>is this right?? if DrawImage method drawed picture into HDC already?.
Joseph M. Newcomer [MVP]
email: newcomer(a)flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm