Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Toolkit Pro
  New Posts New Posts RSS Feed - Drawing problem
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Drawing problem

 Post Reply Post Reply
Author
Message
BastianPL View Drop Down
Groupie
Groupie
Avatar

Joined: 15 April 2006
Status: Offline
Points: 69
Post Options Post Options   Thanks (0) Thanks(0)   Quote BastianPL Quote  Post ReplyReply Direct Link To This Post Topic: Drawing problem
    Posted: 07 May 2007 at 4:06pm
Hi again. I have a new problem with XTP Controls. I am drawing some images in gallery control on fly. My code is:
 
 

CBitmap bmpSrc;

bmpSrc.Attach( hBitmap );

item.pPopupBitmap->Attach( CXTPImageManager::Create32BPPDIBSection( 0, m_nPopupWidth, m_nPopupHeight + m_nCaptionHeight ) );

CXTPCompatibleDC dcSrc( 0, &bmpSrc );

CXTPCompatibleDC *pdcDest = new CXTPCompatibleDC( 0, item.pPopupBitmap );

BITMAP bmpInfo;

ZeroMemory( &bmpInfo, sizeof( BITMAP ) );

bmpSrc.GetBitmap( &bmpInfo );

int nWidth = bmpInfo.bmWidth;

int nHeight = bmpInfo.bmHeight;

if ( nWidth > m_nPopupWidth )

{

float fAspectRatio = (float)nWidth / (float)m_nPopupWidth;

nWidth = m_nPopupWidth;

nHeight = (int)( ( (float)nHeight / fAspectRatio ) + 0.5f );

}

if ( nHeight > m_nPopupHeight )

{

float fAspectRatio = (float)nHeight / (float)m_nPopupHeight;

nHeight = m_nPopupHeight;

nWidth = (int)( ( (float)nWidth / fAspectRatio ) + 0.5f );

}

int nX = ( m_nPopupWidth - nWidth ) / 2;

int nY = ( m_nPopupHeight - nHeight ) / 2;

// clear thumbnail

pdcDest->FillSolidRect( 0, 0, m_nPopupWidth, m_nPopupHeight, RGB( 252, 252, 252 ) );

// draw thumbnail

// delete pdcDest;

// pdcDest = new CXTPCompatibleDC( NULL, item.pPopupBitmap );

pdcDest->SetStretchBltMode( HALFTONE );

pdcDest->StretchBlt( nX + 1, nY + 1, nWidth - 2, nHeight - 2, &dcSrc, 0, 0, bmpInfo.bmWidth, bmpInfo.bmHeight, SRCCOPY );

// draw pre-cut paper icon

ImagePreCutPaper.DrawImage( pdcDest, nWidth - 64, nHeight - 38, 64, 38 );

 
ImagePreCutPaper.DrawImage has following body:
 

ASSERT( pDC != NULL );

ASSERT( m_hBitmap != NULL );

// draw bitmap

CXTPImageManagerIcon::DrawAlphaBitmap( pDC, m_hBitmap, CPoint( nX, nY ), CSize( nWidth, nHeight ), CPoint( 0, 0 ), GetImageSize() );

 
 
Unfortunettly when i call this line my oryginal image disappears i see only new image but in fact i want to draw this new image over old image.
Everything works fine until I call this line.
 
 
Thanks for any help
Bastian
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.04
Copyright ©2001-2021 Web Wiz Ltd.

This page was generated in 0.047 seconds.