FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour To Linares! About :loadFromString()
Posts: 445
Joined: Thu Feb 21, 2008 11:58 AM
To Linares! About :loadFromString()
Posted: Sun Mar 02, 2008 01:30 AM
Hello Linares.

First, thanks for your implementation of loadFromString method. Is really perfect!

But, I am a strange situation with this implementation.. I will describe it below...

       REDEFINE   BITMAP oImagem ID 4001 OF oFolder:aDialogs[3] CENTER
                         
       WITH OBJECT oImagem

            IF !isEmpty( aCampos["cImage"] )
               :loadFromString( aCampos["cImage"] )
            ELSE
               :loadImage( "IMG_NO_PHOTO" )
            ENDIF
            
            :lStretch := .T.
            :refresh()

       END


The variable aCampos["cImage"] is loaded via a query in database on MySQL.


This same code works in my computer on office, a Windows XP Professional with SP2, totally updated.

But, this same code not works in my house... a Windows XP Professional with SP2, totally updated too.

Please... what I'm doing's wrong?

Thanks very much for all Linares!

Greats!
Peace and lighting!

JĂșlio CĂ©sar M. Ferreira

FWH 8.10 / xHB 1.1.0 / xDevStudio 0.72 / Pelles C 5.0.1 / SQLLIB 1.9
Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM
To Linares! About :loadFromString()
Posted: Sun Mar 02, 2008 08:02 AM
Check that you are retrieving the same string:

            IF !isEmpty( aCampos["cImage"] ) 
               MsgInfo( Len(  aCampos["cImage"] ) ) // here !
               MsgInfo( nStrCRC( aCampos["cImage"] ) ) // here !
               :loadFromString( aCampos["cImage"] )

Check that you get the same length and contents from both computers.
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 445
Joined: Thu Feb 21, 2008 11:58 AM
To Linares! About :loadFromString()
Posted: Sun Mar 02, 2008 05:49 PM

This is the return of the test:

msgInfo( len( aCampos["cImage"] ) ) = 85369
msgInfo( nStrCRC( aCampos["cImage"] ) ) = 2008508687

I don't understand... What is this? Why they are different?

Thanks Linares!

Greats!

Peace and lighting!

JĂșlio CĂ©sar M. Ferreira

FWH 8.10 / xHB 1.1.0 / xDevStudio 0.72 / Pelles C 5.0.1 / SQLLIB 1.9
Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM
To Linares! About :loadFromString()
Posted: Sun Mar 02, 2008 07:34 PM

Those two values should be the same ones in your office pc and in your home pc. You should get 85369 and 2008508687 in the two computers.

Not that the two values should be the same.

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 445
Joined: Thu Feb 21, 2008 11:58 AM
To Linares! About :loadFromString()
Posted: Sun Mar 02, 2008 07:52 PM

Ok Linares... is correct!

I can understand this... but... why this is happening if the code is the same? And, apparently, the operating system also is the same?

I tried to record a new image in database, but the same situation repeats again... why?

Note that I'm testing this situation in my home pc... and they return different values in the same machine and the image not appear in object TBitmap! But, in my office with the same situation, the image appear correctly in the object TBitmap!

The image file is the same in both!

Thanks for your help Linares!

Greats!

Peace and lighting!

JĂșlio CĂ©sar M. Ferreira

FWH 8.10 / xHB 1.1.0 / xDevStudio 0.72 / Pelles C 5.0.1 / SQLLIB 1.9
Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM
To Linares! About :loadFromString()
Posted: Sun Mar 02, 2008 08:17 PM

JC,

You have to provide us more info:

  • What database engine are you using
  • How the field is defined
  • How are you fillling it
  • a small and self contained PRG sample to reproduce it.

Its the only way to provide tech support

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 445
Joined: Thu Feb 21, 2008 11:58 AM
To Linares! About :loadFromString()
Posted: Sun Mar 02, 2008 08:23 PM
Antonio Linares wrote:JC,

You have to provide us more info:

