FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin para Harbour/xHarbour Logo en ventana con areas transparentes (Solucionado)
Posts: 257
Joined: Tue May 16, 2006 04:46 PM
Logo en ventana con areas transparentes (Solucionado)
Posted: Wed Apr 06, 2011 04:38 AM

Hola foro,

Deseo que el fondo de la ventana principal sea de un color degradado (de azul claro a azul oscuro) y colocar encima un logo en que las areas de color blanco sean transparentes.

1.- Es eso posible?
2.- Que tipo de archivo debe ser el logo? Gif? Png? Jpg?
3.- Podrian darme un ejemplo?

'chas gracias de antemano

RodolfoRBG
FWH 1307, xHarbour123 BCC582
rodolfoerbg@gmail.com
Posts: 1380
Joined: Fri Oct 14, 2005 01:28 PM
Re: Logo en ventana principal con areas transparentes
Posted: Wed Apr 06, 2011 02:26 PM
Rodolfo RBG (Red Blue Green?... :-) )

Una forma es la siguiente:
Code (fw): Select all Collapse
   DEFINE WINDOW soWnd0 ;
 ...
   soWnd0:bPainted:= {|hDC| SetLogo( hDC, oConxFTP ) }

   ACTIVATE WINDOW soWnd0
...

static procedure SetLogo( hDC, oConxFTP )
local oImg, ;
      cLogo:= BeforAtNum( "\", SubStr(  oConxFTP:cPathDbf,3 ) ) +"\bmp\SiGeCo_iGO32.jpg"

  oImg:= TImage():Define( , cLogo )

  PalBmpDraw( hDC, (soWnd0:nHeight-oImg:nHeight ) /3, soSplit:nFirst+( soSplit:nLast-oImg:nWidth) /2, oImg:hBitmap,, oImg:nWidth, oImg:nHeight,, TRUE )


Donde BeforeAtNum(), no es relevante, es una funcion de xHarbour que la uso para definir el path
PalBmpDrw() es de FW y puedes ver sus parámetros en el Help

Como verás uso jpg, y acepta bmp por supuesto. No probe con png

Saludos

P.D.: Espero q no te moleste mi humor inicial
Resistencia - "Ciudad de las Esculturas"

Chaco - Argentina
Posts: 537
Joined: Mon Jan 16, 2006 03:42 PM
Re: Logo en ventana principal con areas transparentes
Posted: Wed Apr 06, 2011 09:44 PM

Prueba asi
cSyst:="SISTEMA"
ACTIVATE WINDOW oVentPrinc MAXIMIZED;
ON PAINT Refr_Bmp(hDC,oBmp)
SET RESOURCES TO // Desactivamos los recursos definidos.

RETURN( NIL )

STAT FUNC Refr_Bmp(hDC,oBmp)
LOCAL aRect, hWnd, nColor:=255
LOCAL oBrush, nSteps, nI,n
local nBlue := 200

IF lInit
aRect:=GetCoors(GetDeskTopWindow()) // Coordenadas de ventana
IF aRect[3]>=768 // si > 600x800 la centra
aRect[1]:=(aRect[3]-580)/2
aRect[2]:=(aRect[4]-800)/2
aRect[3]:=580
aRect[4]:=800
oVentPrinc:Move(aRect[1],aRect[2],aRect[4],aRect[3])
ELSE
oVentPrinc:Maximize()
ENDIF
lInit:=.F.
ENDIF
hWnd :=oVentPrinc:hWnd
aRect :=GetClientRect(hWnd)
nSteps:=(aRect[3]-aRect[1])/3
aRect[3]=0

for n = 1 to nSteps

  aRect[ 3 ] += 3

  DEFINE BRUSH oBrush COLOR RGB( 0, 0, nBlue )
  FillRect(hDC,aRect,oBrush:hBrush)
  RELEASE BRUSH oBrush

  aRect[ 1 ] += 3
  nBlue -= 1

next

IF oBmp<>NIL // pinta bmp
PalBmpDraw(hDC,;
(oVentPrinc:nHeight()/2)-(oBmp:nHeight()/2)-50, ;
(oVentPrinc:nWidth() /2)-(oBmp:nWidth() /2),oBmp:hBitmap,oBmp:hPalette)
ENDIF
SetBkMode(hDC,1)
SetTextColor(hDC,CLR_WHITE)
DrawText(hDC,cSyst,{oVentPrinc:nHeight-130,oVentPrinc:nWidth-120,oVentPrinc:nHeight-10,oVentPrinc:nWidth-10})
RETURN (NIL)

Posts: 257
Joined: Tue May 16, 2006 04:46 PM
Re: Logo en ventana principal con areas transparentes
Posted: Thu Apr 07, 2011 05:14 AM

Don MarioG, (jejeje) por supuesto que no hay molestia en tu broma, el buen humor siempre debe ser parte del trabajo, por cierto, son mis apellidos (Rodriguez-Borjas Garza).

En el ejemplo que me envias me marca un error en la variable soSplit y no se a que hace referencia por lo que no lo pude probar.


jBrita:

Tu ejemplo en cuanto al fondo de la ventana con color degradado y colocar el logo (BMP) en el centro funciona perfecto, solo me falta que las areas color blanco quedaran transparentes de forma que en lugar de blanco apareciera el fondo de la ventana.

Estoy usando un BMP pero no se si eso se logra con un JPG, GIF u algun otro tipo de archivo y/o si hay que indicarle al sistema que haga transparente lo que esta en color blanco, espero haberme explicado.

RodolfoRBG
FWH 1307, xHarbour123 BCC582
rodolfoerbg@gmail.com
Posts: 1283
Joined: Fri Feb 10, 2006 02:34 PM
Re: Logo en ventana principal con areas transparentes
Posted: Thu Apr 07, 2011 06:45 AM

Rodolfo,

FWDbg->Help->About

Salutacions, saludos, regards

"...programar es fácil, hacer programas es difícil..."

UT Page -> https://carles9000.github.io/
Forum UT -> https://discord.gg/bq8a9yGMWh
HIX -> https://github.com/carles9000/hix
Posts: 1335
Joined: Fri Jun 13, 2008 11:04 AM
Re: Logo en ventana principal con areas transparentes
Posted: Thu Apr 07, 2011 09:40 AM
You may use an Alpha Bitmap as your logo file.

To Convert your logo to Alpha Bitmap.
Open your Logo image using PixelFormer (Freeware) OR IcoFx( Freeware) and use the transparent tool. Using the transparent tool, you should wipe out the white color from your logo. Where ever you need the image need to be transparent, you need to use the transparent tool to wipe out.

Save the image as an Alpha Channel bitmap and then use it in your application. If you search the English forum you will find many useful tips provided by Mr.Uwe.

Try this file
http://rapidshare.com/files/456291412/Alpha_Anser.bmp

Regards
Anser
Posts: 1380
Joined: Fri Oct 14, 2005 01:28 PM
Re: Logo en ventana principal con areas transparentes
Posted: Thu Apr 07, 2011 10:17 AM

Rodolfo;
se me escapo comentar que:
soWnd0 es la variable objeto de mi ventana
soSplit es la variable objeto de un splitter que incluye la ventana (no es relevante para tu caso)

PalBmpDraw( hDC, (soWnd0:nHeight-oImg:nHeight ) /3, soSplit:nFirst+( soSplit:nLast-oImg:nWidth) /2, oImg:hBitmap,, oImg:nWidth, oImg:nHeight,, TRUE )

Para tu caso,guiate por la ayuda de la funcion:
Syntax:

PalBmpDraw( <hDC>, <nRow>, <nCol>, <hBitmap>, <hPalette>, <nWidth>, <nHeight>, <nRaster>, <lTransparent>, <nClrPane> ) --> nil

Parameters:

<hDC> Identifies the window device context.
<nRow>, <nCol> The coordinates where to display the bitmap. Expressed in pixels unless there is an alternative SetMapMode() selected.
<hBitmap>, <hPalette> The bitmap handles. These handles are automatically generated by the FiveWin functions:

PalBmpRead( <hDC>, <cBmpFileName> ) --> <aPalBmp>

PalBmpLoad( <hDC>, <cBmpResName> ) --> <aPalBmp>

And destroyed calling:

PalBmpFree( <hBitmap>, <hPalette> )

These functions are automatically called from TBitmap Class.

<nWidth> The target dimensions for the dipplayed bitmap.
<nHeight> By tdefault the own bitmap dimensions are used.

Saludos

Resistencia - "Ciudad de las Esculturas"

Chaco - Argentina
Posts: 2365
Joined: Wed Nov 02, 2005 11:46 PM
Re: Logo en ventana principal con areas transparentes
Posted: Thu Apr 07, 2011 10:32 AM
Rodolfo


puedes usar la funcion TransBMP, a esta le indicas el color que deseas transparente y todas las areas del bitmap que tengan ese color seran transparentes... usando un poco el codigo de Mario te dejo un ejemplo

http://wiki.fivetechsoft.com/doku.php?id=fivewin_funcion_transbmp

Code (fw): Select all Collapse
#include "fivewin.ch"

function main

  local oImg := TImage():Define( , "img.bmp" )
  local soWnd0

  DEFINE WINDOW soWnd0 

   soWnd0:bPainted:= {|hDC| SetLogo( hDC, oImg, soWnd0 ) }

   ACTIVATE WINDOW soWnd0
   
   oImg:End()

return nil

static procedure SetLogo( hDC, oImg, soWnd0 )
  
  TransBmp( oImg:hBitmap, oImg:nWidth, oImg:nHeight, CLR_WHITE , hDC, oImg:nWidth /2, (soWnd0:nHeight-oImg:nHeight ) /3, oImg:nWidth, oImg:nHeight )
  
return nil
Posts: 257
Joined: Tue May 16, 2006 04:46 PM
Re: Logo en ventana principal con areas transparentes
Posted: Thu Apr 07, 2011 03:01 PM

A todos, 'chas gracias por sus aportaciones y con ellas ya logre lo que deseaba. Aprendi a usar la funcion TransBmp() que desconocia (Gracias Daniel) ademas de que no sabia que existia el sitio WiKi de FWH que en el futuro sera muy consultado de mi parte.

RodolfoRBG
FWH 1307, xHarbour123 BCC582
rodolfoerbg@gmail.com

Continue the discussion