WEB开发网
开发学院手机开发Windows Mobile 开发 Windows Mobile开发:绘制背景图片 阅读

Windows Mobile开发:绘制背景图片

 2010-08-22 12:27:00 来源:WEB开发网   
核心提示:bmp.Draw(gxBuffer, imgRect);e.Graphics.DrawImage(offBitmap, 0, 0);}else{e.Graphics.Clear(this.BackColor);}}protected override void OnResize(EventArgs e){base.On

bmp.Draw(gxBuffer, imgRect);

e.Graphics.DrawImage(offBitmap, 0, 0);

}

else

{

e.Graphics.Clear(this.BackColor);

}

}

protected override void OnResize(EventArgs e)

{

base.OnResize(e);

if (offBitmap != null)

offBitmap.Dispose();

offBitmap = new Bitmap(this.Width, this.Height, PixelFormat.Format32bppRgb);

}

/**////

/// 获取屏幕大小,展现模式

///

public void AdjustFormLayout()

{

Rectangle screenBounds = Screen.PrimaryScreen.Bounds;

float widthRatio = 0.0F;

float heightRatio = 0.0F;

DisplayManager.GetDisplayRatiosByDpi(this, ref widthRatio, ref heightRatio);

控件按比例缩放#region 控件按比例缩放

if (DisplayManager.GetDisplayMode() == DisplayMode.Portrait)

{

// 纵向

formSize = new Size(screenBounds.Width, screenBounds.Height);

formSign = "por";

//viewCount = 9;

}

else if (DisplayManager.GetDisplayMode() == DisplayMode.Landscape)

{

// 横向

formSize = new Size(screenBounds.Width, screenBounds.Height);

formSign = "lan";

//viewCount = 8;

}

else

{

// 正方

formSize = new Size(screenBounds.Width, screenBounds.Height);

formSign = "por";

//viewCount = 9;

}

#endregion

}

根据需要,引用对应的命名空间,编译后,页面显示如下

这样,最基本的背景图片就绘制上了,由于代码中我设置了根据手机分辨率大小获取不同大小的背景图,大家如果用不上可以自己删除掉,图片路径直接改为手机上安装程序的路径就可以了。背景的图片需要你们TEAM中的美工了,如果美工把图片设置为透明的,那样最好,显示出来的背景会和上下边框栏根据主题的变化而变化了,方法是一样的,自己试咯。

Tags:Windows Mobile 开发

编辑录入:coldstar [复制链接] [打 印]
赞助商链接