Saving bitmap from TXImage.
Re: Saving bitmap from TXImage.
Used the example XIMAGE01.PRG
Open bitmap 2.png, rotate it and save in a file named my.png
It's works. But the bitmap remains unchanged
Open bitmap 2.png, rotate it and save in a file named my.png
It's works. But the bitmap remains unchanged
Code: Select all | Expand
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 lOk
- Antonio Linares
- Site Admin
- Posts: 42529
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Has thanked: 31 times
- Been thanked: 77 times
- Contact:
- nageswaragunupudi
- Posts: 10721
- Joined: Sun Nov 19, 2006 5:22 am
- Location: India
- Been thanked: 8 times
- Contact:
Re: Saving bitmap from TXImage.
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.
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.
Regards
G. N. Rao.
Hyderabad, India
G. N. Rao.
Hyderabad, India
Re: Saving bitmap from TXImage.
Thank you.
How then is it possible to load bitmap into memory. Rotate it and save it to a file ?
How then is it possible to load bitmap into memory. Rotate it and save it to a file ?
- nageswaragunupudi
- Posts: 10721
- Joined: Sun Nov 19, 2006 5:22 am
- Location: India
- Been thanked: 8 times
- Contact:
Re: Saving bitmap from TXImage.
This is an example code for rotating an image by 90,180,270 degrees clock-wise:
Values of nRotate
1 for 90 deg
2 for 180 deg
3 for 270 deg
Important note:
The above constants of nRotate are the correct values. But just now while testing the above program, I noticed a bug in the C++ function. We shall fix the bug in the next version.
But with this bug the following values of nRotate give the desired results. You may use these values till next version:
3 for 90 deg
4 for 180 deg
2 for 270 deg
Code: Select all | Expand
oImage := GdiBmp():New( "oldfile.png" )
oImage:Rotate( nRotate )
oImage:Save( "newfile.png" )
oImage:End()
Values of nRotate
1 for 90 deg
2 for 180 deg
3 for 270 deg
Important note:
The above constants of nRotate are the correct values. But just now while testing the above program, I noticed a bug in the C++ function. We shall fix the bug in the next version.
But with this bug the following values of nRotate give the desired results. You may use these values till next version:
3 for 90 deg
4 for 180 deg
2 for 270 deg
Regards
G. N. Rao.
Hyderabad, India
G. N. Rao.
Hyderabad, India
Re: Saving bitmap from TXImage.
Hi Mr. Rao,
What file types supports GDIBmp class other than PNG?
What file types supports GDIBmp class other than PNG?
Regards,
Hakan ONEMLI
Harbour & MSVC 2022 & FWH 23.04
Hakan ONEMLI
Harbour & MSVC 2022 & FWH 23.04
- nageswaragunupudi
- Posts: 10721
- Joined: Sun Nov 19, 2006 5:22 am
- Location: India
- Been thanked: 8 times
- Contact:
- Enrico Maria Giordano
- Posts: 8753
- Joined: Thu Oct 06, 2005 8:17 pm
- Location: Roma - Italia
- Has thanked: 1 time
- Been thanked: 4 times
- Contact:
Re: Saving bitmap from TXImage.
And gif. But please note that saving gifs still gives a poor quality result.
EMG
EMG
- James Bott
- Posts: 4840
- Joined: Fri Nov 18, 2005 4:52 pm
- Location: San Diego, California, USA
- Contact:
Re: Saving bitmap from TXImage.
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
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
- nageswaragunupudi
- Posts: 10721
- Joined: Sun Nov 19, 2006 5:22 am
- Location: India
- Been thanked: 8 times
- Contact:
Re: Saving bitmap from TXImage.
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
This is what is in my mind too.
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
The present function is only a wrapper to the gdi+ function, which allows only rotation in multiples of 90 deg with option to flip the image. I am planning to provide rotation by any angle in the coming versions.
As of now this is an option. Ximage provides for rotation by any angle. But this is visual only and the image itself is not rotated. What can be done now is to use ximage, rotate by the required angle and then save the control as bitmap with oImage:SaveToBmp( <filename> )
Regards
G. N. Rao.
Hyderabad, India
G. N. Rao.
Hyderabad, India
- nageswaragunupudi
- Posts: 10721
- Joined: Sun Nov 19, 2006 5:22 am
- Location: India
- Been thanked: 8 times
- Contact:
Re: Saving bitmap from TXImage.
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.
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.
Regards
G. N. Rao.
Hyderabad, India
G. N. Rao.
Hyderabad, India
- James Bott
- Posts: 4840
- Joined: Fri Nov 18, 2005 4:52 pm
- Location: San Diego, California, USA
- Contact: