Print Page | Close Window

Drawing problem

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Toolkit Pro
Forum Description: Topics Related to Codejock Toolkit Pro
URL: http://forum.codejock.com/forum_posts.asp?TID=7070
Printed Date: 12 November 2025 at 7:37pm
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: Drawing problem
Posted By: BastianPL
Subject: Drawing problem
Date 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



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.04 - http://www.webwizforums.com
Copyright ©2001-2021 Web Wiz Ltd. - https://www.webwiz.net