#pragma BEGINDUMP
#include <windows.h>
#include <hbapi.h>
static void TransBmp( HBITMAP hBitmap, int iXsize, int iYsize,
COLORREF rgbTransparent, HDC hDC,
int iXOffset, int iYOffset, int iWidth, int iHeight )
{
HDC mDC, nDC;
HBITMAP hMask, hBmOld1, hBmOld2;
LPBYTE lpBits;
mDC = CreateCompatibleDC( hDC );
if( mDC )
{
hBmOld1 = ( HBITMAP ) SelectObject( mDC, hBitmap );
lpBits = ( LPBYTE ) hb_xgrab( iXsize * iYsize * 2 );
if( lpBits )
{
hMask = CreateBitmap( iXsize, iYsize, 1, 1, lpBits );
if( hMask )
{
nDC = CreateCompatibleDC( hDC );
if( nDC )
{
hBmOld2 = ( HBITMAP ) SelectObject( nDC, hMask );
SetBkColor( mDC, rgbTransparent );
BitBlt( nDC, 0, 0, iXsize, iYsize, mDC, 0, 0, SRCCOPY );
SetStretchBltMode( hDC, COLORONCOLOR );
StretchBlt( hDC, iXOffset, iYOffset, iWidth, iHeight,
mDC, 0, 0, iXsize, iYsize,
SRCINVERT );
StretchBlt( hDC, iXOffset, iYOffset, iWidth, iHeight,
nDC, 0, 0, iXsize, iYsize,
SRCAND );
StretchBlt( hDC, iXOffset, iYOffset, iWidth, iHeight,
mDC, 0, 0, iXsize, iYsize,
SRCINVERT );
SelectObject( nDC, hBmOld2 );
DeleteDC( nDC );
}
else
MessageBox( 0, "(1) Can't create compatible DC!", "Error", 0 );
DeleteObject( hMask );
}
else
MessageBox( 0, "(2) Can't create bitmap!", "Error", 0 );
hb_xfree( lpBits );
}
else
MessageBox( 0, "(3) Can't allocate memory!", "Error", 0 );
SelectObject( mDC, hBmOld1 );
DeleteDC( mDC );
}
else
MessageBox( 0, "(4) Can't create DC!", "Error", 0 );
}
HB_FUNC( TRANSBMP )
{
TransBmp( ( HBITMAP ) hb_parnl( 1 ), hb_parnl( 2 ), hb_parnl( 3 ), hb_parnl( 4 ),
( HDC ) hb_parnl( 5 ), hb_parnl( 6 ), hb_parnl( 7 ), hb_parnl( 8 ),
hb_parnl( 9 ) );
}
#pragma ENDDUMP
LPVOID lpMsgBuf;
FormatMessage( FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
NULL,
GetLastError(),
MAKELANGID( LANG_NEUTRAL, SUBLANG_DEFAULT ), // Default language
( LPTSTR ) &lpMsgBuf,
0,
NULL );
MessageBox( 0, lpMsgBuf, "error", 0 );
LocalFree( lpMsgBuf );
#pragma BEGINDUMP
#include <windows.h>
#include <hbapi.h>
static void TransBmp( HBITMAP hBitmap, int iXsize, int iYsize,
COLORREF rgbTransparent, HDC hDC,
int iXOffset, int iYOffset, int iWidth, int iHeight )
{
HDC mDC, nDC;
HBITMAP hMask, hBmOld1, hBmOld2;
LPBYTE lpBits;
mDC = CreateCompatibleDC( hDC );
if( mDC )
{
hBmOld1 = ( HBITMAP ) SelectObject( mDC, hBitmap );
lpBits = ( LPBYTE ) hb_xgrab( iXsize * iYsize * 2 );
if( lpBits )
{
hMask = CreateBitmap( iXsize, iYsize, 1, 1, lpBits );
if( hMask )
{
nDC = CreateCompatibleDC( hDC );
if( nDC )
{
hBmOld2 = ( HBITMAP ) SelectObject( nDC, hMask );
SetBkColor( mDC, rgbTransparent );
BitBlt( nDC, 0, 0, iXsize, iYsize, mDC, 0, 0, SRCCOPY );
SetStretchBltMode( hDC, COLORONCOLOR );
StretchBlt( hDC, iXOffset, iYOffset, iWidth, iHeight,
mDC, 0, 0, iXsize, iYsize,
SRCINVERT );
StretchBlt( hDC, iXOffset, iYOffset, iWidth, iHeight,
nDC, 0, 0, iXsize, iYsize,
SRCAND );
StretchBlt( hDC, iXOffset, iYOffset, iWidth, iHeight,
mDC, 0, 0, iXsize, iYsize,
SRCINVERT );
SelectObject( nDC, hBmOld2 );
DeleteDC( nDC );
}
else
MessageBox( 0, "(1) Can't create compatible DC!", "Error", 0 );
DeleteObject( hMask );
}
else
{
LPVOID lpMsgBuf;
FormatMessage( FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
NULL,
GetLastError(),
MAKELANGID( LANG_NEUTRAL, SUBLANG_DEFAULT ), // Default language
( LPTSTR ) &lpMsgBuf,
0,
NULL );
MessageBox( 0, lpMsgBuf, "(2) Can't create bitmap!", 0 );
LocalFree( lpMsgBuf );
}
hb_xfree( lpBits );
}
else
MessageBox( 0, "(3) Can't allocate memory!", "Error", 0 );
SelectObject( mDC, hBmOld1 );
DeleteDC( mDC );
}
else
MessageBox( 0, "(4) Can't create DC!", "Error", 0 );
}
HB_FUNC( TRANSBMP )
{
TransBmp( ( HBITMAP ) hb_parnl( 1 ), hb_parnl( 2 ), hb_parnl( 3 ), hb_parnl( 4 ),
( HDC ) hb_parnl( 5 ), hb_parnl( 6 ), hb_parnl( 7 ), hb_parnl( 8 ),
hb_parnl( 9 ) );
}
#pragma ENDDUMP
#pragma BEGINDUMP
#include <windows.h>
#include <hbapi.h>
static void TransBmp( HBITMAP hBitmap, unsigned int iXsize, unsigned int iYsize,
COLORREF rgbTransparent, HDC hDC,
int iXOffset, int iYOffset, int iWidth, int iHeight )
{
HDC mDC, nDC;
HBITMAP hMask, hBmOld1, hBmOld2;
LPBYTE lpBits;
mDC = CreateCompatibleDC( hDC );
if( mDC )
{
hBmOld1 = ( HBITMAP ) SelectObject( mDC, hBitmap );
lpBits = ( LPBYTE ) hb_xgrab( iXsize * iYsize * 2 );
if( lpBits )
{
hMask = CreateBitmap( iXsize, iYsize, 1, 1, NULL ); // lpBits );
if( hMask )
{
nDC = CreateCompatibleDC( hDC );
if( nDC )
{
hBmOld2 = ( HBITMAP ) SelectObject( nDC, hMask );
SetBkColor( mDC, rgbTransparent );
BitBlt( nDC, 0, 0, iXsize, iYsize, mDC, 0, 0, SRCCOPY );
SetStretchBltMode( hDC, COLORONCOLOR );
StretchBlt( hDC, iXOffset, iYOffset, iWidth, iHeight,
mDC, 0, 0, iXsize, iYsize,
SRCINVERT );
StretchBlt( hDC, iXOffset, iYOffset, iWidth, iHeight,
nDC, 0, 0, iXsize, iYsize,
SRCAND );
StretchBlt( hDC, iXOffset, iYOffset, iWidth, iHeight,
mDC, 0, 0, iXsize, iYsize,
SRCINVERT );
SelectObject( nDC, hBmOld2 );
DeleteDC( nDC );
}
else
MessageBox( 0, "(1) Can't create compatible DC!", "Error", 0 );
DeleteObject( hMask );
}
else
{
LPVOID lpMsgBuf;
FormatMessage( FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
NULL,
GetLastError(),
MAKELANGID( LANG_NEUTRAL, SUBLANG_DEFAULT ), // Default language
( LPTSTR ) &lpMsgBuf,
0,
NULL );
MessageBox( 0, lpMsgBuf, "(2) Can't create bitmap!", 0 );
LocalFree( lpMsgBuf );
}
hb_xfree( lpBits );
}
else
MessageBox( 0, "(3) Can't allocate memory!", "Error", 0 );
SelectObject( mDC, hBmOld1 );
DeleteDC( mDC );
}
else
MessageBox( 0, "(4) Can't create DC!", "Error", 0 );
}
HB_FUNC( TRANSBMP )
{
TransBmp( ( HBITMAP ) hb_parnl( 1 ), hb_parnl( 2 ), hb_parnl( 3 ), hb_parnl( 4 ),
( HDC ) hb_parnl( 5 ), hb_parnl( 6 ), hb_parnl( 7 ), hb_parnl( 8 ),
hb_parnl( 9 ) );
}
#pragma ENDDUMP
Antonio Linares wrote:It seems as we finally found the bug and solved it
Return to FiveWin for Harbour/xHarbour
Users browsing this forum: Google [Bot] and 53 guests