gpt4 book ai didi

c# - 按位将 int 转换为 UInt32 的最快方法?

转载 作者:太空狗 更新时间:2023-10-29 18:02:49 25 4
gpt4 key购买 nike

我有一些低级图像/纹理操作,其中 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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com