To Linares! About :loadFromString()

To Linares! About :loadFromString()

Postby JC » Sun Mar 02, 2008 1: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...

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

Postby Antonio Linares » Sun Mar 02, 2008 8:02 am

Check that you are retrieving the same string:

Code: Select all  Expand view
            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
User avatar
Antonio Linares
Site Admin
 
Posts: 42080
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

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

Postby Antonio Linares » Sun Mar 02, 2008 7: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
User avatar
Antonio Linares
Site Admin
 
Posts: 42080
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

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

Postby Antonio Linares » Sun Mar 02, 2008 8: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
User avatar
Antonio Linares
Site Admin
 
Posts: 42080
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby JC » Sun Mar 02, 2008 8: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?
Last edited by JC on Sun Mar 02, 2008 8:37 pm, edited 1 time in total.
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
User avatar
JC
 
Posts: 445
Joined: Thu Feb 21, 2008 11:58 am
Location: Brazil

Postby JC » Sun Mar 02, 2008 8:36 pm

The mini example...

Code: Select all  Expand view
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

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

Postby Antonio Linares » Tue Mar 04, 2008 8: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
User avatar
Antonio Linares
Site Admin
 
Posts: 42080
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

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

Postby JC » 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
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: No registered users and 74 guests