Page 1 of 1

Put PNG image with an alpha channel on a Button

Posted: Thu Mar 30, 2023 6:57 pm
by gfilatov
Hi,

I was looking for a way to show the PNG images with an alpha channel on a Button control.

And I figured out how to do it.

The following image shows the result in MiniguiEx:
capture1.png
capture1.png (73.55 KiB) Viewed 55855 times
And how it is showed in HMG 3.4.4 with the same PRG source:
capture2.png
capture2.png (68.29 KiB) Viewed 55855 times
Your feedback is welcome 8-)

Re: Put PNG image with an alpha channel on a Button

Posted: Thu Mar 30, 2023 10:05 pm
by jorge_rivero
Envia el ejemplo
Gracias

Re: Put PNG image with an alpha channel on a Button

Posted: Fri Mar 31, 2023 7:05 am
by gfilatov
jorge_rivero wrote: Thu Mar 30, 2023 10:05 pm Envia el ejemplo
Gracias
Hello Jorge,

Thanks for your interest ;)

My hugs to Argentina from Ukraine.

The sample source code is below:

Code: Select all

/*
 * MINIGUI - Harbour Win32 GUI library
*/

#include "hmg.ch"

FUNCTION Main()

   LOCAL aBtn, n
   LOCAL cPngPath := ".\images\"
   LOCAL aPng := {}

   AEval( { 3, 1, 2, 6, 7, 8, 9, 10 }, {| c | ;
      AAdd( aPng, cPngPath + "image" + hb_ntos( c ) + ".png" ) } )

   aBtn := Array( Len( aPng ) )

   DEFINE WINDOW Form_1 ;
         AT 0, 0 ;
         WIDTH 80 + 70 * Len( aPng ) ;
         HEIGHT 430 ;
         MAIN ;
         TITLE 'Disabled Buttons Test' ;
         NOSIZE ;
         NOMAXIMIZE

      @ 40, 40 LABEL Lbl_1 VALUE "ENABLED BUTTONS NORMAL LOOK" AUTOSIZE

      FOR n := 1 TO Len( aPng )

         aBtn[ n ] := "Btn1_" + hb_ntos( n )

         DEFINE BUTTON &( aBtn[ n ] )
            ROW 70
            COL n * 70 - 30
            ACTION NIL
            PICTURE aPng[ n ]
            WIDTH 64
            HEIGHT 64
         END BUTTON

      NEXT

      @ 150, 40 LABEL Lbl_2 VALUE "LOADED PICTURES NORMAL LOOK" AUTOSIZE

      FOR n := 1 TO Len( aPng )
         aBtn[ n ] := "Img2_" + hb_ntos( n )

         DEFINE IMAGE &( aBtn[ n ] )
            ROW 180
            COL n * 70 - 20
            ACTION NIL
            PICTURE aPng[ n ]
            TRANSPARENT .T.
         END IMAGE

      NEXT

      @ 260, 40 LABEL Lbl_3 VALUE "DISABLED BUTTONS" AUTOSIZE

      FOR n := 1 TO Len( aPng )
         aBtn[ n ] := "Btn3_" + hb_ntos( n )

         DEFINE BUTTON &( aBtn[ n ] )
            ROW 290
            COL n * 70 - 30
            ACTION NIL
            PICTURE aPng[ n ]
            WIDTH 64
            HEIGHT 64
         END BUTTON

         Form_1.&( aBtn[ n ] ).Enabled := .F.

      NEXT

   END WINDOW

   CENTER WINDOW Form_1

   ACTIVATE WINDOW Form_1

RETURN NIL
Please take a look at the following PNG image as an example: :arrow:
PNG image example
PNG image example
image6.png (2.45 KiB) Viewed 55802 times

Re: Put PNG image with an alpha channel on a Button

Posted: Fri Mar 31, 2023 7:07 am
by serge_girard
Thanks Grigory !

Serge

Re: Put PNG image with an alpha channel on a Button

