我有一些低级的图像/纹理操作,其中32位颜色存储为UInt32或int,并且我需要在两者之间进行非常快速的按位转换。

例如

 int color = -2451337;

 //exception
 UInt32 cu = (UInt32)color;

有任何想法吗?

感谢致敬

最佳答案

int color = -2451337;
unchecked {
    uint color2 = (uint)color;
    // color2 = 4292515959
}

关于c# - 将int逐位转换为UInt32的最快方法?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/3600871/

10-12 12:37
查看更多