cnavarro wrote:Entonces subo los bmps, el cambio en el código y el .rc modificado, Ok?
IF Empty(cBmpFile3)
::hBitMap3 = Bmp2Dis( ::hBitMap1 )
ENDIF
#include <windows.h>
#include <hbapi.h>
#define ROSA RGB(255,0,255)
#define BLANCO RGB(255,255,255)
HB_FUNC( BMP2DIS )
{
HBITMAP hBmpMem, hOldBmp, hOldBmp2;
COLORREF nColor;
int nX;
int nY;
HDC hDC = CreateDC("DISPLAY", 0, 0, 0);
HDC hDCMem = CreateCompatibleDC( hDC );
HDC hDCMem2 = CreateCompatibleDC( hDC );
HBITMAP hBitmap = (HBITMAP) hb_parnl( 1 );
BITMAP bm;
GetObject( ( HGDIOBJ ) hBitmap, sizeof( BITMAP ), ( LPSTR ) &bm );
hBmpMem = CreateCompatibleBitmap( hDC, bm.bmWidth, bm.bmHeight );
hOldBmp = (HBITMAP) SelectObject( hDCMem, hBmpMem );
hOldBmp2 = (HBITMAP) SelectObject( hDCMem2, hBitmap );
BitBlt( hDCMem, 0,0,bm.bmWidth, bm.bmHeight, hDCMem2, 0, 0, SRCCOPY );
for (nX = 0; nX < bm.bmWidth ; nX++ )
{
for (nY = 0; nY < bm.bmHeight ; nY++ )
{
nColor = GetPixel( hDCMem, nX, nY );
if( nColor != ROSA && nColor!=BLANCO )
{
SetPixel( hDCMem, nX, nY, RGB( 192, 192, 192) );
}
}
}
SelectObject( hDCMem, hOldBmp );
SelectObject( hDCMem2, hOldBmp2 );
DeleteDC( hDCMem );
DeleteDC( hDCMem2 );
DeleteDC( hDC );
hb_retnl( (LONG) hBmpMem );
}
#define FUCSIA RGB(255,0,255)
#define BLANCO RGB(255,255,255)
HB_FUNC( BMP2DIS )
{
HBITMAP hBmpMem, hOldBmp, hOldBmp2;
COLORREF nColor;
int nX;
int nY;
int red,green,blue;
HDC hDC = CreateDC("DISPLAY", 0, 0, 0);
HDC hDCMem = CreateCompatibleDC( hDC );
HDC hDCMem2 = CreateCompatibleDC( hDC );
HBITMAP hBitmap = (HBITMAP) hb_parnl( 1 );
BITMAP bm;
GetObject( ( HGDIOBJ ) hBitmap, sizeof( BITMAP ), ( LPSTR ) &bm );
hBmpMem = CreateCompatibleBitmap( hDC, bm.bmWidth, bm.bmHeight );
hOldBmp = (HBITMAP) SelectObject( hDCMem, hBmpMem );
hOldBmp2 = (HBITMAP) SelectObject( hDCMem2, hBitmap );
BitBlt( hDCMem, 0,0,bm.bmWidth, bm.bmHeight, hDCMem2, 0, 0, SRCCOPY );
for (nX = 0; nX < bm.bmWidth ; nX++ )
{
for (nY = 0; nY < bm.bmHeight ; nY++ )
{
nColor = GetPixel( hDCMem, nX, nY );
if( nColor != FUCSIA && nColor!=BLANCO )
{
red = GetRValue( nColor ) ;
green = GetGValue( nColor ) ;
blue = GetBValue( nColor ) ;
nColor = (0.3 * red + 0.59 * green + 0.11 * blue + 0.5 );
SetPixel( hDCMem, nX, nY, RGB( nColor , nColor , nColor ) );
}
}
}
SelectObject( hDCMem, hOldBmp );
SelectObject( hDCMem2, hOldBmp2 );
DeleteDC( hDCMem );
DeleteDC( hDCMem2 );
DeleteDC( hDC );
hb_retnl( (LONG) hBmpMem );
}
CLASS TBtnBmp FROM TControl
....
DATA lDisableToGray INIT .t. // añadido
....
METHOD LoadBitmaps( )
.....
if ! Empty( cResName2 )
......
endif
if Empty( cResName3 ) .and. Empty( cBmpFile3 ) // añadido ...
IF ! Empty( cResName1 )
cResName3:= cResName1
endif
IF ! Empty( cBmpFile1 )
cBmpFile3:= cBmpFile1
endif
endif
if ! Empty( cResName3 )
IF FindResource( GetResources(), cResName3 , 10 ) != 0
....
ELSE
....
endif
IF ::lDisableToGray // añadido
::hBitmap3:= BMP2DIS( ::hBitmap1 )
endif
::HasAlpha( ::hBitmap3, BTN_DISABLE )
endif
.....
if ! Empty( cBmpFile3 )
if File( cBmpFile3 )
::cBmpFile3 = cBmpFile3
if Upper( Right( cBmpFile3, 3 ) ) == "PNG"
....
else
....
endif
IF ::lDisableToGray // añadido
::hBitmap3:= BMP2DIS( ::hBitmap1 )
endif
::HasAlpha( ::hBitmap3, BTN_DISABLE )
::cBmpFile3 = cBmpFile3
endif
endif
.....
#define FUCSIA RGB(255,0,255)
#define BLANCO RGB(255,255,255)
HB_FUNC( BMP2DIS )
{
HBITMAP hBmpMem, hOldBmp, hOldBmp2;
COLORREF nColor;
int nX;
int nY;
int red,green,blue;
HDC hDC = CreateDC("DISPLAY", 0, 0, 0);
HDC hDCMem = CreateCompatibleDC( hDC );
HDC hDCMem2 = CreateCompatibleDC( hDC );
HBITMAP hBitmap = (HBITMAP) hb_parnl( 1 );
BITMAP bm;
GetObject( ( HGDIOBJ ) hBitmap, sizeof( BITMAP ), ( LPSTR ) &bm );
hBmpMem = CreateCompatibleBitmap( hDC, bm.bmWidth, bm.bmHeight );
hOldBmp = (HBITMAP) SelectObject( hDCMem, hBmpMem );
hOldBmp2 = (HBITMAP) SelectObject( hDCMem2, hBitmap );
BitBlt( hDCMem, 0,0,bm.bmWidth, bm.bmHeight, hDCMem2, 0, 0, SRCCOPY );
for (nX = 0; nX < bm.bmWidth ; nX++ )
{
for (nY = 0; nY < bm.bmHeight ; nY++ )
{
nColor = GetPixel( hDCMem, nX, nY );
if( nColor != FUCSIA && nColor!=BLANCO )
{
red = GetRValue( nColor ) ;
green = GetGValue( nColor ) ;
blue = GetBValue( nColor ) ;
nColor = (0.3 * red + 0.59 * green + 0.11 * blue + 0.5 );
SetPixel( hDCMem, nX, nY, RGB( nColor , nColor , nColor ) );
}
}
}
SelectObject( hDCMem, hOldBmp );
SelectObject( hDCMem2, hOldBmp2 );
DeleteDC( hDCMem );
DeleteDC( hDCMem2 );
DeleteDC( hDC );
hb_retnl( (LONG) hBmpMem );
}
Return to EasyReport, EasyDialog y EasyPreview
Users browsing this forum: No registered users and 3 guests