Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

HTTP/REST download images in c++

I want to get an image from a rest-server. I want to do this in a c++ function, which is callable from blueprints. Looking around here I have not really found something I think is useful.

I know there is a plugin from ufna (varest) out there, but from what I tested it doesn't really seem to fit my needs.

Can somebody point me in the right direction, maybe I just haven't found the right documentation page.

Product Version: Not Selected
more ▼

asked Jul 10 '15 at 02:10 PM in C++ Programming

avatar image

3 1 2 5

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

Here's a quick example.

Requesting the image

 TSharedRef<IHttpRequest> ThumbRequest = FHttpModule::Get().CreateRequest();
 ThumbRequest->OnProcessRequestComplete().BindRaw(this, &SFeaturedImageWidget::OnThumbImageReceived);

Receiving the Image

 void SFeaturedImageWidget::OnThumbImageReceived(FHttpRequestPtr Request, FHttpResponsePtr Response, bool bWasSuccessful)
     if (bWasSuccessful && Response.IsValid())
         TArray<uint8> ImageData = Response->GetContent();
         ThumbnailBrush = CreateBrush(FName(*Request->GetURL()), ImageData);
         FButtonStyle ButtonStyle = FButtonStyle()
                 .OnMouseButtonDown(this, &SFeaturedImageWidget::OnThumbClicked)

Building the brush

 TSharedPtr<FSlateDynamicImageBrush> SFeaturedImageWidget::CreateBrush(FName ResourceName, TArray<uint8> ImageData)
     TSharedPtr<FSlateDynamicImageBrush> Brush;
     uint32 BytesPerPixel = 4;
     int32 Width = 0;
     int32 Height = 0;
     bool bSucceeded = false;
     TArray<uint8> DecodedImage;
     IImageWrapperModule& ImageWrapperModule = FModuleManager::LoadModuleChecked<IImageWrapperModule>(FName("ImageWrapper"));
     IImageWrapperPtr ImageWrapper = ImageWrapperModule.CreateImageWrapper(EImageFormat::PNG);
     if (ImageWrapper.IsValid() && ImageWrapper->SetCompressed(ImageData.GetData(), ImageData.Num()))
         Width = ImageWrapper->GetWidth();
         Height = ImageWrapper->GetHeight();
         const TArray<uint8>* RawData = NULL;
         if (ImageWrapper->GetRaw(ERGBFormat::RGBA, 8, RawData))
             DecodedImage = *RawData;
             bSucceeded = true;
     if (bSucceeded && FSlateApplication::Get().GetRenderer()->GenerateDynamicImageResource(ResourceName, ImageWrapper->GetWidth(), ImageWrapper->GetHeight(), DecodedImage))
         Brush = MakeShareable(new FSlateDynamicImageBrush(ResourceName, FVector2D(ImageWrapper->GetWidth(), ImageWrapper->GetHeight())));
     return Brush;
more ▼

answered Jul 10 '15 at 03:12 PM

avatar image

714 40 27 54

avatar image Ethlaron Jul 13 '15 at 07:57 AM

Requesting the image - line 4 gives me the following error:

error 2338: You cannot use raw method delegates with UObjects

Does anybody have an idea why this happens?

(btw, how does one make those fancy code snippets look so fancy?)

avatar image Ethlaron Jul 13 '15 at 09:01 AM

Solved: I changed BindRaw to BindUObject. Not tested yet, but it builds

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question