Custom HUD Imaging

Hi!

I’m a bit of a n00b at this and I’m sure that will become more obvious :wink:

Here’s my situation: I have a 100x100 array of floats between 0 and 1, and I’m looking to create a 100x100 image that where a 0 in the array corresponds to black and a 1 in the array corresponds to red, and anywhere in between is some intermediate value. Then I’m interested in displaying that image as a widget in the hud. What sort of classes should I be looking at to do something like this, or do I have to modify the engine to do this? Thanks!

-RJ

Update: It appears that in C++, unreal treats an image as a TArray< uint8 >&, so it’s some sort of data stream, whether jpeg or whatever. If the engine can decode that into a 2d array of rgba’s then I could create an image encoding from a 2d array so to speak, and make it a ufunction so that it could be accessible from blueprints.

Solved! (I think). Basically, FImage is an uncompressed image and you can grab a pointer to the data stream which interprets it as the correct format (RGBA32F, etc.) and then you can write to those pixels. I’m not 100% done yet because I think somethings up with the build system, and when I include ImageCore.h the compiler is not recognizing IMAGECORE_API so it’s messed up, but I’m sure I’ll figure it out. Missing an include or something.

Nope! There’s something I’m not doing right with ImageCore.h. There is a keyword in the signature of many of the functions in the FImage struct, and when I include it, the compiler does not recognize IMAGECORE_API, and so everything’s bricked. I can’t find IMAGECORE_API in the rest of the codebase, so it would have to be defined at compile time but that’s not happening for some reason. I get errors like this:

Error 1 error C2146: syntax error : missing ‘;’ before identifier ‘FImage’ C:\Program Files\Epic Games\4.7\Engine\Source\Developer\ImageCore\Public\ImageCore.h 72 1 FPS
Error 2 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int C:\Program Files\Epic Games\4.7\Engine\Source\Developer\ImageCore\Public\ImageCore.h 72 1 FPS
Error 3 error C2146: syntax error : missing ‘;’ before identifier ‘FImage’ C:\Program Files\Epic Games\4.7\Engine\Source\Developer\ImageCore\Public\ImageCore.h 82 1 FPS
Error 4 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int C:\Program Files\Epic Games\4.7\Engine\Source\Developer\ImageCore\Public\ImageCore.h 82 1 FPS
Error 5 error C2144: syntax error : ‘void’ should be preceded by ‘;’ C:\Program Files\Epic Games\4.7\Engine\Source\Developer\ImageCore\Public\ImageCore.h 94 1 FPS
Error 6 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int C:\Program Files\Epic Games\4.7\Engine\Source\Developer\ImageCore\Public\ImageCore.h 94 1 FPS
Error 7 error C2146: syntax error : missing ‘;’ before identifier ‘int32’ C:\Program Files\Epic Games\4.7\Engine\Source\Developer\ImageCore\Public\ImageCore.h 101 1 FPS
Error 8 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int C:\Program Files\Epic Games\4.7\Engine\Source\Developer\ImageCore\Public\ImageCore.h 101 1 FPS
Error 9 error C2144: syntax error : ‘void’ should be preceded by ‘;’ C:\Program Files\Epic Games\4.7\Engine\Source\Developer\ImageCore\Public\ImageCore.h 112 1 FPS
Error 10 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int C:\Program Files\Epic Games\4.7\Engine\Source\Developer\ImageCore\Public\ImageCore.h 112 1 FPS
Error 11 error C2144: syntax error : ‘void’ should be preceded by ‘;’ C:\Program Files\Epic Games\4.7\Engine\Source\Developer\ImageCore\Public\ImageCore.h 122 1 FPS
Error 12 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int C:\Program Files\Epic Games\4.7\Engine\Source\Developer\ImageCore\Public\ImageCore.h 122 1 FPS

Very frustrating!

-RJ

Solved, for real this time. Since I’m using ImageCore, ImageCore needs to be added to the project.build.cs. Hope this helps somebody!

1 Like