PDA

View Full Version : نمایش بزرگنمائی تصویر با حرکت ماوس روی picturebox



ali_72
شنبه 23 خرداد 1394, 12:12 عصر
سلام
یه picturebox دارم و به کاربر قابلیت ترسیم خطوط روی تصویر را دادم
الان میخوام قابلیتی به picturebox اضافه کنم که وقتی کاربر خط ترسیم میکنه و روی picturebox با ماوس حرکت میکنه همزمان تو یه picturebox دیگه (با سایز خیلی کوچکتر) اون قسمت تصویر که ماوس روش هست رو تو یه بزرگنمائی متفاات ببینه
و مسئله اینه که میخوام اگه تو اون قسمت که کرسر ماوس روش هست خط ترسیم شده بود
اونم تو بزرگنمائی نمایش داده شه

یه راهی پیشنهاد بدید که من نمایش لاین تو پیکچرباکس دوم (بزرگنمائی) رو چی کار کنم

ممنون


private void _pic_image_MouseMove(object sender, MouseEventArgs e) {
if (_pic_image.Image == null)
return;


UpdateZoomedImage(e);
}

private void UpdateZoomedImage(MouseEventArgs e)
{

int zoomWidth = picZoom.Width / _ZoomFactor;
int zoomHeight = picZoom.Height / _ZoomFactor;




int halfWidth = zoomWidth / 2;
int halfHeight = zoomHeight / 2;



Bitmap tempBitmap = new Bitmap(zoomWidth, zoomHeight, PixelFormat.Format24bppRgb);



Graphics bmGraphics = Graphics.FromImage(tempBitmap);



bmGraphics.Clear(_pic_image.BackColor);



bmGraphics.InterpolationMode = InterpolationMode.HighQualityBicubic;




bmGraphics.DrawImage(_pic_image.Image,
new Rectangle(0, 0, zoomWidth, zoomHeight),
new Rectangle(e.X - halfWidth, e.Y - halfHeight, zoomWidth, zoomHeight),
GraphicsUnit.Pixel);



picZoom.Image = tempBitmap;



bmGraphics.DrawLine(Pens.Black, halfWidth + 1, halfHeight - 4, halfWidth + 1, halfHeight - 1);
bmGraphics.DrawLine(Pens.Black, halfWidth + 1, halfHeight + 6, halfWidth + 1, halfHeight + 3);
bmGraphics.DrawLine(Pens.Black, halfWidth - 4, halfHeight + 1, halfWidth - 1, halfHeight + 1);
bmGraphics.DrawLine(Pens.Black, halfWidth + 6, halfHeight + 1, halfWidth + 3, halfHeight + 1);



bmGraphics.Dispose();



picZoom.Refresh();
}