Use PNG image (Solved)

Use PNG image (Solved)

Postby ctoas » Sun Jan 24, 2021 11:28 pm

Hello guys...

At BTNBMP I can use PNG images just by adding data to the resource file and calling this resource in the code, how to do this in the rest of the code?

Thanks.
Last edited by ctoas on Tue Feb 02, 2021 3:27 am, edited 1 time in total.
Christiano Augusto Silveira
christiano.silveira@gmail.com

MaxxTech Soluções em TI
http://www.maxxtech.com.br
User avatar
ctoas
 
Posts: 115
Joined: Wed Oct 26, 2005 2:38 pm
Location: São Paulo - Brasil

Re: Use PNG image

Postby ukoenig » Mon Jan 25, 2021 1:37 pm

Christiano,
can You please explain what You mean with

how to do this in the rest of the code?


maybe showing a dialog-image ( or other control-image ) from resource :?:

regards
Uwe :?:
Since 1995 ( the first release of FW 1.9 )
i work with FW.
If you have any questions about special functions, maybe i can help.
User avatar
ukoenig
 
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany

Re: Use PNG image

Postby nageswaragunupudi » Mon Jan 25, 2021 5:34 pm

If you want to use it in any image control or other control like TBitmap, TImage, XBrowse, etc you can use the resource name in the place where you use an image or bmp file name.

