Something like oImage:loadFromString()

Something like oImage:loadFromString()

Postby JC » Thu Feb 28, 2008 12:49 pm

Hi Guys!


I have trying this:

Code: Select all  Expand view

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!
User avatar
JC
 
Posts: 445
Joined: Thu Feb 21, 2008 11:58 am
Location: Brazil

Postby Antonio Linares » Thu Feb 28, 2008 5:29 pm

Julio,

Try this:
Code: Select all  Expand view
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.   
regards, saludos

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

Postby Antonio Linares » Thu Feb 28, 2008 5:38 pm

CreateMemBitmap() has to be implemented this way:
Code: Select all  Expand view
#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
regards, saludos

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

Postby JC » Fri Feb 29, 2008 2:17 pm

Amazing! Worked perfectly.

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

Greats!
User avatar
JC
 
Posts: 445
Joined: Thu Feb 21, 2008 11:58 am
Location: Brazil


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 46 guests