19 FString IndexText = FString::Printf(TEXT(
"Q%d"), index);
20 Text_Index->SetText(FText::FromString(IndexText));
25 PRINTLOG(TEXT(
"Question: %s"), *questionKor);
30 FString FileName = FString::Printf(TEXT(
"Answer%d.PNG"), index);
36 const float MaxWidthLimit = 1080.0f;
37 const float TargetHeight = 360.0f;
39 const float TextureWidth =
static_cast<float>(LoadedTexture->GetSizeX());
40 const float TextureHeight =
static_cast<float>(LoadedTexture->GetSizeY());
41 const float AspectRatio = TextureWidth / TextureHeight;
46 NewBrush.SetResourceObject(LoadedTexture);
47 NewBrush.ImageSize = FVector2D(TextureWidth, TextureHeight);
50 float NewWidth = TargetHeight * AspectRatio;
51 float NewHeight = TargetHeight;
54 if (NewWidth > MaxWidthLimit)
56 NewWidth = MaxWidthLimit;
57 NewHeight = NewWidth / AspectRatio;
68 FString Description = FString::Printf(TEXT(
"%s\n\n[Correction]\n%s"),
78 TArray<uint8> RawFileData;
79 if (!FFileHelper::LoadFileToArray(RawFileData, *filePath))
81 PRINTLOG(TEXT(
"Failed to load file: %s"), *filePath);
85 IImageWrapperModule& ImageWrapperModule = FModuleManager::LoadModuleChecked<IImageWrapperModule>(FName(
"ImageWrapper"));
86 TSharedPtr<IImageWrapper> ImageWrapper = ImageWrapperModule.CreateImageWrapper(EImageFormat::PNG);
88 if (!ImageWrapper.IsValid() || !ImageWrapper->SetCompressed(RawFileData.GetData(), RawFileData.Num()))
90 PRINTLOG(TEXT(
"Failed to parse PNG: %s"), *filePath);
94 TArray<uint8> UncompressedBGRA;
95 if (!ImageWrapper->GetRaw(ERGBFormat::BGRA, 8, UncompressedBGRA))
97 PRINTLOG(TEXT(
"Failed to decompress PNG: %s"), *filePath);
101 UTexture2D* Texture = UTexture2D::CreateTransient(ImageWrapper->GetWidth(), ImageWrapper->GetHeight(), PF_B8G8R8A8);
107 void* TextureData = Texture->GetPlatformData()->Mips[0].BulkData.Lock(LOCK_READ_WRITE);
108 FMemory::Memcpy(TextureData, UncompressedBGRA.GetData(), UncompressedBGRA.Num());
109 Texture->GetPlatformData()->Mips[0].BulkData.Unlock();
110 Texture->UpdateResource();