transform Png to Bmp

transform Png to Bmp

Postby Silvio.Falconi » Sat May 18, 2019 7:09 am

to converte a png I use FW_transformBitmap and then save with fw_saveImage
but it createa bmp with black background
I see the bitmap image with black outlines which makes the image look a little grainy and unclear
how can I change the background of the image?
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: 7074
Joined: Thu Oct 18, 2012 7:17 pm

Re: transform Png to Bmp

Postby Silvio.Falconi » Sat May 18, 2019 7:44 am

I try to save the file to Jpg and then to Bmp and now seem run ok
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: 7074
Joined: Thu Oct 18, 2012 7:17 pm

Re: transform Png to Bmp

Postby nageswaragunupudi » Sat May 18, 2019 8:53 am

Where is the function FW_transformBitmap() ?

I would do it this way:
FW_SaveImage( "name.png", "name.bmp" )
Did you try this? How is the quality?
Regards

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

Re: transform Png to Bmp

Postby Silvio.Falconi » Sat May 18, 2019 9:10 am

Rao,
FW_transformBitmap is in http://forums.fivetechsupport.com/viewtopic.php?f=3&t=35547&start=0&hilit=FW_transformBitmap

I used this because I wanted have a small image but

my test code to save from png to Bmp


Code: Select all  Expand view  RUN

   Local aElementi:=CaricaElementi()
   Local cFoldertemp:=".\bitmaps\mini\temp\"
   Local aElementiBmp:= {}
   Local cFileBmp_Elementi:= "
TempEl_"

  aElementiBmp:=  CreaMiniatureElementi(aElementi,cFoldertemp,cFileBmp_Elementi)
 
//-----------------------------------------------------------------------------------------//
Function CreaMiniatureElementi(aElementi,cFoldertemp,cFileBmp_Elementi)
   Local n
   Local k
   Local atempBmp := {}
   Local cFile,cfileNew

 For n= 1 to Len(aElementi)

//  from Png to Jpg
        cfile:=  Converti_Immagine_Bmp(alltrim(aElementi [n][8]),;
                     cFolderTemp,;
                     cFileBmp_Elementi+alltrim(str(n)),0.80)

// from Jog to Bmp
          cFileNew:= savetobmp(cfile)

           //aadd(atempBmp ,cFolderTemp+cFileBmp_Elementi+alltrim(str(n))+"
