Page 1 of 1
How to have a sharp image conversion
Posted: Sat Feb 29, 2020 9:51 am
by Silvio.Falconi
to convert a png image I use
DEFAULT nResize:=0.30
hBmp: = FW_ReadImage (nil, cFile) [1]
hNew: = FW_TransformBitmap (hBmp, NIL, nResize)
FW_SaveImage (hNew, cFolderTemp + cNewName + ext, 40)
but then using a combo I don't see the sharp image
JPG
if I turn it into a bmp format it is even worse
bmp
how do i get a clear picture?
Re: How to have a sharp image conversion
Posted: Sat Feb 29, 2020 11:50 am
by nageswaragunupudi
Where did you get the function FW_TransformBitmap() from?
Re: How to have a sharp image conversion
Posted: Sat Feb 29, 2020 12:06 pm
by Silvio.Falconi
Not Remember
I think you make a sample test (fwh 18.03)
http://forums.fivetechsupport.com/viewt ... ap#p211638
we tried also with
FW_SaveImage( "name.png", "name.bmp" )
but the quality is no good
Re: How to have a sharp image conversion
Posted: Sat Feb 29, 2020 12:15 pm
by Silvio.Falconi
Rao,
Now I tried with
local nJpgQuality := 90
FW_SaveImage( cFile, cFolderTemp+cNewName+ext,nJpgQuality )
and now run ok
before png->jpg
then jpg->bmp
and the image is clear now
Re: How to have a sharp image conversion
Posted: Sat Feb 29, 2020 3:30 pm
by nageswaragunupudi
Thanks. Now I got it. This function is in source\function\imgtxtio.prg.
Looks like quality is lost while resizing.
So, do you want to convert a png file as jpg with reduced size?
local nJpgQuality := 90
FW_SaveImage( cFile, cFolderTemp+cNewName+ext,nJpgQuality )
and now run ok
This saves png as jpg but does not reduce the size. Is that what you want?
Can you please
1) Let me know why do you want to convert png to jpg with reduced size? Can you not directly use png?
2) Can you send me your png by email? Like to some tests and see.
Re: How to have a sharp image conversion
Posted: Sun Mar 01, 2020 3:58 pm
by Silvio.Falconi
Can you please
1) Let me know why do you want to convert png to jpg with reduced size? Can you not directly use png?
2) Can you send me your png by email? Like to some tests and see.
1) I must use a combobox control . It use only bmp image so I must convert before png to jpg then png to bmp. If I convert png to bmp directly we have no sharp Image ( with black shadow)
2) I send now a message with Png file
Re: How to have a sharp image conversion
Posted: Sun Mar 01, 2020 4:10 pm
by nageswaragunupudi
I understand.
We will do some tests and see if we can improve our functions.
You wanted to do resize also. How did you do that?
Re: How to have a sharp image conversion
Posted: Sun Mar 01, 2020 4:31 pm
by Silvio.Falconi
if it is possible I wanted to resize (because it is too big) but for now I use the version that I have as you can see on this image
Now I'm correcting because I have an error on gets , the button of get is bad and I 'm searching a good solution
Re: How to have a sharp image conversion
Posted: Mon Mar 02, 2020 9:44 am
by nageswaragunupudi
Mr. Silvio
Can you try this?
Code: Select all
aBmp: = FW_ReadImage( nil, cFile )
hNew: = FW_TransformBitmap( aBmp[ 1 ], NIL, 0.30 )
FW_SaveHBitmap( hNew, "new.bmp" )
PalBmpFree( aBmp )
DeleteObject( hNew )
Re: How to have a sharp image conversion
Posted: Mon Mar 02, 2020 10:37 am
by Silvio.Falconi
I tried and made bmp with
black background
Code: Select all
cDir:= "temp\"
IF !lIsDir( lower(cDir) )
IF lMkDir( lower( cDir) )
ELSE
MsgAlert("Err "+cdir,"Verificare!")
ENDIF
ENDIF
USE ELEMENTI ALIAS EL
aElementi:= CaricaElementi(.t.) // load array
aBmpCombo:= Crea_BMP(aElementi,cFoldertemp,cFileBmp_Elementi) // create Bmps for combobox
//-----------------------------------------------------------------------------//
Function Crea_Bmp(aElementi,cFolderTemp,cFileBmp_Elementi)
Local n
Local k
Local atempBmp := {}
Local cFile,cfileNew
Local cCartella := cFoldertemp+"\"
For n= 1 to Len(aElementi)
cfile:= Conversione(alltrim(aElementi [n][5]),cCartella ,cFileBmp_Elementi+alltrim(str(n)))
aadd(atempBmp ,cFile+".bmp")
next
return atempBmp
//-----------------------------------------------------------------------------//
Function Conversione(cFile,Cfolder,cNewFile)
Local aBmp := FW_ReadImage( nil, cFile )
Local hNew := FW_TransformBitmap( aBmp[ 1 ], NIL, 0.30 )
FW_SaveHBitmap( hNew, cFolder+cNewFile+".bmp" )
PalBmpFree( aBmp )
DeleteObject( hNew )
return cNewFile
Re: How to have a sharp image conversion
Posted: Mon Mar 02, 2020 11:26 am
by Silvio.Falconi
Nages,
If I make in this mode :
Code: Select all
Function Crea_Bmp(aElementi,cFolderTemp,cFileBmp_Elementi)
Local n
Local k
Local atempBmp := {}
Local cFile,cfileNew
Local cCartella := cFoldertemp+"\"
For n= 1 to Len(aElementi)
// to JPG +RESIZE
cfile:= Conversione(alltrim(aElementi [n][5]),;
cCartella ,;
cFileBmp_Elementi+alltrim(str(n)))
// to BMP
cFileN := savetobmp(cfile)
DELETEFILE(cFILE)
aadd(atempBmp ,cFileN+".bmp")
next
return atempBmp
Function Conversione(cFile,Cfolder,cNewFile)
Local aBmp := FW_ReadImage( nil, cFile )
Local hNew := FW_TransformBitmap( aBmp[ 1 ], NIL, 0.30 )
//FW_SaveHBitmap( hNew, cFolder+cNewFile+".jpg",90 )
FW_SaveImage( hNew, cFolder+cNewFile+".jpg",90 ) // to JPG
PalBmpFree( aBmp )
DeleteObject( hNew )
return cFolder+cNewFile+".jpg"
Function Savetobmp(cfile)
Local aBmp := FW_ReadImage( nil, cfile )[ 1 ]
FW_SaveImage( aBmp, cfile+".Bmp",40 )
Return cfile
I have
Re: How to have a sharp image conversion
Posted: Mon Mar 02, 2020 4:07 pm
by nageswaragunupudi
For bitmaps FW_SaveHBitmap() saves with better quality than FW_SaveImage()
What you saw as black color is in fact Alpha color and FWH controls correctly paint the bitmaps treating the alpha color as transparent
Note: After some more tests, we will improve FW_SaveImage() in the next version.
Re: How to have a sharp image conversion
Posted: Tue Mar 03, 2020 8:04 am
by Silvio.Falconi
nageswaragunupudi wrote:For bitmaps FW_SaveHBitmap() saves with better quality than FW_SaveImage()
What you saw as black color is in fact Alpha color and FWH controls correctly paint the bitmaps treating the alpha color as transparent
Note: After some more tests, we will improve FW_SaveImage() in the next version.
Nages,
if I use
Code: Select all
For n= 1 to Len(aElementi)
cFileBmp:= Nages_BMP(alltrim(aElementi [n][5]),;
cCartella ,;
cFileBmp_Elementi+alltrim(str(n)))
aadd(atempBmp ,cFileBmp)
next
return atempBmp
Function Nages_BMP(cFile,cFolder,cNewFile)
Local aBmp:= FW_ReadImage( nil, cFile )
Local hNew:= FW_TransformBitmap( aBmp[ 1 ], NIL, 0.30 )
Local cnew := cFolder+cNewFile+".bmp"
FW_SaveHBitmap( hNew,cnew )
PalBmpFree( aBmp )
DeleteObject( hNew )
return cnew
Then I can list on pc this
and trying the test I have
the images on the combo
are grainy and unclear, they are ugly to look at and do not help the end user!!!!
perhaps on future someone must try to create a
control combobox with pngs/jpg compatible!!!
Re: How to have a sharp image conversion
Posted: Tue Mar 03, 2020 8:06 am
by nageswaragunupudi
I am seeing. The reason is that combobox is not painting alphabmps properly.
Need to improve this aspect. Takes time.
Re: How to have a sharp image conversion
Posted: Tue Mar 03, 2020 10:29 am
by Silvio.Falconi
nageswaragunupudi wrote:I am seeing. The reason is that combobox is not painting alphabmps properly.
Need to improve this aspect. Takes time.
Nages.
thanks
a question ...combometro support png files ?