Something like oImage:loadFromString()

Post Reply
User avatar
JC
Posts: 445
Joined: Thu Feb 21, 2008 11:58 am
Location: Brazil
Contact:

Something like oImage:loadFromString()

Post 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!
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Post 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.   
regards, saludos

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

Post 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
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
JC
Posts: 445
Joined: Thu Feb 21, 2008 11:58 am
Location: Brazil
Contact:

Post by JC »

Amazing! Worked perfectly.

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

Greats!
Post Reply