Diese Seite mit anderen teilen ...

Informationen zum Thema:
Forum:
WinDev Forum
Beiträge im Thema:
3
Erster Beitrag:
vor 2 Jahren, 2 Monaten
Letzter Beitrag:
vor 2 Jahren, 1 Monat
Beteiligte Autoren:
Yogi Yang, Fabrice Harari

[WX17] - How to decode image string and load the image in Image Control?

Startbeitrag von Yogi Yang am 19.12.2015 07:08

Hello,

In an application I am fetching data from a remote server by calling a php script using HTTP request.

This php scrip is returning the following string encoded image string along with other information:

data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADwAAAA8CAIAAAC1nk4lAAAYj0lEQVRogb2aeXRd1ZXmf/tObx6kp8GSnibbsjzhAWMmk4DNFJKQAEmadOZ0QjXVFZIKBSGVJgmVqVZVEipUUjQZgAwsCATi4JCAATMZM3qA2HgeJVmyJGt6evO79+7+Q4NtMJS7qrvP0tLb795zpO/u851v73P2FVXlLW3ioohMG2/t8/+onRTPm5rxdgOmgZ464unh/0nj321y6l3/vzVVnfDU2xnGdL+3/RMTvz1Xj/9KSRX1wCtozxu67g7tO/zmgU8+qpcs1jX3/cdwn2CI6HG3rAnrnTmgf7pdFlygbfO17EnPEY4cJvYjMTLss3RTt3gBks1ceO2bRklVVM+u5w8/1mVpmt71H1wWE3C3v66GL3OXTlyz3gnrxKj7voI5U9vmsuk+2XkX+7fSURJvlAWQbmTzmfzVd58tBn551/OHR4rRgmm5Qc9LjI4Pr/uoK3uj3HCjfv6zPPo8zDhlnCcsJ73h69x7W2n2nOBzGyeunITT0zOCB0/+Nfm1LLueJ66TmTbnnYbdwMbXGWqmvJxIkHSZOqcQTQxtt/oO7fn9cPMDG53unkhle+GjH1h035wrueZvuU505Hdyz+oKC00fwzg2+xMC9VbiMoF7+1auu0EaX9NKng3V0n1oUs183+dEehwbPLhJdlyuNRdRHpJ4kLDpZw+P9OX6dh4q7jJG3MCIE3ADalbnYw2j83dLU7LarkvvqF10V1fzw/vSInNezn8h+cGt1D/L5R/h5vS685/Y/3LvNVfNxzKmPXPS6QW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NoyTJH5TS3jaOIWnPw77Ccb/cTsV9fjfP81LtkC96dEAAAAASUVORK5CYII=

How to decode this string and load the image in Image Control?

I have checked that this string is a valid image by pasting it in Chrome.

TIA

Yogi Yang

Antworten:

Hi

Just use the decode function wit the base64 option on the data part of the string (iVBOR...) and set the result in your image field (or save it to disk as a png)

Best regards

von Fabrice Harari - am 19.12.2015 10:22
Fabrice,

Thanks for the hint.

I am using this code:

sImgStr is string

sImgStr = "iVBORw0..."

IMG_NoName1 = Uncrypt(sImgStr,"",cryptNone,encodeBASE64)


But it is not working. I mean it is not giving any errors but the image come up corrupted.

TIA

Yogi Yang

von Yogi Yang - am 01.01.2016 12:40
Zur Information:
MySnip.de hat keinen Einfluss auf die Inhalte der Beiträge. Bitte kontaktieren Sie den Administrator des Forums bei Problemen oder Löschforderungen über die Kontaktseite.
Falls die Kontaktaufnahme mit dem Administrator des Forums fehlschlägt, kontaktieren Sie uns bitte über die in unserem Impressum angegebenen Daten.