本例使用VS2015实现放大镜。
关键代码:
class myMagnify
{
private const int MAX = 5;
private Graphics gpOrgin; //画板,用于画截图
private Graphics gpMag; //画板,用于画放大图
private Bitmap btOrgin; //画布,桌面原图
private Bitmap btMag; //放大后图片
private Size mySize; //桌面截取范围,即pictureBox的大小
private int mul; //放大倍数
public int Mul
{
get
{
return mul;
}
set
{
mul = value < MAX ? value : MAX;
refreshMul();
}
}
public Size MySize
{
get
{
return mySize;
}
set
{
mySize = value;
refreshSize();
}
}
/// <summary>
/// 构造函数