Click here to Skip to main content
15,885,161 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How to read the JPEG file and store in CString variable? I want to read the JPEG file from the hard drive and to read it in CString. But i have tried with CFile but the binary data is stored very well in char array but while copying to CString it fails,
only first 4 characters in char array is being copied into the CString variable.
How to perform this??
Posted
Comments
Sergey Alexandrovich Kryukov 16-Jun-11 1:17am    
Why on Earth?
--SA
Gokulnath007 16-Jun-11 5:36am    
To store it in the MYSQL blob field. Actually i am executing using ExecuteSQl() function which needs a string.

1 solution

This sounds like a retarded thing to do. You know that your CString will contain garbage, not the image in any meaningful way ? To do this, you'd need to UUEncode it, thus making it bigger, but making it able to be stored as a string. Then you'd have a representation of a JPEG that it's possible to decode and turn back in to the bytes of a JPEG, inside a CString. But, it would not actually be the information in the original JPEG, let alone useful in any way as an image.
 
Share this answer
 
Comments
Gokulnath007 16-Jun-11 5:37am    
To store it in the MYSQL blob field. Actually i am executing using ExecuteSQl() function which needs a string. I tried reading the file and i got the image bytes in a char array. I just want to copy those into CString. While trying that it just copies the first 4 characters in it. Rest of the characters are omitted. NULL is also there in the char array.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900