本文整理汇总了C++中UTexture2D::GetSurfaceWidth方法的典型用法代码示例。如果您正苦于以下问题:C++ UTexture2D::GetSurfaceWidth方法的具体用法?C++ UTexture2D::GetSurfaceWidth怎么用?C++ UTexture2D::GetSurfaceWidth使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UTexture2D
的用法示例。
在下文中一共展示了UTexture2D::GetSurfaceWidth方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Draw
void FPaperExtractSpritesViewportClient::Draw(FViewport* Viewport, FCanvas* Canvas)
{
// Super will clear the viewport
FPaperEditorViewportClient::Draw(Viewport, Canvas);
UTexture2D* Texture = TextureBeingExtracted.Get();
if (Texture != nullptr)
{
const bool bUseTranslucentBlend = Texture->HasAlphaChannel();
// Fully stream in the texture before drawing it.
Texture->SetForceMipLevelsToBeResident(30.0f);
Texture->WaitForStreaming();
FLinearColor TextureDrawColor = Settings->TextureTint;
//FLinearColor RectOutlineColor = FLinearColor::Yellow;
const FLinearColor RectOutlineColor = Settings->OutlineColor;
const float XPos = -ZoomPos.X * ZoomAmount;
const float YPos = -ZoomPos.Y * ZoomAmount;
const float Width = Texture->GetSurfaceWidth() * ZoomAmount;
const float Height = Texture->GetSurfaceHeight() * ZoomAmount;
Canvas->DrawTile(XPos, YPos, Width, Height, 0.0f, 0.0f, 1.0f, 1.0f, TextureDrawColor, Texture->Resource, bUseTranslucentBlend);
for (FPaperExtractedSprite Sprite : ExtractedSprites)
{
DrawRectangle(Canvas, RectOutlineColor, Sprite.Rect);
}
}
}
示例2: GetThumbnailSize
void UFontThumbnailRenderer::GetThumbnailSize(UObject* Object, float Zoom,uint32& OutWidth,uint32& OutHeight) const
{
UFont* Font = Cast<UFont>(Object);
if (Font != nullptr &&
Font->Textures.Num() > 0 &&
Font->Textures[0] != nullptr)
{
// Get the texture interface for the font text
UTexture2D* Tex = Font->Textures[0];
OutWidth = FMath::TruncToInt(Zoom * (float)Tex->GetSurfaceWidth());
OutHeight = FMath::TruncToInt(Zoom * (float)Tex->GetSurfaceHeight());
}
else
{
OutWidth = OutHeight = 0;
}
}
示例3: Draw
void USlateBrushThumbnailRenderer::Draw(UObject* Object, int32 X, int32 Y, uint32 Width, uint32 Height, FRenderTarget* RenderTarget, FCanvas* Canvas)
{
USlateBrushAsset* SlateBrushAsset = Cast<USlateBrushAsset>(Object);
if (SlateBrushAsset)
{
FSlateBrush Brush = SlateBrushAsset->Brush;
UTexture2D* Texture = Cast<UTexture2D>( Brush.GetResourceObject() );
// Draw the background checkboard pattern
const int32 CheckerDensity = 8;
auto* Checker = UThumbnailManager::Get().CheckerboardTexture;
Canvas->DrawTile(
0.0f, 0.0f, Width, Height, // Dimensions
0.0f, 0.0f, CheckerDensity, CheckerDensity, // UVs
FLinearColor::White, Checker->Resource); // Tint & Texture
if (Texture)
{
switch(Brush.DrawAs)
{
case ESlateBrushDrawType::Image:
{
FCanvasTileItem CanvasTile( FVector2D( X, Y ), Texture->Resource, FVector2D( Width,Height ), Brush.TintColor.GetSpecifiedColor() );
CanvasTile.BlendMode = SE_BLEND_Translucent;
CanvasTile.Draw( Canvas );
}
break;
case ESlateBrushDrawType::Border:
{
FCanvasTileItem CanvasTile( FVector2D( X, Y ), Texture->Resource, FVector2D( Width,Height ), Brush.TintColor.GetSpecifiedColor() );
CanvasTile.BlendMode = SE_BLEND_Translucent;
CanvasTile.Draw( Canvas );
}
break;
case ESlateBrushDrawType::Box:
{
float NaturalWidth = Texture->GetSurfaceWidth();
float NaturalHeight = Texture->GetSurfaceHeight();
float TopPx = FMath::Clamp<float>(NaturalHeight * Brush.Margin.Top, 0, Height);
float BottomPx = FMath::Clamp<float>(NaturalHeight * Brush.Margin.Bottom, 0, Height);
float VerticalCenterPx = FMath::Clamp<float>(Height - TopPx - BottomPx, 0, Height);
float LeftPx = FMath::Clamp<float>(NaturalWidth * Brush.Margin.Left, 0, Width);
float RightPx = FMath::Clamp<float>(NaturalWidth * Brush.Margin.Right, 0, Width);
float HorizontalCenterPx = FMath::Clamp<float>(Width - LeftPx - RightPx, 0, Width);
// Top-Left
FVector2D TopLeftSize( LeftPx, TopPx );
{
FVector2D UV0( 0, 0 );
FVector2D UV1( Brush.Margin.Left, Brush.Margin.Top );
FCanvasTileItem CanvasTile( FVector2D( X, Y ), Texture->Resource, TopLeftSize, UV0, UV1, Brush.TintColor.GetSpecifiedColor() );
CanvasTile.BlendMode = SE_BLEND_Translucent;
CanvasTile.Draw( Canvas );
}
// Bottom-Left
FVector2D BottomLeftSize( LeftPx, BottomPx );
{
FVector2D UV0( 0, 1 - Brush.Margin.Bottom );
FVector2D UV1( Brush.Margin.Left, 1 );
FCanvasTileItem CanvasTile( FVector2D( X, Y + Height - BottomPx ), Texture->Resource, BottomLeftSize, UV0, UV1, Brush.TintColor.GetSpecifiedColor() );
CanvasTile.BlendMode = SE_BLEND_Translucent;
CanvasTile.Draw( Canvas );
}
// Top-Right
FVector2D TopRightSize( RightPx, TopPx );
{
FVector2D UV0( 1 - Brush.Margin.Right, 0 );
FVector2D UV1( 1, Brush.Margin.Top );
FCanvasTileItem CanvasTile( FVector2D( X + Width - RightPx, Y ), Texture->Resource, TopRightSize, UV0, UV1, Brush.TintColor.GetSpecifiedColor() );
CanvasTile.BlendMode = SE_BLEND_Translucent;
CanvasTile.Draw( Canvas );
}
// Bottom-Right
FVector2D BottomRightSize( RightPx, BottomPx );
{
FVector2D UV0( 1 - Brush.Margin.Right, 1 - Brush.Margin.Bottom );
FVector2D UV1( 1, 1 );
FCanvasTileItem CanvasTile( FVector2D( X + Width - RightPx, Y + Height - BottomPx ), Texture->Resource, BottomRightSize, UV0, UV1, Brush.TintColor.GetSpecifiedColor() );
CanvasTile.BlendMode = SE_BLEND_Translucent;
CanvasTile.Draw( Canvas );
}
//-----------------------------------------------------------------------
// Center-Vertical-Left
FVector2D CenterVerticalLeftSize( LeftPx, VerticalCenterPx );
{
FVector2D UV0( 0, Brush.Margin.Top );
FVector2D UV1( Brush.Margin.Left, 1 - Brush.Margin.Bottom );
FCanvasTileItem CanvasTile( FVector2D( X, Y + TopPx), Texture->Resource, CenterVerticalLeftSize, UV0, UV1, Brush.TintColor.GetSpecifiedColor() );
CanvasTile.BlendMode = SE_BLEND_Translucent;
//.........这里部分代码省略.........