Logo en ventana con areas transparentes (Solucionado)

Logo en ventana con areas transparentes (Solucionado)

Postby RodolfoRBG » Wed Apr 06, 2011 4: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
Last edited by RodolfoRBG on Thu Apr 07, 2011 4:02 pm, edited 1 time in total.
RodolfoRBG
FWH 1307, xHarbour123 BCC582
rodolfoerbg@gmail.com
User avatar
RodolfoRBG
 
Posts: 257
Joined: Tue May 16, 2006 4:46 pm
Location: San Luis Potosi, SLP, Mexico

Re: Logo en ventana principal con areas transparentes

Postby MarioG » Wed Apr 06, 2011 2:26 pm

Rodolfo RBG (Red Blue Green?... :D )

Una forma es la siguiente:
Code: Select all  Expand view
  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
User avatar
MarioG
 
Posts: 1380
Joined: Fri Oct 14, 2005 1:28 pm
Location: Resistencia - Chaco - AR

Re: Logo en ventana principal con areas transparentes

Postby jbrita » Wed Apr 06, 2011 9: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)
jbrita
 
Posts: 486
Joined: Mon Jan 16, 2006 3:42 pm

Re: Logo en ventana principal con areas transparentes

Postby RodolfoRBG » Thu Apr 07, 2011 5: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.
Last edited by RodolfoRBG on Thu Apr 07, 2011 4:00 pm, edited 1 time in total.
RodolfoRBG
FWH 1307, xHarbour123 BCC582
rodolfoerbg@gmail.com
User avatar
RodolfoRBG
 
Posts: 257
Joined: Tue May 16, 2006 4:46 pm
Location: San Luis Potosi, SLP, Mexico

Re: Logo en ventana principal con areas transparentes

Postby Carles » Thu Apr 07, 2011 6: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
Skype -> https://join.skype.com/cnzQg3Kr1dnk
User avatar
Carles
 
Posts: 1095
Joined: Fri Feb 10, 2006 2:34 pm
Location: Barcelona

Re: Logo en ventana principal con areas transparentes

Postby anserkk » Thu Apr 07, 2011 9: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
User avatar
anserkk
 
Posts: 1329
Joined: Fri Jun 13, 2008 11:04 am
Location: Kochi, India

Re: Logo en ventana principal con areas transparentes

Postby MarioG » 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
User avatar
MarioG
 
Posts: 1380
Joined: Fri Oct 14, 2005 1:28 pm
Location: Resistencia - Chaco - AR

Re: Logo en ventana principal con areas transparentes

Postby Daniel Garcia-Gil » 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: Select all  Expand view

#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

 
User avatar
Daniel Garcia-Gil
 
Posts: 2365
Joined: Wed Nov 02, 2005 11:46 pm
Location: Isla de Margarita

Re: Logo en ventana principal con areas transparentes

Postby RodolfoRBG » Thu Apr 07, 2011 3: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
User avatar
RodolfoRBG
 
Posts: 257
Joined: Tue May 16, 2006 4:46 pm
Location: San Luis Potosi, SLP, Mexico


Return to FiveWin para Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 16 guests