How to put image dynamically in a Card? - google-glass

I am querying the images using REST Service where I receive it in a Base64 encoded format. How do I convert it to Bitmap, and then put it on the Card? I am using CardScroller

Without giving any code, what you ask is an entire tutorial on how to create and populate a CardscrollerView...
You will need to convert your Base64 image to an imageview first, here is a similar topic : Base64 To Imageview
Then you will need to populate your imageview in your CardScrollView like this example, here is an example : CardScrollView Tutorial

Related

How can I convert inMemoryUploadedFile into string to pass it over an api?

I want to pass user uploaded images into an api form my view
How can I convert the inMemoryUploaded file into a string and pass it over an api and convert it back to image?
Some sample code would be helpful, otherwise we are guessing at intent.
You can base64.b64encode the image binary, which will give you text.
Base 64 docs

Thumnails for images in Instagram Graph API

I'd like to ask if there is any way to get thumbnail image for media returned from Instagram Graph API? I can get an image URL by using following endpoint: /{InstagramUserId}/media?fields=media_url
However it only returns one size. Old Instagram API returned various sizes like low_resolution, thumbnail, standard_size. Is it possible to get similar result by using Instagram Grahp API?
After searching for some time to a solution i finally found one.
So, include in the fields query string the permalink field and it should give as following (Sorry, for using Kim Kardashian as an example):
https://www.instagram.com/p/CAYDz52gSLh
then append this at the end media?size=t or simply media like this:
https://www.instagram.com/p/CAYDz52gSLh/media?size=t
media?size=t will give a 150x150 px image
media?size=m will give a 320x320 px image
media?size=l will give a 1080x1080 px image
I can not find a way to get the thumbnails in one step.
But in the next step after receiving the data, the thumbnail of each image and video can be found in this way using oEmbed:
https://graph.facebook.com/v9.0/instagram_oembed?url={permalink}&maxwidth=320&fields=thumbnail_url,author_name,provider_name,provider_url&access_token={accessToken}
permalink: The url received from the previous stage (business_discovery)
Example:
https://graph.facebook.com/v9.0/instagram_oembed?url=https://www.instagram.com/p/CBOuPY1AcMQ/&maxwidth=320&fields=thumbnail_url,author_name,provider_name,provider_url&access_token={accessToken}
More Details

How to save compressed pixels (compressed with my own encoder) back into DICOM image file using Imebra library?

I have my own image encoder and decoder. What I want is to read DICOM images, extract uncompressed image pixels, compress them using my encoder and then write those compressed pixels back in the DICOM file in place of uncompressed pixels. Decoder would do the opposite. Is this possible to do in Imebra? I can read tags and pixels, but after I compress them, I'm not sure how to put them back (they are currently in char* buffer), or if this is even possible. I'm using Imebra in C++.
Alternatively, it would be okay if I could create completely new DICOM file, but in that case I would need to easily transfer all the DICOM tags from the old file.
If this is not possible in Imebra, is there some other C++ library that allows this?
Edit:
Thanks for the answer, Paolo. However, original DICOM image still remains unchanged (using second option). Can you say am I doing something obviously wrong here?
std::unique_ptr<imebra::DataSet> loadedDataSet(imebra::CodecFactory::load(imgNameM));
imebra::WritingDataHandlerNumeric* dataHandler = loadedDataSet->getWritingDataHandlerRaw(imebra::TagId(imebra::tagId_t::PixelData_7FE0_0010), 0);
dataHandler->assign(buffer, size);
delete dataHandler;
loadedDataSet is not empty, I checked with bufferExists.
Edit 2:
Yes, I didn't save it. Now I added that line and managed to modify PixelData element which was solves my original problem. Thanks. However, some other parts of the file are now automatically also changed. More than 100 empty bytes are added at the beginning of the file, although this doesn't bother me that much. What bothers me is that (0008,0005) Specific Character Set tag is now added and its value isn't set (it's empty) which then causes CharsetConversionNoTableError when trying to read tags of that modified file. If I remove that tag manually and fix the group length, I can read tags normally. Is there a possibility to avoid this behavior?
Imebra already provides the encoder/decoder for lossless jpeg, baseline and extended jpeg, RLE.
There are several ways of adding your own codec to Imebra:
derive a class from imebra::implementation::codecs::imageCodec
or encode an image into a char buffer, then add it as raw content using imebra::DataSet::getWritingDataHandlerRaw which allows you to write the tag raw content. getWritingDataHandlerRaw returns a WritingDataHandlerNumeric. Use WritingDataHandlerNumeric::assign to move the bytes buffer into the data handler, then delete the data handler to cause it to commit its content into the dataset.
The example changeTransferSyntax that comes with the library shows how to create a new dataset with all the same tags from the source dataset but with a different transfer syntax (including a different image compression)

How to set text dynamically in unreal engine

I would like to set text and 2d images dynamically in Unreal Engine maybe using a placeholder like a Billboard Blueprint then using the Set Text Blueprint.
I am getting json from an external source -- amazon product information -- then want to update the UI Billboard with this json result which includes text and links to image files.
Does anyone know how to achieve this.
Create the string:
FString TestHUDString = FString(TEXT("Buy this crap!"));
FStrings can be set/modified during runtime just like you want it from a std::string
TestHUDString = "buy this other crap....";
And (for example) write it to the "screen":
Canvas->DrawText(BigFont, TestHUDString, 110.0f,110.0f);
You man need to convert your data to a c string or UTF-8 if you have Problems.
Theres also text components of objects if you want to create "in world" billboards for example.
Here the official documentation about using FStrings:
https://docs.unrealengine.com/latest/INT/Programming/UnrealArchitecture/StringHandling/FString/
This should help assuming that you know how to deserialize the json - wich is a different topic imho.

Create or Change multipage TIFFs

I try to compose new and modify existing multipage TIFFs using Magick++.
Does someone know how I can do this?
I can read a specific page using this code:
Image * img = new Image("path/to/image.tif[0]"); //read page 0
But how can I save changes back to the TIFF? and how can I add new pages?
Google could only tell me things about splitting TIFFs in singe page ones.
Thanks for your help!
I never tried it but what about the writeImages function. Docs are here.
From the docs
Write images in container to file specified by string imageSpec_