Page 1 of 1
transform Png to Bmp
Posted: Sat May 18, 2019 7:09 am
by Silvio.Falconi
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?
Re: transform Png to Bmp
Posted: Sat May 18, 2019 7:44 am
by Silvio.Falconi
I try to save the file to Jpg and then to Bmp and now seem run ok
Re: transform Png to Bmp
Posted: Sat May 18, 2019 8:53 am
by nageswaragunupudi
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?
Re: transform Png to Bmp
Posted: Sat May 18, 2019 9:10 am
by Silvio.Falconi
Rao,
FW_transformBitmap is in
http://forums.fivetechsupport.com/viewt ... formBitmap
I used this because I wanted have a small image but
my test code to save from png to Bmp
Code: Select all
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
Re: transform Png to Bmp
Posted: Sat May 18, 2019 9:24 am
by Silvio.Falconi
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
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
and you can see the Image with Black outlines , the quality is no good
Re: transform Png to Bmp
Posted: Sat May 18, 2019 10:06 am
by nageswaragunupudi
yes, not good.
Re: transform Png to Bmp
Posted: Sat May 18, 2019 1:31 pm
by nageswaragunupudi
May I know why do you want to convert them as bmp?
Can you not use the png directly in your application?
Re: transform Png to Bmp
Posted: Sat May 18, 2019 4:10 pm
by Silvio.Falconi
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)
Code: Select all
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
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
//---------------------------------------------------------------------------------------------//