Page 1 of 1

Use PNG image (Solved)

Posted: Sun Jan 24, 2021 11:28 pm
by ctoas
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.

Re: Use PNG image

Posted: Mon Jan 25, 2021 1:37 pm
by ukoenig
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 :?:

Re: Use PNG image

Posted: Mon Jan 25, 2021 5:34 pm
by nageswaragunupudi
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: Select all

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.

Re: Use PNG image

Posted: Mon Jan 25, 2021 9:22 pm
by ctoas
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

#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

Re: Use PNG image

Posted: Mon Jan 25, 2021 9:26 pm
by ctoas
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: Select all

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.[/quote]

Thank you Nages ....

I'll try.

Re: Use PNG image

Posted: Tue Jan 26, 2021 5:23 pm
by ctoas
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?

Re: Use PNG image

Posted: Wed Jan 27, 2021 8:33 am
by nageswaragunupudi
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

@ 125,  10 TITLEIMG OF oTitle4 BITMAP FW_ReadImage( nil, "PNGRESOURCE" )[ 1 ]  SIZE 30, 30

Re: Use PNG image

Posted: Wed Jan 27, 2021 3:17 pm
by nageswaragunupudi
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.

Re: Use PNG image

Posted: Fri Jan 29, 2021 10:15 am
by AntoninoP
on my code I have, on RC file:

Code: Select all

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

    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" )