marcioe Posted December 3, 2019 Report Share Posted December 3, 2019 Amigos, é assim, a imagem está salva no cadastro de produtos, porem queria exibir ela no grid do browse a imagem exibida eu fiz o teste usando um BMP dai sim exibe, porem queia que fosse exibido JPG aFotos_produtos:=SqlArray("SELECT FOTO FROM foto_produto order by ID_FOTO") xbrowse(aFotos_produtos) Hoje para gravar a foto é desta forma *------------------------------------------------------------------------------- * Gravar a foto do Produto *------------------------------------------------------------------------------- FUNCTION INSERE_APAGA_FOTO_PRODUTO(T_OPERACAO_PRODUTOS) T_ID_FOTO := 0 *---------------------------------------------------------------------------- IF FSize(DRIVE_TR+"\"+CURDIR() + "\TMP_IMG.JPG") > 0 BEGIN TRANSACTION cQuery_Mtabela := 'DELETE from foto_produto where CODIGO_PRODUTO = ' + TRANSFORMA_SQL(T_CODI_PRODUTOS,"N",06,0) + ' LIMIT 1' COMITAR_DADOS_SQL(cQuery_Mtabela) END TRANSACTION BEGIN TRANSACTION cQuery_Mtabela := "INSERT INTO foto_produto ( " cQuery_Mtabela := cQuery_Mtabela + " CODIGO_PRODUTO " cQuery_Mtabela := cQuery_Mtabela + ",DATA_FOTO " cQuery_Mtabela := cQuery_Mtabela + ",FOTO " cQuery_Mtabela := cQuery_Mtabela + " ) VALUES ( " cQuery_Mtabela := cQuery_Mtabela + TRANSFORMA_SQL(T_CODI_PRODUTOS,"N",06,0) + "," cQuery_Mtabela := cQuery_Mtabela + TRANSFORMA_SQL(DATE(),"D",08,0) + "," cQuery_Mtabela := cQuery_Mtabela + ANY2SQL( MemoRead( (T_FOTOGRAFIA) ) ) cQuery_Mtabela := cQuery_Mtabela + " )" COMITAR_DADOS_SQL(cQuery_Mtabela) END TRANSACTION HB_GCAll(.T.) ENDIF RETURN .T. Quote Link to comment Share on other sites More sharing options...
gilmer Posted December 4, 2019 Report Share Posted December 4, 2019 Bom Dia, Você não pode salvar diretamente, precisa converter Base64 por conta de caracteres especiais. Existe vários tópicos neste mesmo assunto em vários outros forum, inclusive do MySql Quote Link to comment Share on other sites More sharing options...
marcioe Posted December 4, 2019 Author Report Share Posted December 4, 2019 o engraçado que se gravo um BMP ele exibe.... Com a mesma Rotina se for BMP ele exibe Quote Link to comment Share on other sites More sharing options...
gilmer Posted December 5, 2019 Report Share Posted December 5, 2019 Marcio, Tem diversos assuntos sobre este assunto em todas as linguagens, verifique. Quote Link to comment Share on other sites More sharing options...
rochinha Posted December 5, 2019 Report Share Posted December 5, 2019 Amiguinhos, Marcio Carregue a imagem usando fRead() ou MemoRead(), converta com as funções Base64 que você usa no SAT e salve o resultado num campo Blob ou Varchar. Quote Link to comment Share on other sites More sharing options...
marcioe Posted December 5, 2019 Author Report Share Posted December 5, 2019 Amiguinhos, Marcio Carregue a imagem usando fRead() ou MemoRead(), converta com as funções Base64 que você usa no SAT e salve o resultado num campo Blob ou Varchar. Como assim Eu gravo assim no banco de dados BEGIN TRANSACTION cQuery_Mtabela := "INSERT INTO foto_produto ( " cQuery_Mtabela := cQuery_Mtabela + " CODIGO_PRODUTO " cQuery_Mtabela := cQuery_Mtabela + ",DATA_FOTO " cQuery_Mtabela := cQuery_Mtabela + ",FOTO " cQuery_Mtabela := cQuery_Mtabela + " ) VALUES ( " cQuery_Mtabela := cQuery_Mtabela + TRANSFORMA_SQL(T_CODI_PRODUTOS,"N",06,0) + "," cQuery_Mtabela := cQuery_Mtabela + TRANSFORMA_SQL(DATE(),"D",08,0) + "," cQuery_Mtabela := cQuery_Mtabela + ANY2SQL( MemoRead( (T_FOTOGRAFIA) ) ) cQuery_Mtabela := cQuery_Mtabela + " )" COMITAR_DADOS_SQL(cQuery_Mtabela) END TRANSACTION HB_GCAll(.T.) Quote Link to comment Share on other sites More sharing options...
rochinha Posted December 5, 2019 Report Share Posted December 5, 2019 Amiguinhos, Marcio Faça o teste e adaptação: Function EncodeFile( strPicPath ) LOCAL adTypeBinary := 1 // Tipo Binary // Variaveis para codificacao LOCAL objXML LOCAL objDocElem // Variavel para ler o conteudo da imagem LOCAL objStream // Abre data stream da imagem objStream := TOleAuto():New( "ADODB.Stream" ) objStream:Type := adTypeBinary objStream:Open() objStream:LoadFromFile( strPicPath ) // Cria XML e node raiz // que ira conter o dado da imagem objXML := TOleAuto():New( "MSXml2.DOMDocument" ) objDocElem := objXML:createElement( "Base64Data" ) objDocElem.dataType := "bin.base64" // Fixa o valor binario objDocElem:nodeTypedValue := objStream:Read() // Pega o valor codificado em Base64 EncodeFile := objDocElem:Text return nil Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.