FThumbImageBuffer
缩略图或图标的图像内容。在 FScreenCaptureSourceInfo
中设置。
C++
USTRUCT(BlueprintType)
struct FThumbImageBuffer {
GENERATED_BODY()
public:
UPROPERTY(VisibleAnywhere, BlueprintReadWrite, Category = "Agora|ThumbImageBuffer")
UImage* Image = nullptr;
UPROPERTY(VisibleAnywhere, BlueprintReadWrite, Category = "Agora|ThumbImageBuffer")
TArray<uint8> buffer;
UPROPERTY(VisibleAnywhere, BlueprintReadWrite, Category = "Agora|ThumbImageBuffer")
int64 length = 0;
UPROPERTY(VisibleAnywhere, BlueprintReadWrite, Category = "Agora|ThumbImageBuffer")
int64 width = 0;
UPROPERTY(VisibleAnywhere, BlueprintReadWrite, Category = "Agora|ThumbImageBuffer")
int64 height = 0;
#if defined(_WIN32) || (defined(__APPLE__) && TARGET_OS_MAC && !TARGET_OS_IPHONE)
FThumbImageBuffer(){}
FThumbImageBuffer(const agora::rtc::ThumbImageBuffer & AgoraData){
length = AgoraData.length;
buffer.SetNumZeroed(length);
for (int i = 0; i < length; i++) {
this->buffer[i] = AgoraData.buffer[i];
}
width = AgoraData.width;
height = AgoraData.height;
if(Image == nullptr){
Image = NewObject<UImage>();
}
UTexture2D* RenderTexture = UTexture2D::CreateTransient(width, height, PF_R8G8B8A8);
if(RenderTexture){
#if AG_UE5_OR_LATER
uint8* RawData = (uint8*)RenderTexture->GetPlatformData()->Mips[0].BulkData.Lock(LOCK_READ_WRITE);
FMemory::Memcpy(RawData, AgoraData.buffer, width * height * 4);
RenderTexture->GetPlatformData()->Mips[0].BulkData.Unlock();
RenderTexture->UpdateResource();
#else
uint8* RawData = (uint8*)RenderTexture->PlatformData->Mips[0].BulkData.Lock(LOCK_READ_WRITE);
FMemory::Memcpy(RawData, AgoraData.buffer, width * height * 4);
RenderTexture->PlatformData->Mips[0].BulkData.Unlock();
RenderTexture->UpdateResource();
#endif
FSlateBrush RenderBrush;
RenderBrush.SetResourceObject(RenderTexture);
Image->SetBrush(RenderBrush);
}
}
agora::rtc::ThumbImageBuffer CreateAgoraData() const {
agora::rtc::ThumbImageBuffer AgoraData;
char* TmpChar = new char[length];
for (int i = 0; i < length; i++) {
TmpChar[i] = this->buffer[i];
}
AgoraData.buffer = TmpChar;
AgoraData.length = length;
AgoraData.width = width;
AgoraData.height = height;
return AgoraData;
}
void FreeAgoraData(agora::rtc::ThumbImageBuffer & AgoraData) const {
SET_UABT_GENERIC_PTR___MEMFREE(AgoraData.buffer)
}
#endif
};
信息
图像默认为 ARGB 格式。如果你需要使用其他格式,请自行转换格式。
buffer
缩略图或图标的 buffer。
length
缩略图或图标的 buffer 长度,单位为字节。
width
缩略图或图标的实际宽度(px)。
height
缩略图或图标的实际高度(px)。