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

本文介绍在WinCE环境下使用C#进行图片动态加载的方法,并演示了如何在C#中实现整型与字节之间的相互转换。

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

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值