Project Source Download: http://download.csdn.net/detail/mostone/6360007
-
public partial class FormMain : Form
-
{
-
-
Bitmap bmpZoom = null;
-
Bitmap bmpSrc = null;
-
-
public FormMain()
-
{
-
InitializeComponent();
-
}
-
-
private void button1_Click(object sender, EventArgs e)
-
{
-
try
-
{
-
DialogResult isDone = openFileDialog1.ShowDialog();
-
if (isDone == DialogResult.OK)
-
{
-
pictureBox1.Image = null;
-
pictureBox2.Image = null;
-
bmpSrc = null;
-
bmpZoom = null;
-
-
Image img = Bitmap.FromFile(openFileDialog1.FileName);
-
pictureBox1.Image = img;
-
bmpSrc = new Bitmap(img);
-
}
-
}
-
catch (Exception ex)
-
{
-
pictureBox1.Image = null;
-
bmpSrc = null;
-
MessageBox.Show(ex.Message);
-
}
-
-
}
-
-
private void pictureBox1_MouseClick(object sender, MouseEventArgs e)
-
{
-
const int zoomSize = 8;
-
if (this.bmpSrc == null)
-
{
-
return;
-
}
-
-
bmpZoom = null;
-
bmpZoom = new Bitmap(pictureBox2.Width, pictureBox2.Height);
-
Graphics grpDst = Graphics.FromImage(bmpZoom);
-
-
-
int width = pictureBox2.Width / zoomSize;
-
int height = pictureBox2.Height / zoomSize;
-
-
int offsetX = width / 2;
-
int offsetY = height / 2;
-
-
int x = e.X - offsetX;
-
int y = e.Y - offsetY;
-
if (offsetX + e.X >= bmpSrc.Width)
-
{
-
x = bmpSrc.Width - offsetX * 2;
-
}
-
else if (x < 0)
-
{
-
x = 0;
-
}
-
-
if (offsetY + e.Y >= bmpSrc.Height)
-
{
-
y = bmpSrc.Height - offsetY * 2;
-
}
-
else if (y < 0)
-
{
-
y = 0;
-
}
-
-
Color color;
-
int oriX = x;
-
for (int row = 0; row < pictureBox2.Height; row += zoomSize)
-
{
-
if (y >= bmpSrc.Height) break;
-
-
for (int col = 0; col < pictureBox2.Width; col += zoomSize)
-
{
-
if (x >= bmpSrc.Width) break;
-
-
-
color = bmpSrc.GetPixel(x, y);
-
-
grpDst.FillRectangle(new SolidBrush(color), col, row, zoomSize, zoomSize);
-
x++;
-
}
-
x = oriX;
-
y++;
-
}
-
-
pictureBox2.Image = bmpZoom;
-
-
}
-
-
private void pictureBox2_MouseClick(object sender, MouseEventArgs e)
-
{
-
if (bmpZoom == null) return;
-
-
Color color = bmpZoom.GetPixel(e.X, e.Y);
-
labelColor.BackColor = color;
-
String val = color.ToArgb().ToString("X");
-
textBox1.Text = "#" + val.Substring(2);
-
textBox2.Text = "#" + rgb565FromColor(color).ToString("X");
-
textBox3.Text = "#" + rgb565PFromColor(color).ToString("X");
-
}
-
-
private
-
六六分期app的软件客服如何联系?不知道吗?加qq群【895510560】即可!标题:六六分期
阅读:19283|2023-10-27
-
今天小编告诉大家如何处理win10系统火狐flash插件总是崩溃的问题,可能很多用户都不知
阅读:10021|2022-11-06
-
今天小编告诉大家如何对win10系统删除桌面回收站图标进行设置,可能很多用户都不知道
阅读:8344|2022-11-06
-
今天小编告诉大家如何对win10系统电脑设置节能降温的设置方法,想必大家都遇到过需要
阅读:8713|2022-11-06
-
我们在使用xp系统的过程中,经常需要对xp系统无线网络安装向导设置进行设置,可能很多
阅读:8658|2022-11-06
-
今天小编告诉大家如何处理win7系统玩cf老是与主机连接不稳定的问题,可能很多用户都不
阅读:9688|2022-11-06
-
电脑对日常生活的重要性小编就不多说了,可是一旦碰到win7系统设置cf烟雾头的问题,很
阅读:8646|2022-11-06
-
我们在日常使用电脑的时候,有的小伙伴们可能在打开应用的时候会遇见提示应用程序无法
阅读:8014|2022-11-06
-
今天小编告诉大家如何对win7系统打开vcf文件进行设置,可能很多用户都不知道怎么对win
阅读:8683|2022-11-06
-
今天小编告诉大家如何对win10系统s4开启USB调试模式进行设置,可能很多用户都不知道怎
阅读:7550|2022-11-06
|
请发表评论