- What database engine are you using
- How the field is defined
- How are you fillling it
- a small and self contained PRG sample to reproduce it.

Its the only way to provide tech support


Linares, the informations:

The database: MySQL 5.0.45-community-nt
The field: image_product longblob not null
Filling: any2Sql( memoRead( alltrim( "FULL_PATH_OF_IMAGE_FILE" ) ) )

How I can send the example for you? For this message too?
Peace and lighting!

JĂșlio CĂ©sar M. Ferreira

FWH 8.10 / xHB 1.1.0 / xDevStudio 0.72 / Pelles C 5.0.1 / SQLLIB 1.9
Posts: 445
Joined: Thu Feb 21, 2008 11:58 AM
To Linares! About :loadFromString()
Posted: Sun Mar 02, 2008 08:36 PM
The mini example...

FUNCTION testImage( oWnd )

LOCAL cQuery, aQuery, aCampos
LOCAL oDlg, oImage


cQuery := "SELECT image_product FROM products WHERE reg_id = 1"
aQuery := SQLArray( cQuery )

aCampos["cImage"] := aQuery[1, 1]


DEFINE DIALOG oDlg RESOURCE "CAD_PRO" OF oWnd

       oDlg:lHelpIcon := .F.
       oDlg:cargo     := .F.

       REDEFINE BITMAP oImage ID 4001 OF oDlg CENTER

       WITH OBJECT oImage

            IF !isEmpty( aCampos["cImage"] )
               :loadFromString( aCampos["cImage"] )
            ELSE
               :loadImage( "IMG_NO_PHOTO" )
            ENDIF

            :lStretch := .T.
            :refresh()

       END

       REDEFINE BUTTON ID 4002 OF oDlg ACTION loadImage( oImage, @aCampos ) ;


ACTIVATE DIALOG oDlg CENTER

RETURN


The loadImage() function

STATIC FUNCTION loadImage( oImage, aCampos )

LOCAL cFileTypes := "Windows Bitmap |*.bmp| JPEG |*.jpg"
LOCAL cPathImage    := ""


cPathImage := cGetFile32( cFileTypes, "The Image..." )

IF file( cPathImage ) .AND. !( fileSize( cPathImage ) / 1024 ) > 2000 )

   aCampos["cImage"] := cPathImage

   oImage:loadBMP( aCampos["cImage"] )
   oImage:refresh()

   sysRefresh()

ENDIF

RETURN( NIL )
Peace and lighting!

JĂșlio CĂ©sar M. Ferreira

FWH 8.10 / xHB 1.1.0 / xDevStudio 0.72 / Pelles C 5.0.1 / SQLLIB 1.9
Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM
To Linares! About :loadFromString()
Posted: Tue Mar 04, 2008 08:18 AM

JC,

The same code from different computers should produce the same results, unless there is a problem with your remote database conection, or different settings in those computers.

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 445
Joined: Thu Feb 21, 2008 11:58 AM
To Linares! About :loadFromString()
Posted: Tue Mar 04, 2008 11:49 AM

Linares, I did some tests:

My routine saves the image as it should in the database. With the application MySQL Query Browser, I can see the picture properly.

Apparently, the object TBitmap is not showing the image in my home pc. Is not an error of the method loadFromString.

The two machines are prepared in the same conditions, with the same operational system. I don't understand this situation...

They should produce the same results... but, if the imagem is not showing?

This is more one problem to resolve.

Peace and lighting!

JĂșlio CĂ©sar M. Ferreira

FWH 8.10 / xHB 1.1.0 / xDevStudio 0.72 / Pelles C 5.0.1 / SQLLIB 1.9
Posts: 445
Joined: Thu Feb 21, 2008 11:58 AM
To Linares! About :loadFromString()
Posted: Tue Mar 04, 2008 11:19 PM

Linares, thanks for your help...

Thats ok now!

Peace and lighting!

JĂșlio CĂ©sar M. Ferreira

FWH 8.10 / xHB 1.1.0 / xDevStudio 0.72 / Pelles C 5.0.1 / SQLLIB 1.9

Continue the discussion