cGetFile()

cGetFile()

Postby Silvio.Falconi » Tue Nov 12, 2013 9:12 am

From FiveWin 1.9
the 5th parameter of is cGetFile() is lsave ....

How I can save an Image and select a format to save ( from final user) with cGetFile()
sample :

Code: Select all  Expand view

#define FIF_UNKNOWN  -1
#define   FIF_BMP     0
#define   FIF_ICO     1
#define   FIF_JPEG    2
#define   FIF_JNG     3
#define   FIF_KOALA   4
#define   FIF_LBM     5
#define   FIF_IFF     FIF_LBM
#define   FIF_MNG     6
#define   FIF_PBM     7
#define   FIF_PBMRAW  8
#define   FIF_PCD     9
#define   FIF_PCX    10
#define   FIF_PGM    11
#define   FIF_PGMRAW 12
#define   FIF_PNG    13
#define   FIF_PPM    14
#define   FIF_PPMRAW 15
#define   FIF_RAS    16
#define   FIF_TARGA  17
#define   FIF_TIFF   18
#define   FIF_WBMP   19
#define   FIF_PSD    20
#define   FIF_CUT    21
#define   FIF_XBM    22
#define   FIF_XPM    23
#define   FIF_DDS    24
#define   FIF_GIF    25
#define   FIF_HDR    26
#define   FIF_FAXG3  27
#define   FIF_SGI    28




STATIC FUNCTION SalvaImage(oImage)


     local cFile := cGetFile( "Bitmap (*.bmp)| *.bmp|" +         ;
                             "DIB   (*.dib)| *.dib|" +          ;
                             "PCX   (*.pcx)| *.pcx|"  +         ;
                             "JPEG  (*.jpg)| *.jpg|" +          ;
                             "GIF   (*.gif)| *.gif|"  +         ;
                             "TARGA (*.tga)| *.tga|" +          ;
                             "RLE   (*.rle)| *.rle|" +          ;
                             "All Files (*.*)| *.*"             ;
                            ,"Salva con il nome",  CurDir(), .t. )


   * if ! Empty( cFile ) .and. File( cFile )
   *   Return cFile
  * End


     nFormat:= 2
     nFlag := 25


     oImage:SaveImage( cFile, nFormat, nFlag )

     MsgInfo( "saved as"+ cFile)

     RETURN NIL
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 7056
Joined: Thu Oct 18, 2012 7:17 pm

Re: cGetFile()

Postby ukoenig » Tue Nov 12, 2013 10:50 am

Silvio,

SELECTEDEXT = the new extension
change the extension of the selected image like :

// original selected like OLGA.JPG
cLImage1 := cFileNoPath( cNewBITM ), ;
// new EXPORT image-name like _OLGA.BMP
cLImage2 := "_" + cFileNoExt( cLImage1 ) + "." + SELECTEDEXT, ;

Code: Select all  Expand view

REDEFINE BTNBMP oBtn1 OF oIDlg ;
ID 130 PIXEL 2007 ;
NOBORDER ;
PROMPT "&Image" ;
FILENAME c_path1 + "Select.Bmp" ;
ACTION  ( cFilter := "BMP (*.bmp)|*.bmp|" + ;
   "JPG (*.jpg)|*.jpg|" + ;
   "PNG (*.png)| *.png|" + ;
   "TIFF (*.tiff)| *.tiff|" + ;
   "DDS (*.dds)| *.dds|" + ;
   "IFF (*.iff)| *.iff|" + ;
   "PCX  (*.pcx)| *.pcx|" + ;
   "PPM (*.ppm)| *.ppm|" + ;
   "PSD (*.ppm)| *.psd|" + ;
   "SGI  (*.sgi)| *.sgi|" + ;
   "TARGA (*.tga)| *.tga|", ;
   cNewBITM := cGetFile32( cFilter,"Select a Image" ,,  "\" + CurDir()+ "\Images" ), ;
   IIF( EMPTY( cNewBITM ), MsgAlert( "
No file selected !","ATTENTION" ), ;
      ( cLImage1 := cFileNoPath( cNewBITM ), ;    // original selected like OLGA.JPG
        cLImage2 := "
_" + cFileNoExt( cLImage1 ) + "." + SELECTEDEXT, ;    // new EXPORT image-name like _OLGA.BMP
        oSelex1:SetOption(2), oGet1:Refresh(), oGet4:Refresh(), oBmp1:Refresh() ) ) ) ; // format defined in oSelex1         
FONT oBtnFont ;
LEFT
oBtn1:lTransparent := .t.  
oBtn1:cToolTip =  { "
Select a Image ","Load Image", 1, CLR_BLACK, 14089979 }
oBtn1:SetColor( 0, )


Best Regards
Uwe :lol:
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: cGetFile()

Postby Silvio.Falconi » Tue Nov 12, 2013 11:33 am

RIGHT UWE SELECTEDEXT = the new extension

but I not Know wich extension select the final user .....
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 7056
Joined: Thu Oct 18, 2012 7:17 pm

Re: cGetFile()

Postby ukoenig » Tue Nov 12, 2013 12:01 pm

Silvio,

SELECTEDEXT is defined from user.
Please have a look at Your post
viewtopic.php?f=3&t=27412&p=154259#p154259

Best 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: cGetFile()

Postby MaxP » Wed Nov 13, 2013 6:41 am

This is a sample

Code: Select all  Expand view

STATIC FUNCTION SalvaImage(oImage)
     local nFormat, nFlag, nType, cExt

     local cFile := cGetFile( "Bitmap (*.bmp)| *.bmp|" +         ;
                             "DIB   (*.dib)| *.dib|" +          ;
                             "PCX   (*.pcx)| *.pcx|"  +         ;
                             "JPEG  (*.jpg)| *.jpg|" +          ;
                             "GIF   (*.gif)| *.gif|"  +         ;
                             "TARGA (*.tga)| *.tga|" +          ;
                             "RLE   (*.rle)| *.rle"            ;                            
                            ,"Salva con il nome",  CurDir(), .t. )
                           
     IF .NOT. EMPTY( cFile )          
             nType := NGETFILEFILTER()

             nFormat:=  0
             nFlag := 0
       
             DO CASE
                CASE nType == 1
                   nFormat := 0
                   cExt := "bmp"
                   
                CASE nType == 2                
                   nFormat := 0
                   cExt := "dib"
                   
                CASE nType == 3                
                   nFormat := 10
                   cExt := "pcx"
                   
                CASE nType == 4
                   nFormat := 2
                   nFlag := 25
                   cExt := "jpg"
                   
                CASE nType == 5
                   nFormat := 25
                   cExt := "gif"
                   
                CASE nType == 6
                   nFormat := 17
                   cExt := "tga"
                   
                CASE nType == 7
                   nFormat := 0
                   nFlag := 1
                   cExt := "rle"
             ENDCASE

             cFile := cFilePath( cFile ) + cFileNoExt( cFile ) + "." + cExt
             oImage:SaveImage( cFile, nFormat, nFlag )
       
             MsgInfo( "saved as: "+ cFile)
     ENDIF    

     RETURN NIL
 


Best Regards
Massimo
User avatar
MaxP
 
Posts: 85
Joined: Thu Jul 12, 2007 2:02 pm

Re: cGetFile()

Postby Silvio.Falconi » Wed Nov 13, 2013 11:02 am

thank Max
the problem is for pcx anf gif but on this forum I saw a fnxtion made by Daniel FICONVERTE... but now I not Rememebr where
I think with this func we can converte the oimage into pcx or gif with no lose of colors
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 7056
Joined: Thu Oct 18, 2012 7:17 pm


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 41 guests