Put PNG image with an alpha channel on a Button

HMG Samples and Enhancements

Moderator: Rathinagiri

Post Reply
User avatar
gfilatov
Posts: 1070
Joined: Fri Aug 01, 2008 5:42 am
Location: Ukraine
Contact:

Put PNG image with an alpha channel on a Button

Post 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 52846 times
And how it is showed in HMG 3.4.4 with the same PRG source:
capture2.png
capture2.png (68.29 KiB) Viewed 52846 times
Your feedback is welcome 8-)
Kind Regards,
Grigory Filatov

"Everything should be made as simple as possible, but no simpler." Albert Einstein
jorge_rivero
Posts: 24
Joined: Tue Nov 07, 2017 6:41 am
DBs Used: DBF, Mysql
Location: Capital Federal, Buenos Aires, ARGENTINA

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

Post by jorge_rivero »

Envia el ejemplo
Gracias
User avatar
gfilatov
Posts: 1070
Joined: Fri Aug 01, 2008 5:42 am
Location: Ukraine
Contact:

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

Post 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 52793 times
Last edited by gfilatov on Fri Mar 31, 2023 7:08 am, edited 1 time in total.
Kind Regards,
Grigory Filatov

"Everything should be made as simple as possible, but no simpler." Albert Einstein
User avatar
serge_girard
Posts: 3168
Joined: Sun Nov 25, 2012 2:44 pm
DBs Used: 1 MySQL - MariaDB
2 DBF
Location: Belgium
Contact:

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

Post by serge_girard »

Thanks Grigory !

Serge
There's nothing you can do that can't be done...
jorge_rivero
Posts: 24
Joined: Tue Nov 07, 2017 6:41 am
DBs Used: DBF, Mysql
Location: Capital Federal, Buenos Aires, ARGENTINA

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

Post 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
User avatar
gfilatov
Posts: 1070
Joined: Fri Aug 01, 2008 5:42 am
Location: Ukraine
Contact:

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

Post 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:
Kind Regards,
Grigory Filatov

"Everything should be made as simple as possible, but no simpler." Albert Einstein
gisjr134
Posts: 44
Joined: Tue Dec 08, 2020 11:37 am
DBs Used: DBF,MySQL,PostgreSQL
Location: Brasil
Contact:

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

Post 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
Georg_BA
Posts: 106
Joined: Fri Apr 07, 2017 5:31 pm
DBs Used: DBF

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

Post 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
Attachments
Button_gray.jpg
Button_gray.jpg (36.71 KiB) Viewed 14869 times
gisjr134
Posts: 44
Joined: Tue Dec 08, 2020 11:37 am
DBs Used: DBF,MySQL,PostgreSQL
Location: Brasil
Contact:

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

Post 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
Georg_BA
Posts: 106
Joined: Fri Apr 07, 2017 5:31 pm
DBs Used: DBF

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

Post by Georg_BA »

I'm talking about the gray half of the button
Post Reply