Page 1 of 1
To Linares! About :loadFromString()
Posted: Sun Mar 02, 2008 1:30 am
by JC
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
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!
Posted: Sun Mar 02, 2008 8:02 am
by Antonio Linares
Check that you are retrieving the same string:
Code: Select all
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.
Posted: Sun Mar 02, 2008 5:49 pm
by JC
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!
Posted: Sun Mar 02, 2008 7:34 pm
by Antonio Linares
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.
Posted: Sun Mar 02, 2008 7:52 pm
by JC
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!
Posted: Sun Mar 02, 2008 8:17 pm
by Antonio Linares
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
Posted: Sun Mar 02, 2008 8:23 pm
by JC
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?
Posted: Sun Mar 02, 2008 8:36 pm
by JC
The mini example...
Code: Select all
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
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 )
Posted: Tue Mar 04, 2008 8:18 am
by Antonio Linares
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.
Posted: Tue Mar 04, 2008 11:49 am
by JC
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.
Posted: Tue Mar 04, 2008 11:19 pm
by JC
Linares, thanks for your help...
Thats ok now!