Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Native Development

Reply
Developer
Posts: 20
Registered: ‎07-27-2012
My Device: PlayBook / Z10 LE
My Carrier: PLUS GSM

Base64 encoded JPG and ImageView

Does anyone know how can I display Base64 encoded JPG image in ImageView? I have a string with base64 jpg and I would like to display it in ImageView. Preferably in QML. Saving to filesystem isn't the solution, as I have quite a few images to display in list.

Developer
Posts: 1,177
Registered: ‎03-20-2013
My Device: Red LE Developer Z10
My Carrier: Fido

Re: Base64 encoded JPG and ImageView

[ Edited ]

UPDATE: Ok, this should work, but requires you to know some details about the jpeg you are decoding...

 

If the string is a QString, try something like this:

 

Image decodeImage( const QString& encodedImage, int width, int height, int bytesPerLine ) {
   return Image( ImageData&colon;:fromPixels( reinterpret_cast<unsigned char*>( encodedImage.toLatin1().data() ), width, height, bytesPerLine ) );
}

...and then plug the result into the ImageView. I haven't tested this, but it should work.

 


Saperus wrote:

Does anyone know how can I display Base64 encoded JPG image in ImageView? I have a string with base64 jpg and I would like to display it in ImageView. Preferably in QML. Saving to filesystem isn't the solution, as I have quite a few images to display in list.






Developer of Built for BlackBerry certified multiFEED RSS/Atom feed reader and aggregator.  multiFEED Icon

Play nice: Clicking Like Button on posts that helped you not only encourages others to continue sharing their experience, but also improves your own rating on this board. Also, don't forget to accept a post if it solves your problem or answers your question.