Victory BP Library Suite of Image / Pixel Loading and Access!!!
Hi there!
Here are the names of the pixel functions in the Victory BP Library that you can look up and check out!
Yes you can indeed read pixel values from grayscale, just make sure it is not compressed if stored in the project. Compressed textures will give weird values. To date no one has shown up with a decompression solution for existing textures. If someone knows solution and wants to share, please do
However if you load the grayscale texture from hard disk, it won’t be compressed and can be loaded as straight pixels.
I provide you with node to load image from disk
So I’d recommend
-
load image from disk into pixel array
-
access the pixel array
So that means you should use node:
Victory_LoadTexture2D_FromFile_Pixels
/** Load a Texture2D from a JPG,PNG,BMP,ICO,EXR,ICNS file! IsValid tells you if file path was valid or not. Enjoy! - */
static UTexture2D* **Victory_LoadTexture2D_FromFile**(const FString& FullFilePath,EJoyImageFormats ImageFormat,bool& IsValid, int32& Width, int32& Height);
/** Load a Texture2D from a JPG,PNG,BMP,ICO,EXR,ICNS file! IsValid tells you if file path was valid or not. Enjoy! - */
static UTexture2D* **Victory_LoadTexture2D_FromFile_Pixels**(const FString& FullFilePath,EJoyImageFormats ImageFormat,bool& IsValid, int32& Width, int32& Height, TArray<FLinearColor>& OutPixels);
/** Retrieve a pixel color value given the pixel array, the image height, and the coordinates. Returns false if the coordinates were not valid. Pixel coordinates start from upper left corner as 0,0. X= horizontal, Y = vertical */
static bool **Victory_Get_Pixel**(const TArray<FLinearColor>& Pixels, int32 ImageHeight, int32 x, int32 y, FLinearColor& FoundColor);
/** Save an array of pixels to disk as a PNG! It is very important that you supply the curret width and height of the image! Returns false if Width * Height != Array length or file could not be saved to the location specified. I return an ErrorString to clarify what the exact was. - */
static bool **Victory_SavePixels**(const FString& FullFilePath,int32 Width, int32 Height, const TArray<FLinearColor>& ImagePixels, bool SaveAsBMP, bool sRGB, FString& ErrorString);
/** will modify the original T2D to remove sRGB and change compression to VectorDisplacementMap to ensure accurate pixel reading. -*/
static bool **Victory_GetPixelFromT2D**(UTexture2D* T2D, int32 X, int32 Y, FLinearColor& PixelColor);
/** will modify the original T2D to remove sRGB and change compression to VectorDisplacementMap to ensure accurate pixel reading. -*/
static bool **Victory_GetPixelsArrayFromT2D**(UTexture2D* T2D, int32& TextureWidth, int32& TextureHeight,TArray<FLinearColor>& PixelArray);