Downloading Images? Imagewrapper?

I’m working on something that requires me to download a lot of images off the web, I’m using the ImageWrapper class to make them into JPEGs and put them on textures in the environment. It works fine on desktop, but on Android (specifically GearVR) they just never download. Any idea why not or advice for testing what’s causing it specifically?

1 Like

I have to bump this, it’s become a large problem for me as I need to get my Gear iteration going asap. Is there any Unreal dev that could help me with figuring out the issue of downloading images on mobile?

Any devs I could talk to about this at least?

Hi spire8989,

Can you expound a bit on your problem? Are you saying your project downloads images from the internet, makes them into jpgs and puts them on the Android?

I’m not sure how I missed that you responded to this, but yes.

I’m working from my PC version which downloads a JPEG and uses ImageWrapper with the TArray<uint8> content and UTexture2D::CreateTransient to make a texture from it which is placed on a plane in-game.

This all works just dandy on PC, but when converting the same application to Android it simply fails all of the ImageWrapper steps, leading me to believe ImageWrapper may not be working on mobile?

Hi spire8989,

ImageWrapper works on Android fine for me. It is used in the Download Image Blueprint node (see UAsyncTaskDownloadImage::HandleImageRequest). Here is my level blueprint to test it:

I created a cube in the scene to receive the dynamic material created from a parent material with a texture parameter DynBaseTexture. MyDynamicMat is a variable of type Dynamic Material Instance.

1 Like

Thanks for the response, that’s in 4.8, right? I don’t know why it’d make a difference compared to the one I wrote myself, but I’ll update my project and test it out.

I don’t see why it would matter, but the fact that it’s a GearVR app wouldn’t make a difference, right? Unless GearVR requires power of 2 textures while other Android apps don’t? And if so, is there an easy way to take the texture returned and resize it, the images are square, but not a power of 2.

Edit: The issue was that I was attempting to pull images from an https address. The images are also hosted on http so I just switched it. I didn’t bother testing this which I saw elsewhere: "In the Project Settings dialog, look in the Engine - Network section for Libcurl Verify Peer checkbox. Try turning it off and see if it works."

For further reference: I was also having issues with images not loading on Android (I’m also using the Download Image node). All the images I was trying to download were from wikimedia (https).

Unchecking “Verify Peer” solved the problem.

Also, I don’t know if this is necessary, but I also added an extra permission on Project Settings -> Platforms / Android: android.permission.INTERNET. Might be needed when you publish the app.

android.permission.INTERNET is set by default. If you want to see what is set for your project, look at AndroidManifest.xml in your project’s Intermediate/Android/APK directory after packaging.

Hi Chris,

Is there a way to do the exact same thing as you’re doing above but download the image from the phone? Much like the way File Media Source works?

Thanks,
George

You can look at Engine\Source\Runtime\UMG\Private\Blueprint\AsyncTaskDownloadImage.cpp for the code for Download Image node. UAsyncTaskDownloadImage::HandleImageRequest() uses ImageWrapper to decode PNG, JPEG, or BMP using the data from HttpResponse. You would do similar, just load the data from a file instead.

Is anyone having problems with washed out colors when using the downloaded texture for a sprite? I made sure to replicate all the settings in the dynamic material as well as the the texture settings for paper 2d but the colors are not true to the original image when rendering.

It sounds like it is the wrong colorspace. Most downloaded images are already gamma-corrected to look right on the monitor. Non-gamma corrected works best for rendering.

Take a look here a sRGB: https://docs.unrealengine.com/latest/INT/Engine/Content/Types/Textures/Properties/

This solution gives me textures with no mipmaps. Is there a way around it? Thank you!