最近刚开始折腾wince(c#),记录一下:
1、动态加载图片
声明个索引:
private uint img_idx;
函数实现:
Bitmap bmp;
string[] fname = new string[] ...{ "/Program Files/test/2.png", "/Program Files/test/3.png", "/Program Files/test/4.png" };
MessageBox.Show("显示下一个界面!");
bmp = new Bitmap(fname[img_idx]);
pictureBox1.Image = Image.FromHbitmap(bmp.GetHbitmap());
img_idx++;
if (img_idx > 2)
img_idx = 0;
2、整形转换
字节到整形

byte[] test8 = new byte[] ...{ 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8 };
uint test32;
string tt; 
test32 = BitConverter.ToUInt32(test8, 4);
tt = System.Convert.ToString(test32);
MessageBox.Show(tt);
整形到字节

byte[] test8 = new byte[] ...{0,0,0,0};
uint test32,i;
string tt;
test32 = 0x12345678;
test8 = BitConverter.GetBytes(test32);
for (i = 0; i < 4; i++)
...{
tt = System.Convert.ToString(test8[i]);
MessageBox.Show(tt);
}
PC默认是小端,结果是120,86,52,18(十进制显示)
本文介绍在WinCE环境下使用C#进行图片动态加载的方法,并演示了如何在C#中实现整型与字节之间的相互转换。

2564

被折叠的 条评论
为什么被折叠?



