Page 1 of 1

BITMAP NO TRANSPARENT

PostPosted: Wed Feb 24, 2010 4:34 pm
by Silvio
I HAVE A BITMAP

@ 10,10 BITMAP filename "test.bmp" SIZE 64,64 DESIGN

i MUST MOVE THIS BITMAP ON A WINDOW WITH DRAWGRID FUNCTION

THIS BITMAP IS NOT TRANSPARENT AND WHEN i MOVE IT COPY THE BACKGROUND ON NEW POSITION


HOW i CAN TO MOVE THIS BITMAP ON MODE TRANSPARENT ON THIS WINDOW ?


THE SIMPLY CODE

Code: Select all  Expand view
#include "fivewin.ch"

FUNCTION main()
LOCAL oWnd ,oBmp

DEFINE window oWnd FROM 10,10 TO 80,80

@ 10,10 BITMAP oBmp  filename "C:\FWH\bitmaps\32x32\plus.bmp" DESIGN    SIZE 64,64

              oBmp:ltransparent:=.t.

ACTIVATE window oWnd ON PAINT DRAWGRID( oWnd:hWnd, oWnd:hdc, 1, 30, 30 )

RETURN NIL

#pragma BEGINDUMP

#include <Windows.h>
#include <HbApi.h>

//----------------------------------------------------------------------------//

HB_FUNC( DRAWGRID ) // hWnd, hDC, @cPS, wGridX, wGridY
{
   WORD wRow, wCol;
   HDC hDC = ( HDC ) hb_parnl( 2 );
   PAINTSTRUCT * ps = ( PAINTSTRUCT * ) hb_parc( 3 );
   WORD wGridX = hb_parni( 4 );
   WORD wGridY = hb_parni( 5 );
   RECT rc;
   WORD wWidth, wHeight;
   
   HPEN hOldPen;
   HPEN hGray   = CreatePen( PS_SOLID, 0, RGB( 210, 210, 210 ) );
   HPEN hGray2  = CreatePen( PS_SOLID, 0, RGB( 230, 230, 230 ) );
   
   hOldPen = ( HPEN ) SelectObject( hDC, hGray );

   GetWindowRect( ( HWND ) hb_parnl( 1 ), &rc );
   wWidth  = rc.right - rc.left + 1;
   wHeight = rc.bottom - rc.top + 1;

   for( wRow = 0; wRow <= wHeight; wRow += wGridX )
    {
        MoveTo( hDC, 0, wRow );
        LineTo( hDC, wWidth, wRow ) ;
    }
     
   for( wCol = 0; wCol <= wWidth; wCol += wGridY )
    {
        MoveTo( hDC, wCol, 0 );
        LineTo( hDC, wCol, wHeight ) ;
    }

   SelectObject( hDC, hGray2 );

   for( wRow = wGridX/2; wRow <= wHeight; wRow += wGridX )
    {
        MoveTo( hDC, 0, wRow );
        LineTo( hDC, wWidth, wRow ) ;
    }
     
   for( wCol = wGridY/2; wCol <= wWidth; wCol += wGridY )
    {
        MoveTo( hDC, wCol, 0 );
        LineTo( hDC, wCol, wHeight ) ;
    }
     
   SelectObject( hDC, hOldPen );
   DeleteObject( hGray );
   DeleteObject( hGray2);

         //SetPixel( hDC, wCol, wRow, 0 );
}

//----------------------------------------------------------------------------//

#pragma ENDDUM

Re: BITMAP NO TRANSPARENT

PostPosted: Wed Feb 24, 2010 8:51 pm
by Daniel Garcia-Gil
Hello silvio

i will explain you...

1.- the current bitmap was alpha channel with white background, you can use this bitmap...
Image http://www.sitasoft.com/fivewin/bitmap/plus2.bmp

2.- the transparent in all controls come from the parent brush no from image background.
example:

Image http://www.sitasoft.com/fivewin/bitmap/grid.bmp

Code: Select all  Expand view

#include "fivewin.ch"

FUNCTION main()
LOCAL oWnd ,oBmp

LOCAL oBrush

DEFINE BRUSH oBrush FILE "GRID.bmp"

DEFINE window oWnd FROM 10,10 TO 80,80 BRUSH oBrush

@ 10,10 BITMAP oBmp  filename "C:\FWH\bitmaps\32x32\plus2.bmp" SIZE 64, 64 ADJUST TRANSPARENT NOBORDER

ACTIVATE window oWnd

RETURN NIL
 


3.- If you want move the bitmap around the window until the brush will be useless and will need paint the bitmap "with the hand" with transparencies techniques (seek in google about that) maybe bitblt function (http://msdn.microsoft.com/en-us/library/dd183370(VS.85).aspx) can help you, i don't know how do that

Re: BITMAP NO TRANSPARENT

PostPosted: Wed Feb 24, 2010 8:59 pm
by Silvio
SAME ERROR

WHEN YOU USE DESIGN COMMAND TO MOVE THE BITMAP

IT COPY THE OLD BACKGROUND INTO NEW POSITION

Re: BITMAP NO TRANSPARENT

PostPosted: Wed Feb 24, 2010 9:43 pm
by Daniel Garcia-Gil
Silvio

Daniel Garcia-Gil wrote:3.- If you want move the bitmap around the window until the brush will be useless and will need paint the bitmap "with the hand" with transparencies techniques (seek in google about that) maybe bitblt function (http://msdn.microsoft.com/en-us/library/dd183370(VS.85).aspx) can help you, i don't know how do that

Re: BITMAP NO TRANSPARENT

PostPosted: Thu Feb 25, 2010 7:49 am
by Silvio
this is strange....

With the fivewin power why not we cannot move a bitmap transparent into a window with drawgrid ?

I think we Not Know how make but i think and believe it can be done with the fivewin power language

Re: BITMAP NO TRANSPARENT

PostPosted: Thu Feb 25, 2010 11:47 am
by Daniel Garcia-Gil
Silvio

it isn't strange...

Silvio wrote:With the fivewin power why not we cannot move a bitmap transparent into a window with drawgrid ?

yes, and already you do that, but with the Windows OS standar features

FiveWin uses standard windows OS controls and other controls themselves, all controls created a "window".

The standard Windows OS feature, to create a window, only supports transparencies with brush, FiveWin added design mode for a more comprehensive management controls, but can not escape from the Windows OS features.

To do what you want, you can not use a normal control, you have to directly use the bitmap handle

Re: BITMAP NO TRANSPARENT

PostPosted: Thu Feb 25, 2010 1:02 pm
by Daniel Garcia-Gil
Silvio

i found a possible solution... but you need the brush, same my last example

in CONTROL.PRG, method LButtonUp
LOCATE
Code: Select all  Expand view

if Empty( ::nMResize )
            ::Move( ::nTop + nRow - nMRow, ::nLeft + nCol - nMCol,,, .t. )
 


ADD AFTER
Code: Select all  Expand view
::Refresh()


http://www.sitasoft.com/fivewin/test/trans.zip
Code: Select all  Expand view

#include "fivewin.ch"

FUNCTION main()
   LOCAL oWnd ,oBmp
   LOCAL oBrush
   
   DEFINE BRUSH oBrush FILE "grid.bmp"
   
   DEFINE WINDOW oWnd FROM 10,10 TO 400, 400 PIXEL BRUSH oBrush
   
   @ 10,10 BITMAP oBmp  filename "plus2.bmp" SIZE 64, 64 ADJUST TRANSPARENT NOBORDER DESIGN
   
   ACTIVATE window oWnd

RETURN NIL