Click here to Skip to main content
15,887,214 members
Home / Discussions / C#
   

C#

 
GeneralRe: how to session value in a page. Pin
Mubeen.asim12-Aug-10 23:17
Mubeen.asim12-Aug-10 23:17 
QuestionResize problem for drawn rectangle on the picture box? Pin
Nivas8212-Aug-10 20:27
Nivas8212-Aug-10 20:27 
AnswerRe: Resize problem for drawn rectangle on the picture box? Pin
Luc Pattyn13-Aug-10 2:05
sitebuilderLuc Pattyn13-Aug-10 2:05 
GeneralRe: Resize problem for drawn rectangle on the picture box? Pin
Nivas8217-Aug-10 20:30
Nivas8217-Aug-10 20:30 
GeneralRe: Resize problem for drawn rectangle on the picture box? Pin
Luc Pattyn18-Aug-10 1:41
sitebuilderLuc Pattyn18-Aug-10 1:41 
GeneralRe: Resize problem for drawn rectangle on the picture box? Pin
Nivas8223-Aug-10 2:12
Nivas8223-Aug-10 2:12 
AnswerRe: Resize problem for drawn rectangle on the picture box? Pin
Luc Pattyn23-Aug-10 2:16
sitebuilderLuc Pattyn23-Aug-10 2:16 
GeneralRe: Resize problem for drawn rectangle on the picture box? Pin
Nivas8223-Aug-10 23:09
Nivas8223-Aug-10 23:09 
Please see the code below and guide me where iam going worng. Thanks.....

     private void openToolStripMenuItem_Click(object sender, EventArgs e)
        {

            OpenFD.FileName = "";
            OpenFD.Title = "open image";
            OpenFD.InitialDirectory = "C";
            OpenFD.Filter = "JPEG|*.jpg|Bmp|*.bmp|All Files|*.*.*";
            if (OpenFD.ShowDialog() == DialogResult.OK)
            {
                file = OpenFD.FileName;

                image1= image = Image.FromFile(file);
               
                sz1.Width = 800;
                sz1.Height = 650;
                svc = Screen.PrimaryScreen;
//adjust the image to fit in the panel
               image= resizeimage(image, sz1);
                rectangles.Clear();
                
            }

        }
        private Image resizeimage(Image my, Size sz1)
        {
            double ratio = 0d;
            
            double myThumbWidth = 0d;
            double myThumbHeight = 0d;
            Bitmap bp;
                            if ((my.Width / Convert.ToDouble(sz1.Width)) > (my.Height /
                Convert.ToDouble(sz1.Height)))
                    ratio = Convert.ToDouble(my.Width) / Convert.ToDouble(sz1.Width);
                else
                    ratio = Convert.ToDouble(my.Height -10) / Convert.ToDouble(sz1.Height);

           
            myThumbHeight = Math.Ceiling(my.Height / ratio);
            myThumbWidth = Math.Ceiling(my.Width / ratio);
            Size thumbSize = new Size((int)myThumbWidth, (int)myThumbHeight);
          
// getting screen resolution (svc)
            sz.Width = svc.Bounds.Width;
            sz.Height = svc.Bounds.Height;
             rect2 = rect = new Rectangle(0, 0, thumbSize.Width, sz.Height-120);

// getting the value to display the image in the centre of the screen resolution
            panelpostion= Convert.ToInt16((sz.Width -10) /3.5);

            bp = new Bitmap(sz.Width-10, rect.Height);
            bp.SetResolution(300, 300);
            g = Graphics.FromImage(bp);
            g.SmoothingMode = SmoothingMode.HighQuality;
            g.InterpolationMode = InterpolationMode.HighQualityBicubic;
            g.PixelOffsetMode = PixelOffsetMode.HighQuality;
            g.DrawImage(my, rect, 0, 0, my.Width, my.Height, GraphicsUnit.Pixel);
           
// giving bitmap size to panel
 panel1.Size= bp.Size ;

            rect = new Rectangle(0, 0, 0, 0);
            return (bp);
       
        }

     public void ZoomIn()
        {
            double ratio = 0d;
            double ratio1 = 0d;
            if (sz1.Width >= Convert.ToInt16(sz.Width*3.8))
                MessageBox.Show("Max ZoomIn");
            else
            {
                
                sz1.Width += 50;
                sz1.Height += 50;
                ratio = Convert.ToDouble(sz1.Width) / Convert.ToDouble(panel1.Width);
                ratio1 = Convert.ToDouble(sz1.Height) / Convert.ToDouble(panel1.Height);
                panel1.Size = sz1;
                //adjusting the image to stay in top and move left.
                 panelpostion = panelpostion - 5;

//calculation the new rectangle value....

                for (c = 0; c <= (rectangles.Count - 1); c++)
                {
                                      
                    rect1.X = Convert.ToInt16(Convert.ToDouble(rectangles[c].X) * ratio);
                    rect1.Y = Convert.ToInt16(Convert.ToDouble(rectangles[c].Y) * ratio);
                    rect1.Width = Convert.ToInt16(Convert.ToDouble(rectangles[c].Width) * ratio);
                    rect1.Height = Convert.ToInt16((Convert.ToDouble(rectangles[c].Height) * ratio));
                    rectangles.RemoveAt(c);
                    rectangles.Insert(c, rect1);
                }
            }
            panel1.Invalidate();
            
        }

