I'm creating a html-pages which contains a picture-stream as base64-string. For the conversion I used CryptBinaryToString- function of crypt32.dll - based on an example from these Forum and it works fine.
Now, I have to receive an base64 String, convert and store it as image-File (jpg). I tried to do it with CryptStringToBinaryA(). It looks not to bad - the length of the result string is > 0 - but I cannot show the image at a Picture-Container or store it.
Is there any example or sample I can have a look?
Thank you very much !
(By the way - I'm using Version 6.3)
- Founder/Site Admin
- Posts: 2928
- Joined: 24 Feb 2017, 09:12
- Location: Gouda, The Netherlands
You can put the Base64 encoded string in a separate file and the TD source you are now using to convert the Base64 string to JPG.
ZIP it and put as attachment.
I don't use crypt32.dll, I have my own conversion dll, but first of all I would check if the file contains a valid image, a JPG-file should start with "ÿØÿà<nul><dle>JFIF<nul>". Do you have the original file to check size and content? Maybe it is truncated at a null byte. In this case ensure you use Long String instead of String for all operations, that is often the reason of such trouble.
The zip-file also includes a jpg-file and a file containing the base64String of this Image.
you have to use the Function CryptStringToBinaryW - the Unicode-Version.
And there is a mistake in the parameter declaration of this function. The strings have to be LPWSTR instead of LPSTR.
Code: Select all
Function: CryptStringToBinaryW Parameters String: LPWSTR Number: DWORD Number: DWORD String: LPWSTR Receive Number: LPDWORD Receive Number: LPDWORD Receive Number: LPDWORD
[ frevel & fey ] Software-System GmbH
Who is online
Users browsing this forum: [Ccbot] and 0 guests