c# - 如何滚动缩放的图像C#
问题描述
我有一个图片框,我可以放大它。
当我缩放图片框时,我需要向左或向右滚动图像。
你能告诉我为什么当我缩放图像时,左侧是固定的,而我不能在左侧滚动吗?
我已经在主面板上激活了 AutoScroll,但我只能向右滚动,但我的图像居中,我也需要向左滚动。
我想要的是当您在 Win 10 中的照片应用程序内缩放和滚动图像时。但我使用的是 scoll 栏而不是鼠标指针。
结构如下图所示,主面板为红色,图片框为绿色。
private void image_Scroll(object sender, EventArgs e)
{
int pbWidth = pbImg.Image.Width + (pbImg.Image.Width * ztb.Value / 100);
int pbHeight = pbImg.Image.Height + (pbImg.Image.Height * ztb.Value / 100);
int mpWidth = mainPanel.Width:
int mpHeight = mainPanel.Height;
int pbX = (mpWidth - pbWidth) / 2;
int pbY = (mpHeight - pbHeight) / 2;
pbImg.Size = new Size(pbWidth, pbHeight);
Point p = new Point(pbX, pbY);
pictureBox.Location = p;
}
解决方案
推荐阅读
- javascript - 如何从 JSON 中提取值
- firebase - 单个文档中的 Firebase Firestore 密钥特定写入权限
- python - Kullback-Lieber 散度测量两个概率函数之间的重叠
- python - 在 Python 中将值从字典转换为列表格式
- c# - 变量 previousValue 返回 NullReferenceException: Object not set to an instance of object
- php - 如何在浏览器中以只读模式查看 pdf?
- javascript - css dom 操作 Angular 组件到 html-css
- javascript - 为什么在Firefox中未定义事件?
- java - Java HttpClient 使用会话 ID 访问图像
- mysql - 在 MySQL 中根据给定 ID 检索多个数据的最佳方法是什么?