If you want to just display the image on any window, dialog, control, you can use
[code]
oWnd:DrawImage( cResource, { nTop, nLeft, Bottom, nRight } )
// OR
FW_DrawImage( hDC, cResource, { nTop, nLeft, Bottom, nRight } )
[/code[

In other words, you can use the resource name wherever you use any other resource or image/bmp file.
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10659
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Use PNG image

Postby ctoas » Mon Jan 25, 2021 9:22 pm

Hello ukoenig ....

I discovered this by accident, the tBTNBMP class can read a PNG image inserted in the resource file as DATA.

Code: Select all  Expand view  RUN

#INCLUDE "FIVEWIN.CH"

FUNCTION TESTE()

    PRIVATE oWnd, oBar
   
    DEFINE WINDOW oWND FROM 0,0 TO 16,60 TITLE "TESTE" NOZOOM NOICONIZE BORDER NONE
   
    DEFINE BUTTONBAR oBar 3DLOOK OF oWnd SIZE 0080,0080 2007 NOBORDER
     
    #IFNDEF GRAD_BTNS_ONLY                                          
        oBar:bClrGrad := {|lMouseOver|If(!lMouseOver,{{1,nRGB(205,165,090),nRGB(205,165,090)}},;
                                                     {{1,nRGB(205,165,090),nRGB(205,165,090)}})}                                  
    #ENDIF
   
    @ 0010,0003 BTNBMP oBtnAGENDA       BITMAP "BAR_AGENDA1"  ,"BAR_AGENDA2"   SIZE 0060,0060 PIXEL OF oBar FLAT NOBORDER
    @ 0010,0083 BTNBMP oBtnCLIENTE      BITMAP "BAR_CLIENTES1","BAR_CLIENTES2" SIZE 0060,0060 PIXEL OF oBar FLAT NOBORDER
    @ 0010,0163 BTNBMP oBtnFERRAMENTAS  BITMAP "BAR_TOOLS1"   ,"BAR_TOOLS2"    SIZE 0060,0060 PIXEL OF oBar FLAT NOBORDER
    @ 0010,0243 BTNBMP oBtnCONFIGURACAO BITMAP "BAR_CONFIG1"  ,"BAR_CONFIG2"   SIZE 0060,0060 PIXEL OF oBar FLAT NOBORDER
    @ 0010,0323 BTNBMP oBtnAJUDA        BITMAP "BAR_AJUDA1"   ,"BAR_AJUDA2"    SIZE 0060,0060 PIXEL OF oBar FLAT NOBORDER
    @ 0010,0413 BTNBMP oBtnENCERRAR     BITMAP "BAR_ONOFF1"   ,"BAR_ONOFF2"    SIZE 0060,0060 PIXEL OF oBar FLAT NOBORDER
   
    #IFDEF GRAD_BTNS_ONLY
        oBtn:bClrGrad := {|lMouseOver|If(!lMouseOver,{{1,nRGB(205,165,090),nRGB(205,165,090)}},;
                                                     {{1,nRGB(205,165,090),nRGB(205,165,090) }})}
        oBtn:mode := "RIGHT"  
    #ENDIF
                                                                                                           
    ACTIVATE WINDOW oWnd CENTERED
   
RETURN NIL
 


Download the resource file with PNG's
http://maxxtech.com.br/forum/PNG.RES
Christiano Augusto Silveira
christiano.silveira@gmail.com

MaxxTech Soluções em TI
http://www.maxxtech.com.br
User avatar
ctoas
 
Posts: 115
Joined: Wed Oct 26, 2005 2:38 pm
Location: São Paulo - Brasil

Re: Use PNG image

Postby ctoas » Mon Jan 25, 2021 9:26 pm

nageswaragunupudi wrote:If you want to use it in any image control or other control like TBitmap, TImage, XBrowse, etc you can use the resource name in the place where you use an image or bmp file name.

If you want to just display the image on any window, dialog, control, you can use
[code]
oWnd:DrawImage( cResource, { nTop, nLeft, Bottom, nRight } )
// OR
FW_DrawImage( hDC, cResource, { nTop, nLeft, Bottom, nRight } )
[/code[

In other words, you can use the resource name wherever you use any other resource or image/bmp file.


Thank you Nages ....

I'll try.
Christiano Augusto Silveira
christiano.silveira@gmail.com

MaxxTech Soluções em TI
http://www.maxxtech.com.br
User avatar
ctoas
 
Posts: 115
Joined: Wed Oct 26, 2005 2:38 pm
Location: São Paulo - Brasil

Re: Use PNG image

Postby ctoas » Tue Jan 26, 2021 5:23 pm

Hello Nages.

I managed to put the image in the empty dialog without problems, but I would like to put the image on the tTITLE class and I'm not getting it. Could you give me this help?
Christiano Augusto Silveira
christiano.silveira@gmail.com

MaxxTech Soluções em TI
http://www.maxxtech.com.br
User avatar
ctoas
 
Posts: 115
Joined: Wed Oct 26, 2005 2:38 pm
Location: São Paulo - Brasil

Re: Use PNG image

Postby nageswaragunupudi » Wed Jan 27, 2021 8:33 am

TTitle class does not natively support any image format other than BMP.
Now that you raised this topic, we will provide this facility in the coming versions.

For now, I suggest you adopt this work-around and this works well:

Use
FW_ReadImage( nil, <YOURRESOURCE> )[ 1 ]
in the place of image-name in the command or method.

Eg:
Code: Select all  Expand view  RUN
@ 125,  10 TITLEIMG OF oTitle4 BITMAP FW_ReadImage( nil, "PNGRESOURCE" )[ 1 ]  SIZE 30, 30
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10659
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Use PNG image

Postby nageswaragunupudi » Wed Jan 27, 2021 3:17 pm

The above workaround is tested and working well.

From the next version FWH2101, we can directly use any image source, bmp,jpg,png.ico,cur, etc either filename, resource, image buffer or web-ref.
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10659
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Use PNG image

Postby AntoninoP » Fri Jan 29, 2021 10:15 am

on my code I have, on RC file:
Code: Select all  Expand view  RUN
PNG_REPEDI_SORT1_16                             10    "..\\Images\\Common\\16x16\\ordina_A.png"
PNG_REPEDI_SORT2_16                             10    "..\\Images\\Common\\16x16\\ordina_D.png"
PNG_REPEDI_SUM_16                               10    "..\\Images\\Common\\16x16\\somma.png"

then use it simply with:
Code: Select all  Expand view  RUN
   aPngSort := {nil,nil}
   aPngSort[1] := oWnd:ReadImage( "PNG_REPEDI_SORT1_16" )
   aPngSort[2] := oWnd:ReadImage( "PNG_REPEDI_SORT2_16" )
   oPngSomma   := oWnd:ReadImage( "PNG_REPEDI_SUM_16" )
AntoninoP
 
Posts: 375
Joined: Tue Feb 10, 2015 9:48 am
Location: Albenga, Italy


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 55 guests