コード例 #1
0
    public void SetZoom(float zoomfactor)
    {
        if (zoomfactor <= 0)
        {
            throw new Exception("Zoom must be positive");
        }
        float oldZoom = Zoom;

        Zoom = zoomfactor / 100f;
        ScaleM.Reset();
        ScaleM.Scale(Zoom, Zoom);
        if (ImgSize != Size.Empty)
        {
            Size = new Size((int)(ImgSize.Width * Zoom),
                            (int)(ImgSize.Height * Zoom));
        }
    }
コード例 #2
0
    public void setZoom(float zoomfactor)
    {
        if (zoomfactor <= 0)
        {
            throw new Exception("Zoom must be positive");
        }
        float oldZoom = Zoom;

        Zoom = zoomfactor / 100f;
        ScaleM.Scale(Zoom, Zoom);
        // zoom the Image by changing the PB's size:
        if (ImgSize != Size.Empty)
        {
            Size =
                new Size((int)(ImgSize.Width * Zoom), (int)(ImgSize.Height * Zoom));
        }
        // here we rescale all point in the list
        for (int i = 0; i < ScaledPoints.Count; i++)
        {
            ScaledPoints[i] = new PointF(ScaledPoints[i].X * Zoom / oldZoom,
                                         ScaledPoints[i].Y * Zoom / oldZoom);
        }
    }