1.有时候使用UE4 的Http实现不了某些功能,所以就得想办法了,看一下自己写的ftp功能,
功能是接受图片,这功能如果使用的话就测试一下吧,我写的这个功能已经用到项目里面了.
下面就看代码吧.
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "AllowWindowsPlatformTypes.h"
#include
#include
#include
#include "HideWindowsPlatformTypes.h"
#include "Engine/Texture2DDynamic.h"
class IImageWrapper;
class UTexture2D;
/**
*
*/
class LoadImageFromFtp
{
public:
static UTexture2D* DownLoader(FString URL, FString localPath, TSharedPtr ImageWrapperPtr);
private:
static LPCWSTR SwitchFromFString(FString strName);
static const int32 MAXBUFFER = 800000;
static UTexture2D* GetLocalTexture(void* imageData, int32 length, TSharedPtr ImageWrapperPtr);
static TArray uint8ToFColor(const TArray origin);
static UTexture2D* TextureFromImage(const int32 SrcWidth, const int32 SrcHeight, const TArray &SrcData, const bool UseAlpha);
};
下面是Cpp实现文件
// Fill out your copyright notice in the Description page of Project Settings.
#include "../ShooterGame/Public/HardInfo/LoadImageFromFtp.h"
#include "UnrealMemory.h"
#include "UdpSocketReceiver.h"
#include "IImageWrapperMod