Page 1 of 1

Something like oImage:loadFromString()

Posted: Thu Feb 28, 2008 12:49 pm
by JC
Hi Guys!


I have trying this:

Code: Select all


cResult := Result of this query -> [ SELECT image FROM table1 ]

memoWrit( "C:\IMG001.BMP", cResult )

oImagem:loadBMP( "C:\IMG001.BMP" )
oImagem:refresh()


Is there a way to load an image into an object of type TBitmap or any other kind of a string directly from the database?

Something like loadFromString () method from the Delphi?

Thanks for all!
Greats!

Posted: Thu Feb 28, 2008 5:29 pm
by Antonio Linares
Julio,

Try this:

Code: Select all

METHOD LoadFromString( cString ) CLASS TBitmap

   local hBmpOld  := ::hBitmap
   local hPalOld  := ::hPalette

   if Empty( cString )
      return .F.
   endif

   ::hBitmap = CreateMemBitmap( ::GetDC(), cString )
   ::ReleaseDC()

   if ! Empty( hBmpOld )
      PalBmpFree( hBmpOld, hPalOld )
   endif

   PalBmpNew( ::hWnd, ::hBitmap, nil )

return .T.   

Posted: Thu Feb 28, 2008 5:38 pm
by Antonio Linares
CreateMemBitmap() has to be implemented this way:

Code: Select all

#pragma BEGINDUMP

#include <hbapi.h>
#include <windows.h>

HBITMAP CreateMemBitmap( HDC hDC, BYTE far * cBitmap );

HB_FUNC( CREATEMEMBITMAP )
{
   hb_retnl( ( LONG ) CreateMemBitmap( ( HDC ) hb_parnl( 1 ), hb_parc( 2 ) ) );
}

#pragma ENDDUMP

Posted: Fri Feb 29, 2008 2:17 pm
by JC
Amazing! Worked perfectly.

I thank the tip Linares.. this helped very, very, very much! Very much!

Greats!