Use PNG image (Solved)

Post Reply
User avatar
ctoas
Posts: 103
Joined: Wed Oct 26, 2005 2:38 pm
Location: São Paulo - Brasil
Contact:

Use PNG image (Solved)

Post 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.
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
ukoenig
Posts: 3981
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany
Contact:

Re: Use PNG image

Post 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 :?:
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
nageswaragunupudi
Posts: 8017
Joined: Sun Nov 19, 2006 5:22 am
Location: India
Contact:

Re: Use PNG image

Post 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.
Regards

G. N. Rao.
Hyderabad, India
User avatar
ctoas
Posts: 103
Joined: Wed Oct 26, 2005 2:38 pm
Location: São Paulo - Brasil
Contact:

Re: Use PNG image

Post 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
Christiano Augusto Silveira
christiano.silveira@gmail.com

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

Re: Use PNG image

Post 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.
Christiano Augusto Silveira
christiano.silveira@gmail.com

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

Re: Use PNG image

Post 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?
Christiano Augusto Silveira
christiano.silveira@gmail.com

MaxxTech Soluções em TI
http://www.maxxtech.com.br
User avatar
nageswaragunupudi
Posts: 8017
Joined: Sun Nov 19, 2006 5:22 am
Location: India
Contact:

Re: Use PNG image

Post 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
Regards

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

Re: Use PNG image

Post 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.
Regards

G. N. Rao.
Hyderabad, India
AntoninoP
Posts: 347
Joined: Tue Feb 10, 2015 9:48 am
Location: Albenga, Italy
Contact:

Re: Use PNG image

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