您的位置:首页 > 编程语言 > C#

wince动态加载图片,数据类型转换

2007-12-26 13:25 429 查看
最近刚开始折腾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 string byte c#
相关文章推荐