投INT到UInt32的位运算最快的方法? [英] Fastest way to cast int to UInt32 bitwise?
本文介绍了投INT到UInt32的位运算最快的方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已经在这里32位颜色存储为UInt32的或INT一些低级别的图像/纹理操作,我需要在两者之间真快按位转换。
例如:
INT颜色= -2451337;
//例外
UInt32的铜=(UInt32的)颜色;
什么想法?
感谢和问候
解决方案
INT颜色= -2451337;
选中{
UINT COLOR2 =(UINT)的颜色;
// COLOR2 = 4292515959
}
i have some low level image/texture operations where 32-bit colors are stored as UInt32 or int and i need a really fast bitwise conversion between the two.
e.g.
int color = -2451337;
//exception
UInt32 cu = (UInt32)color;
any ideas?
thanks and regards
解决方案
int color = -2451337;
unchecked {
uint color2 = (uint)color;
// color2 = 4292515959
}
这篇关于投INT到UInt32的位运算最快的方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文