private void panel1_Paint(object sender, PaintEventArgs e)
        {
   using (g = Graphics.FromImage(mybitmap))
                {

// drawing the image on the panel                      
  e.Graphics.DrawImage(image, new Rectangle(panelpostion, 0, panel1.Width, panel1.Height));
                  
  
                   
                    using (Pen pen = new Pen(Color.Green, 3))
                    {
                            pen.Color = Color.Red;
                            pen.DashStyle = System.Drawing.Drawing2D.DashStyle.Dash;

                            e.Graphics.DrawRectangle(pen, rect);
                            c = 0;
                            foreach (Rectangle r in rectangles)
                            {
                                e.Graphics.DrawRectangle(pen, r);
                                e.Graphics.DrawString(lab[c].ToString(), new Font(lab[c].ToString(), 8F), new SolidBrush(label1.ForeColor), r);
                                c++;
                            }

                    }
                }
}

private void panel1_MouseDown(object sender, MouseEventArgs e)
        {
 if (mybitmap == null)
            {
                mybitmap = new Bitmap(panel1.Width, panel1.Height);
                mybitmap.SetResolution(300, 300);
            }
rect = new Rectangle(e.X, e.Y, 0, 0);
}

//adding rectangle value in  Panel mouse click event.

GeneralRe: Resize problem for drawn rectangle on the picture box? Pin
Nivas8220-Oct-10 21:30
Nivas8220-Oct-10 21:30 
QuestionHow to load a referenced dll from specified location not GAC? Pin
Jack2009512-Aug-10 16:57
Jack2009512-Aug-10 16:57 
AnswerRe: How to load a referenced dll from specified location not GAC? Pin
PIEBALDconsult12-Aug-10 17:46
mvePIEBALDconsult12-Aug-10 17:46 
GeneralRe: How to load a referenced dll from specified location not GAC? Pin
Luc Pattyn12-Aug-10 18:07
sitebuilderLuc Pattyn12-Aug-10 18:07 
GeneralRe: How to load a referenced dll from specified location not GAC? Pin
PIEBALDconsult12-Aug-10 18:14
mvePIEBALDconsult12-Aug-10 18:14 
GeneralRe: How to load a referenced dll from specified location not GAC? Pin
Luc Pattyn12-Aug-10 18:17
sitebuilderLuc Pattyn12-Aug-10 18:17 
GeneralRe: How to load a referenced dll from specified location not GAC? Pin
Jack2009512-Aug-10 18:37
Jack2009512-Aug-10 18:37 
GeneralRe: How to load a referenced dll from specified location not GAC? Pin
PIEBALDconsult12-Aug-10 19:11
mvePIEBALDconsult12-Aug-10 19:11 
GeneralRe: How to load a referenced dll from specified location not GAC? Pin
Jack2009512-Aug-10 22:57
Jack2009512-Aug-10 22:57 
GeneralRe: How to load a referenced dll from specified location not GAC? [modified] Pin
PIEBALDconsult13-Aug-10 3:10
mvePIEBALDconsult13-Aug-10 3:10 
QuestionArrays and Classes Pin
dluurs12-Aug-10 15:22
dluurs12-Aug-10 15:22 
AnswerRe: Arrays and Classes Pin
Luc Pattyn12-Aug-10 15:33
sitebuilderLuc Pattyn12-Aug-10 15:33 
GeneralRe: Arrays and Classes Pin
PIEBALDconsult12-Aug-10 17:48
mvePIEBALDconsult12-Aug-10 17:48 
AnswerRe: Arrays and Classes Pin
Richard MacCutchan12-Aug-10 22:43
mveRichard MacCutchan12-Aug-10 22:43 
QuestionListBox SelectedValueChanged firing twice Pin
Pete Burkindine12-Aug-10 11:56
Pete Burkindine12-Aug-10 11:56 
AnswerRe: ListBox SelectedValueChanged firing twice Pin
Luc Pattyn12-Aug-10 12:37
sitebuilderLuc Pattyn12-Aug-10 12:37 
GeneralRe: ListBox SelectedValueChanged firing twice Pin
Pete Burkindine13-Aug-10 4:56
Pete Burkindine13-Aug-10 4:56 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.