.bmp")

           aadd(atempBmp ,cFileNew+"
.bmp")

        next


        //xbrowser atempBmp
    return atempBmp
//-------------------------------------------------------------------------------------------//

Function Converti_Immagine_Bmp(cFile,cFolderTemp,cNewName,nResize,ntipo)
   Local aext :={"
.Bmp",".Jpg"}
   Local hBmp
   Local hNew

   DEFAULT ntipo:= 2
   DEFAULT nResize:=0.30

   //hBmp := FW_ReadImage( nil, cFile )[ 1 ]
   //hNew := FW_TransformBitmap( hBmp, NIL, nResize )
   //hNew := FW_TransformBitmap( hBmp, {0.2,0.2,-0.2,-0.2}, 0.75, 45 )
    //hNew := FW_TransformBitmap( hBmp, nil, 0.75, 45 )

     ext:= aExt[ntipo]

   //FW_SaveImage( [uImage], [cFile], [nJpgQuality] )
    // FW_SaveImage( hNew, cFolderTemp+cNewName+ext,40 )



     FW_SaveImage( cFile, cFolderTemp+cNewName+ext,40 )

 Return   cFolderTemp+cNewName+ext


 Function savetobmp(cfile)
      Local  hBmp := FW_ReadImage( nil, cfile )[ 1 ]
      FW_SaveImage( hBmp, cfile+"
.Bmp",40 )

      Return  cfile






Before I save from Png to Bmp but it saved with black outlines and before it was no good for me
bow I converte before to Jpg and then to Bmp
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: 7074
Joined: Thu Oct 18, 2012 7:17 pm

Re: transform Png to Bmp

Postby Silvio.Falconi » Sat May 18, 2019 9:24 am

nageswaragunupudi wrote:Where is the function FW_transformBitmap() ?

I would do it this way:
FW_SaveImage( "name.png", "name.bmp" )
Did you try this? How is the quality?


Now I try with your command

Code: Select all  Expand view  RUN
aElementiBmp:=   ConvertImage(aElementi,cFoldertemp,cFileBmp_Elementi)

Function ConvertImage(aElementi,cFoldertemp,cFileBmp_Elementi)
 Local atempBmp := {}
   Local n

  For n= 1 to  Len(aElementi)

     FW_SaveImage( alltrim(aElementi [n][8]), cFolderTemp+cFileBmp_Elementi+alltrim(str(n))+".bmp" )
     aadd(atempBmp ,cFolderTemp+cFileBmp_Elementi+alltrim(str(n))+".bmp")
  next

 
    return atempBmp
 


Image

and you can see the Image with Black outlines , the quality is no good
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: 7074
Joined: Thu Oct 18, 2012 7:17 pm

Re: transform Png to Bmp

Postby nageswaragunupudi » Sat May 18, 2019 10:06 am

yes, not good.
Regards

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

Re: transform Png to Bmp

Postby nageswaragunupudi » Sat May 18, 2019 1:31 pm

May I know why do you want to convert them as bmp?
Can you not use the png directly in your application?
Regards

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

Re: transform Png to Bmp

Postby Silvio.Falconi » Sat May 18, 2019 4:10 pm

Be
nageswaragunupudi wrote:May I know why do you want to convert them as bmp?
Can you not use the png directly in your application?


Because I wish use a Combobox and the Combobox not support Png as You told me and I must use Pngs

But I found a solution ( Png->Jpg->Bmp)

Image

Code: Select all  Expand view  RUN
Function CreaMiniatureElementi(aElementi,cFoldertemp,cFileBmp_Elementi)
   Local n
   Local k
   Local atempBmp := {}
   Local cFile,cfileNew

 For n= 1 to Len(aElementi)
  cfile:=  Converti_Immagine_Bmp(alltrim(aElementi [n][8]),;
                     cFolderTemp,;
                     cFileBmp_Elementi+alltrim(str(n)),0.80)

          cFileNew:= savetobmp(cfile)
     
           aadd(atempBmp ,cFileNew+".bmp")
        next
     
    return atempBmp

 Function Converti_Immagine_Bmp(cFile,cFolderTemp,cNewName,nResize,ntipo)
   Local aext :={".Bmp",".Jpg"}
   Local hBmp
   Local hNew

   DEFAULT ntipo:= 2
   DEFAULT nResize:=0.30
 ext:= aExt[ntipo]

 FW_SaveImage( cFile, cFolderTemp+cNewName+ext,40 )

 Return   cFolderTemp+cNewName+ext
//------------------------------------------------------------------------//
 Function savetobmp(cfile)
      Local  hBmp := FW_ReadImage( nil, cfile )[ 1 ]
      FW_SaveImage( hBmp, cfile+".Bmp",40 )

      Return  cfile


 



I must resize it on first passage

Local aElementi:=CaricaElementi()
Local cFoldertemp:=".\bitmaps\mini\temp\"
Local aElementiBmp:= {}
Local cFileBmp_Elementi:= "TempEl_"

aElementiBmp:= CreaMiniatureElementi(aElementi,cFoldertemp,cFileBmp_Elementi)



Code: Select all  Expand view  RUN


Function CreaMiniatureElementi(aElementi,cFoldertemp,cFileBmp_Elementi)
   Local n
   Local k
   Local atempBmp := {}
   Local cFile,cfileNew

 For n= 1 to Len(aElementi)
               //toJpg and resize
                cfile:=  Converti_Immagine_Bmp(alltrim(aElementi [n][8]),;
                     cFolderTemp,;
                     cFileBmp_Elementi+alltrim(str(n)),0.80)

                //  save to Bmp
                          cFileNew:= savetobmp(cfile)

                     aadd(atempBmp ,cFileNew+".bmp")
        next
   
    return atempBmp
//-------------------------------------------------------------------------------------------------------------//
     Function Converti_Immagine_Bmp(cFile,cFolderTemp,cNewName,nResize,ntipo)
   Local aext :={".Bmp",".Jpg"}
   Local hBmp
   Local hNew

   DEFAULT ntipo:= 2
   DEFAULT nResize:=0.30

     hBmp := FW_ReadImage( nil, cFile )[ 1 ]
     hNew := FW_TransformBitmap( hBmp, NIL, nResize )
      ext:= aExt[ntipo]

   //FW_SaveImage( [uImage], [cFile], [nJpgQuality] )
     FW_SaveImage( hNew, cFolderTemp+cNewName+ext,40 )

  Return   cFolderTemp+cNewName+ext
//-------------------------------------------------------------------------------------------//
 Function savetobmp(cfile)
      Local  hBmp := FW_ReadImage( nil, cfile )[ 1 ]
      FW_SaveImage( hBmp, cfile+".Bmp",40 )

      Return  cfile
//---------------------------------------------------------------------------------------------//

 
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: 7074
Joined: Thu Oct 18, 2012 7:17 pm


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 58 guests