Change bitmap in TXImage. Can I save the modified bitmap into a file ?
Change bitmap in TXImage. Can I save the modified bitmap into a file ?
procedure Sav_Img
local hDib:=DibFromBitmap( oWnd:aControls[3]:GetHBitmap() )
local cTempFile := cTempFile()
local lSaved
nFormat:=13
nQuality:=25
cFile:="my.png"
DibWrite( cTempFile, hDib )
GloBalFree( hDib )
lSaved = FIConvertImageFile( cTempFile, cFile, nFormat, nQuality )
FErase( cTempFile )
return
function FIConvertImageFile( cSrcFile, cDstFile, nDstFormat, nQuality )
local nSrcFormat, hDib, hDib2, lOk := .f.
DEFAULT nQuality := 0
if LoadFreeImage() > 32
nSrcFormat:= FIGETFILETYPE( cSrcFile, 0 )
hDib:= FILOAD( nSrcFormat, cSrcFile, 0 )
hDib2:= FICNV24( hDib )
lOk:= FISAVE( nDstFormat, hDib2, cDstFile, nQuality )
FIUNLOAD( hDib )
FIUNLOAD( hDib2 )
endif
return lOkHow do you rotate it ?
I rotate bitmap in TXImage. How I can save result to file ?
Rotation:
a) Mouse: Shift-MouseWheel
b) Touch: Rotate gesture by fingers
Zoom/Unzoom:
a) Mouse: MouseWheel
b) Touch: Zoom and Pinch gestures with fingers
Pan
(a) Mouse: Mouse drag
(b) Touch: Move with finger
The image that is loaded itself is never modified. The rotation or zoom/unzoom are only visual (in the recent versions) and that helped high performance.
If you want to save a rotated image of a png, we shall soon post a sample here.
Thank you.
How then is it possible to load bitmap into memory. Rotate it and save it to a file ?
oImage := GdiBmp():New( "oldfile.png" )
oImage:Rotate( nRotate )
oImage:Save( "newfile.png" )
oImage:End()Mr.Rao, thank for your help !!
Hi Mr. Rao,
What file types supports GDIBmp class other than PNG?
bmp,jpg,tif,emf,wmf,ico
And gif. But please note that saving gifs still gives a poor quality result.
EMG
Nages,
May I suggest just using the degrees themselves (90,180,270) for the rotation rather than a code (1,2,3)? This would be easier to remember.
Actually, would it be possible to rotate in degree increments( e.g. 92 degrees)? This would help de-skew crooked scans, etc..
James
James Bott wrote:Nages,
May I suggest just using the degrees themselves (90,180,270) for the rotation rather than a code (1,2,3)? This would be easier to remember.
James
James Bott wrote:Nages,
Actually, would it be possible to rotate in degree increments( e.g. 92 degrees)? This would help de-skew crooked scans, etc..
James
Latest information:
As you all may be knowing, tgdiplus.prg and gdiplus.cpp are contributed by our gdi+ expert Mr Manuel Alwarez.
Just now we received his latest update which provides for a new method ImageRotate( nDegrees, lAdjust ). So now it is possible to reotate the image by any angle and save. This will be available from the next release.
Awsome.
Thanks for looking into it.
James