当前位置: 首页>>代码示例>>C++>>正文


C++ FImage::IsGammaCorrected方法代码示例

本文整理汇总了C++中FImage::IsGammaCorrected方法的典型用法代码示例。如果您正苦于以下问题:C++ FImage::IsGammaCorrected方法的具体用法?C++ FImage::IsGammaCorrected怎么用?C++ FImage::IsGammaCorrected使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在FImage的用法示例。


在下文中一共展示了FImage::IsGammaCorrected方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: CopyImage

/**
 * Copies an image accounting for format differences. Sizes must match.
 *
 * @param SrcImage - The source image to copy from.
 * @param DestImage - The destination image to copy to.
 */
static void CopyImage(const FImage& SrcImage, FImage& DestImage)
{
    check(SrcImage.SizeX == DestImage.SizeX);
    check(SrcImage.SizeY == DestImage.SizeY);
    check(SrcImage.NumSlices == DestImage.NumSlices);

    const int32 NumTexels = SrcImage.SizeX * SrcImage.SizeY * SrcImage.NumSlices;

    if (SrcImage.Format == DestImage.Format &&
            SrcImage.GammaSpace == DestImage.GammaSpace)
    {
        DestImage.RawData = SrcImage.RawData;
    }
    else if (SrcImage.Format == ERawImageFormat::RGBA32F)
    {
        // Convert from 32-bit linear floating point.
        const FLinearColor* SrcColors = SrcImage.AsRGBA32F();

        switch (DestImage.Format)
        {
        case ERawImageFormat::G8:
        {
            uint8* DestLum = DestImage.AsG8();
            for (int32 TexelIndex = 0; TexelIndex < NumTexels; ++TexelIndex)
            {
                DestLum[TexelIndex] = SrcColors[TexelIndex].ToFColor(DestImage.IsGammaCorrected()).R;
            }
        }
        break;

        case ERawImageFormat::BGRA8:
        {
            FColor* DestColors = DestImage.AsBGRA8();
            for (int32 TexelIndex = 0; TexelIndex < NumTexels; ++TexelIndex)
            {
                DestColors[TexelIndex] = SrcColors[TexelIndex].ToFColor(DestImage.IsGammaCorrected());
            }
        }
        break;

        case ERawImageFormat::BGRE8:
        {
            FColor* DestColors = DestImage.AsBGRE8();
            for (int32 TexelIndex = 0; TexelIndex < NumTexels; ++TexelIndex)
            {
                DestColors[TexelIndex] = SrcColors[TexelIndex].ToRGBE();
            }
        }
        break;

        case ERawImageFormat::RGBA16:
        {
            uint16* DestColors = DestImage.AsRGBA16();
            for (int32 TexelIndex = 0; TexelIndex < NumTexels; ++TexelIndex)
            {
                int32 DestIndex = TexelIndex * 4;
                DestColors[DestIndex + 0] = FMath::Clamp(FMath::FloorToInt(SrcColors[TexelIndex].R * 65535.999f), 0, 65535);
                DestColors[DestIndex + 1] = FMath::Clamp(FMath::FloorToInt(SrcColors[TexelIndex].G * 65535.999f), 0, 65535);
                DestColors[DestIndex + 2] = FMath::Clamp(FMath::FloorToInt(SrcColors[TexelIndex].B * 65535.999f), 0, 65535);
                DestColors[DestIndex + 3] = FMath::Clamp(FMath::FloorToInt(SrcColors[TexelIndex].A * 65535.999f), 0, 65535);
            }
        }
        break;

        case ERawImageFormat::RGBA16F:
        {
            FFloat16Color* DestColors = DestImage.AsRGBA16F();
            for (int32 TexelIndex = 0; TexelIndex < NumTexels; ++TexelIndex)
            {
                DestColors[TexelIndex] = FFloat16Color(SrcColors[TexelIndex]);
            }
        }
        break;
        }
    }
    else if (DestImage.Format == ERawImageFormat::RGBA32F)
    {
        // Convert to 32-bit linear floating point.
        FLinearColor* DestColors = DestImage.AsRGBA32F();
        switch (SrcImage.Format)
        {
        case ERawImageFormat::G8:
        {
            const uint8* SrcLum = SrcImage.AsG8();
            for (int32 TexelIndex = 0; TexelIndex < NumTexels; ++TexelIndex)
            {
                FColor SrcColor(SrcLum[TexelIndex],SrcLum[TexelIndex],SrcLum[TexelIndex],255);

                switch ( SrcImage.GammaSpace )
                {
                case EGammaSpace::Linear:
                    DestColors[TexelIndex] = SrcColor.ReinterpretAsLinear();
                    break;
                case EGammaSpace::sRGB:
//.........这里部分代码省略.........
开发者ID:zhaoyizheng0930,项目名称:UnrealEngine,代码行数:101,代码来源:ImageCore.cpp


注:本文中的FImage::IsGammaCorrected方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。