x

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"

How to render a UE asset thumbnail in a non-UE application

Using the UnrealEd module I can successfully get a uasset thumbnail as a TArray with a call to FObjectThumbnail::AccessCompressedImageData(). I can then transfer this byte array to a different non-UE application where I can realize the image. The problem is the image colors are incorrect. I have tried many different approaches to realizing the image in the second application (C#, Java), but nothing seems to work. I have attached screen shots of both the good image and the bad. Any help would be greatly appreciated. GoodImage alt text

The image with the blue sky is the correct and desired image.

Product Version: UE 4.18
Tags:
correct-colors.png (123.9 kB)
wrong-colors.png (123.4 kB)
more ▼

asked Feb 14 '18 at 08:10 PM in C++ Programming

avatar image

wjhcc
8 1 3

avatar image Hyper4Volt Nov 08 '18 at 09:14 AM

Hey do you mind explanning how did you convert the image into a file? I am trying to figure it out for ages, I tried using FFileHelper::CreateBitmap and FFileHelper::SaveArrayToFile Thanks in advance :)

avatar image wjhcc Nov 09 '18 at 01:51 AM

I got the following from a colleague. I have not used it myself, but it comes from a reliable source. I hope it will help you.

This method will save a UTexture2D as a PNG in the content directory as "MyImage.png". If you go into HighResScreenshotConfig.SaveImage you can see its using FImageWriter and FArchive to get the job done.

 void SaveTexture2D(UTexture2D* PTexture) {
 PTexture->UpdateResource();
 FTexture2DMipMap* MM = &PTexture->PlatformData->Mips[0];
 
 TArray<FColor> OutBMP;
 int sz = MM->SizeX * MM->SizeY;
 OutBMP.AddUninitialized(sz);
 FColor* FormatedImageData = static_cast<FColor*>(MM->BulkData.Lock(LOCK_READ_ONLY));
 FMemory::Memcpy(OutBMP.GetData(), FormatedImageData, sz * sizeof(FColor));
 MM->BulkData.Unlock();
 
 // SaveImage knows how to save the bitmap as PNG - saves to disk file
 FHighResScreenshotConfig& HighResScreenshotConfig = GetHighResScreenshotConfig();
 HighResScreenshotConfig.SetHDRCapture(false);
 FString filename = FPaths::Combine(*FPaths::ProjectContentDir(), TEXT("MyImage.png"));
 bool bSaved = HighResScreenshotConfig.SaveImage(filename, OutBMP, FIntPoint(MM->SizeX, MM->SizeY));
 }
 
(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

When you make byte array swap red value with blue value, you maybe setting bytes in incorrect RGB order or your C# program read them in incorrect order, since you can clearly see on the image that red is blue and blue is red

more ▼

answered Feb 15 '18 at 12:37 AM

avatar image

Shadowriver
31.7k 914 158 1077

avatar image wjhcc Feb 15 '18 at 02:40 AM

Thank you Shadowriver your answer is a good one! While I do not understand where or why the red and blue colors are being flipped in the process, if I swap the red with the blue in my receiving application then the image appears correct once again. Thanks again!

(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