Saving bitmap from TXImage.

Saving bitmap from TXImage.

Postby Natter » Fri Feb 19, 2016 10:57 am

Change bitmap in TXImage. Can I save the modified bitmap into a file ?
Natter
 
Posts: 1226
Joined: Mon May 14, 2007 9:49 am

Re: Saving bitmap from TXImage.

Postby Natter » Fri Feb 19, 2016 1:23 pm

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

Code: Select all  Expand view  RUN
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
Natter
 
Posts: 1226
Joined: Mon May 14, 2007 9:49 am

Re: Saving bitmap from TXImage.

Postby Antonio Linares » Sat Feb 20, 2016 9:06 am

How do you rotate it ?
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42203
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Saving bitmap from TXImage.

Postby Natter » Sat Feb 20, 2016 9:39 am

I rotate bitmap in TXImage. How I can save result to file ?
Natter
 
Posts: 1226
Joined: Mon May 14, 2007 9:49 am

Re: Saving bitmap from TXImage.

Postby nageswaragunupudi » Sat Feb 20, 2016 10:45 am

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.
Regards

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

Re: Saving bitmap from TXImage.

Postby Natter » Sat Feb 20, 2016 11:57 am

Thank you.
How then is it possible to load bitmap into memory. Rotate it and save it to a file ?
Natter
 
Posts: 1226
Joined: Mon May 14, 2007 9:49 am

Re: Saving bitmap from TXImage.

Postby nageswaragunupudi » Sat Feb 20, 2016 5:57 pm

This is an example code for rotating an image by 90,180,270 degrees clock-wise:
Code: Select all  Expand view  RUN
  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
User avatar
nageswaragunupudi
 
Posts: 10690
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Saving bitmap from TXImage.

Postby Natter » Sat Feb 20, 2016 8:19 pm

Mr.Rao, thank for your help !!
Natter
 
Posts: 1226
Joined: Mon May 14, 2007 9:49 am

Re: Saving bitmap from TXImage.

Postby Horizon » Sun Feb 21, 2016 9:02 am

Hi Mr. Rao,

What file types supports GDIBmp class other than PNG?
Regards,

Hakan ONEMLI

Harbour & MSVC 2022 & FWH 23.04
Horizon
 
Posts: 1322
Joined: Fri May 23, 2008 1:33 pm

Re: Saving bitmap from TXImage.

Postby nageswaragunupudi » Sun Feb 21, 2016 9:23 am

bmp,jpg,tif,emf,wmf,ico
Regards

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

Re: Saving bitmap from TXImage.

Postby Enrico Maria Giordano » Mon Feb 22, 2016 9:33 am

And gif. But please note that saving gifs still gives a poor quality result.

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8725
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: Saving bitmap from TXImage.

Postby James Bott » Mon Feb 22, 2016 3:19 pm

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
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Re: Saving bitmap from TXImage.

Postby nageswaragunupudi » Mon Feb 22, 2016 3:48 pm

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
User avatar
nageswaragunupudi
 
Posts: 10690
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Saving bitmap from TXImage.

Postby nageswaragunupudi » Mon Feb 22, 2016 6:03 pm

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.
Regards

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

Re: Saving bitmap from TXImage.

Postby James Bott » Mon Feb 22, 2016 7:29 pm

Awsome.

Thanks for looking into it.

James
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 80 guests