public Size ToScreenCoords(Size imageRect) { var scalef = ImageConverter.ScaleFactor(RealImageSize, ImageRectangle.Size); var result = ImageConverter.ScaleRectangle(new Rectangle(0, 0, imageRect.Width, imageRect.Height), scalef); return(result.Size); }
public Rectangle ToScreenCoords(Rectangle imageRect) { var scalef = ImageConverter.ScaleFactor(RealImageSize, ImageRectangle.Size); var result = ImageConverter.ScaleRectangle(imageRect, scalef); result.Offset(ImageRectangle.Location); return(result); }
public Rectangle ToImageCoords(Rectangle screenRect) { var scalef = ImageConverter.ScaleFactor(RealImageSize, ImageRectangle.Size); var result = new Rectangle( screenRect.X - ImageRectangle.X, screenRect.Y - ImageRectangle.Y, screenRect.Width, screenRect.Height); result = ImageConverter.ScaleRectangle(result, 1.0 / scalef); return(result); }
/// <summary> /// Paints an overview image with detail rectangle areas painted onto it (same size as current display). /// </summary> /// <returns></returns> public Image PaintOverviewImage() { using (var pen = new Pen(Color.Orange, 3)) { Bitmap b = new Bitmap(_pbt.ImageRectangle.Width, _pbt.ImageRectangle.Height); using (Graphics g = Graphics.FromImage((Image)b)) { // scale the image to picturebox size var f = ImageConverter.ScaleFactor(pictureBox1.Image.Size, _pbt.ImageRectangle.Size); var scaledImage = ImageConverter.ResizeImage(pictureBox1.Image, _pbt.ImageRectangle.Size); g.DrawImage(scaledImage, 0, 0); scaledImage.Dispose(); foreach (var detail in Photo.Project.DetailAreas) { g.DrawRectangle(pen, ImageConverter.ScaleRectangle(detail.Crop, f)); } return(b); } } }