TBitMap to file

Post Reply
Natter
Posts: 1244
Joined: Mon May 14, 2007 9:49 am

TBitMap to file

Post by Natter »

I get an icon associated with a file type
img:=BmpFromIcon(EXTRACTASSICON( 0, nam, @sol))
img:=TBitmap():Define(,, oWnd:aControls[1]:aDialogs[2], img)

img - is an object of TBitMap. How can I save this bitmap to a file ?
User avatar
nageswaragunupudi
Posts: 10733
Joined: Sun Nov 19, 2006 5:22 am
Location: India
Been thanked: 10 times
Contact:

Re: TBitMap to file

Post by nageswaragunupudi »

Code: Select all | Expand

function icofile2bmpfile()

   local cFile, cBmpFile
   local hIco, hBmp, hDib

   cFile    := "\fwh\manual\manual FWH english.doc"
   cBmpFile := "doc.bmp"

   if File( cFile )
      hIco     := ICON_READ( TrueName( cFile ) )
      hBmp     := BMPFROMICON( hIco )
      hDib     := DibFromBitmap( hBmp )
      DibWrite( cBmpFile, hDib )

      DestroyIcon( hIco )
      DeleteObject( hBmp )
      GlobalFree( hDIB )
   endif

return nil
 

The functions I used are available in all versions of FWH.
If you use current versions of FWH you do not need to convert files from ico to bmp, because you can directly use ico files for any purpose.
Regards

G. N. Rao.
Hyderabad, India
User avatar
Silvio.Falconi
Posts: 7184
Joined: Thu Oct 18, 2012 7:17 pm
Been thanked: 9 times

Re: TBitMap to file

Post by Silvio.Falconi »

ib think we can use gdi save functions
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour March-April 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
nageswaragunupudi
Posts: 10733
Joined: Sun Nov 19, 2006 5:22 am
Location: India
Been thanked: 10 times
Contact:

Re: TBitMap to file

Post by nageswaragunupudi »

Silvio

The function I suggested uses GDI functions.
I guess you mean GDI+, not GDI.
Yes, there are many ways to do the same thing.
I preferred to do it in the simplest and shortest manner, using functions existing in FWH of all versions.
Regards

G. N. Rao.
Hyderabad, India
Natter
Posts: 1244
Joined: Mon May 14, 2007 9:49 am

Re: TBitMap to file

Post by Natter »

Thank you, Mr. Rao !
Post Reply