PDA

View Full Version : کار با عکس



ashtiani
شنبه 24 فروردین 1387, 19:00 عصر
با سلام
1. چگونه می توان عمل زوم کردن تصویر را در سی شارپ پیاده سازی نمود .(به عنوان مثال قسمتی از تصویری را که در یک picturebox نمایش داده شده است در همان picturebox نمایش دهد. )
2.چگونه می توان با پایین نگه داشتن کلید ماوس بر روی تصویر ، تصویر مورد نظر را جابجا کرد.

علیرضا مداح
شنبه 24 فروردین 1387, 20:42 عصر
سلام ،
1)مثالی از MSDN:


Image image = new Bitmap("Apple.gif");
// Draw the image unaltered with its upper-left corner at (0, 0).
e.Graphics.DrawImage(image, 0, 0);
// Make the destination rectangle 30 percent wider and
// 30 percent taller than the original image.
// Put the upper-left corner of the destination
// rectangle at (150, 20).
int width = image.Width;
int height = image.Height;
RectangleF destinationRect = new RectangleF(
150,
20,
1.3f * width,
1.3f * height);
// Draw a portion of the image. Scale that portion of the image
// so that it fills the destination rectangle.
RectangleF sourceRect = new RectangleF(0, 0, .75f * width, .75f * height);
e.Graphics.DrawImage(
image,
destinationRect,
sourceRect,
GraphicsUnit.Pixel);

و یا میتوانید از PrintPreviewControl استفاده نمایید که دارای متد Zoom میباشد ، به هر حال روشهای مختلفی برای انجام اینکار ممکن است به کار گرفته شود.
2) بسیار ساده است ، توسط رویدادهای MoseDown و MouseUp و رویدادهای مربوط به Drag&Drop میتوانید اینکار را انجام دهید.
(در هرتاپیک یک سوال)

sinpin
یک شنبه 25 فروردین 1387, 04:45 صبح
در تاپیک زیر هم نمونه هایی هست :
1001 نکته در سی شارپ (http://barnamenevis.org/forum/showthread.php?t=95001)