Posted: Fri Mar 31, 2023 2:16 pm
by jorge_rivero
Gracias Grigori
Me fusta mucho este lenguaje, empece con Clipper en 1987, y hice grandes sistemas, y con Migui extende, logro mejores programas.
Una consulta:
-uso Harbour MiniGUI Extended Edition 23.02 (Release), y compilo con bcc10.2
al compilar el ejemplo D:\MiniGUI\SAMPLES\BASIC\MYSQL\Demo_2.prg, me da el siguiente error:
Turbo Incremental Link 5.69 Copyright (c) 1997-2005 Borland
Error: Unresolved external '_HB_FUN_TMYSQLSERVER' referenced from
C:\USERS\JORGE\APPDATA\LOCAL\TEMP\HBMK_7GCBMP.DIR\DEMO_2.OBJ
hbmk2: Error: Running linker. 2
Presione una tecla para continuar . . .
En cambio si compilo con Compile.bat que esta en el directorio no hay drama, sera por que usa Bcc58??
Si podes ayudarme, ya que compilo todo con Bcc10.2
sera que la libreria hbmysql.lib que crea la version de Minigui esta Bcc58??
A pesar que la version Bcc10.2 tiene tb esa libreria hbmysql.lib en su carpeta.
Tenes idea que puede pasar??
-queria mandarte mensaje privado, pero no se puede mandarte.
Espero estes muy bien en ese hermoso pais de hermosas mujeres

Re: Put PNG image with an alpha channel on a Button

Posted: Fri Mar 31, 2023 2:37 pm
by gfilatov
jorge_rivero wrote: Fri Mar 31, 2023 2:16 pm Gracias Grigori
Me fusta mucho este lenguaje, empece con Clipper en 1987, y hice grandes sistemas, y con Migui extende, logro mejores programas.
Una consulta:
-uso Harbour MiniGUI Extended Edition 23.02 (Release), y compilo con bcc10.2
al compilar el ejemplo D:\MiniGUI\SAMPLES\BASIC\MYSQL\Demo_2.prg, me da el siguiente error:
Turbo Incremental Link 5.69 Copyright (c) 1997-2005 Borland
Error: Unresolved external '_HB_FUN_TMYSQLSERVER' referenced from
C:\USERS\JORGE\APPDATA\LOCAL\TEMP\HBMK_7GCBMP.DIR\DEMO_2.OBJ
hbmk2: Error: Running linker. 2
Presione una tecla para continuar . . .
En cambio si compilo con Compile.bat que esta en el directorio no hay drama, sera por que usa Bcc58??
Si podes ayudarme, ya que compilo todo con Bcc10.2
sera que la libreria hbmysql.lib que crea la version de Minigui esta Bcc58??
A pesar que la version Bcc10.2 tiene tb esa libreria hbmysql.lib en su carpeta.
Tenes idea que puede pasar??
-queria mandarte mensaje privado, pero no se puede mandarte.
Espero estes muy bien en ese hermoso pais de hermosas mujeres
Dear Jorge,

It seems that you have mixed your Bcc58 and Bcc10.2 compilers.

The message from Bcc10.2 linker should be as below:
Turbo Incremental Link 6.90 Copyright (c) 1997-2017 Embarcadero Technologies, Inc.
You may send a message to my private email gfilatov/@/gmail.com for further explanations. :arrow:

Re: Put PNG image with an alpha channel on a Button

Posted: Mon Oct 30, 2023 8:18 pm
by gisjr134
Hi To All ,

How to make Draw Transparent in Hmg? I didn´t get Transparent effect in HMG as it Gets in MINIGUI.

Thank´s in Advance

Re: Put PNG image with an alpha channel on a Button

Posted: Tue Oct 31, 2023 10:01 am
by Georg_BA
Hello everyone
I have 2 questions
1. half of my buttons are grayed out, what's causing it, I can remove it. There are nice white ones in the attachment from gfilatov.
2. is the way to implement the mentioned adjustment in HMG

Georg

Re: Put PNG image with an alpha channel on a Button

Posted: Tue Oct 31, 2023 11:42 am
by gisjr134
Hi To All ,

As you can See in Hmg Version there is a little Black Border . In Minigui version it does not exist this black border

Re: Put PNG image with an alpha channel on a Button

Posted: Sun Nov 05, 2023 11:46 am
by Georg_BA
I'm talking about the gray half of the button