最近刚开始折腾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 ;
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);
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);
}
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(十进制显示)