Windows Develop Bookmark and Share   
 index > Windows Forms General > mouse click +image+C#
 

mouse click +image+C#


using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Text;
using System.Windows.Forms;
using System.Runtime.Serialization;
using System.Configuration;
using System.Drawing.Imaging;


namespace WindowsApplication10
{
public partial class Form1 : Form
{
public static Bitmap bmp1;
public Bitmap bmp;
public Graphics grfx;
public float zoom = 1;
public Form1()
{

grfx=this.CreateGraphics();
bmp = new Bitmap(2500, 2500,PixelFormat.Format24bppRgb);
grfx = Graphics.FromImage(bmp);
Zoom = 1F;
grfx.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
grfx.InterpolationMode = InterpolationMode.HighQualityBicubic;
this.DoubleBuffered = true;
InitializeComponent();

}
protected override void OnPaint(PaintEventArgs e)
{
Graphics g = e.Graphics;


bmp.SetResolution(this.AutoScrollMinSize.Width /Zoom, this.AutoScrollMinSize.Height/Zoom);

g.InterpolationMode = InterpolationMode.HighQualityBicubic;

g.DrawImage(bmp, new Rectangle(this.AutoScrollPosition.X, this.AutoScrollPosition.Y, this.AutoScrollMinSize.Width, this.AutoScrollMinSize.Height), new Rectangle(0, 0, this.bmp.Width, this.bmp.Height), GraphicsUnit.Pixel);
}


private void Form1_MouseClick(object sender, MouseEventArgs e)
{

Graphics g = this.CreateGraphics();
Pen p = new Pen(Color.Blue);
Matrix x = new Matrix();
x.Scale(Zoom, Zoom);
g.Transform = x;

GraphicsPath path = new GraphicsPath();
path.AddEllipse(e.X / Zoom, e.Y / Zoom, 25, 25);
g.DrawPath(p, path);

grfx.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
grfx.InterpolationMode = InterpolationMode.HighQualityBicubic;
grfx.DrawPath(p, path);

}


protected override void OnMouseWheel(MouseEventArgs e)
{
if (e.Delta > 0)
{

if (Zoom < 10.1F) Zoom += 0.1F;

}

else if (e.Delta < 0)
{

if (Zoom > 0.1F) Zoom -= 0.1F;
}

}


public float Zoom
{
get
{
return zoom;
}
set
{
zoom = value;
UpdateControl();
}
}
float w = 0;
float h = 0;
void UpdateControl()
{

w = Zoom * (float)bmp.Width;
h = Zoom * (float)bmp.Height;
this.AutoScrollMinSize = new Size((int)w, (int)h);
this.Invalidate();
}
}
}

using System;
using System.Collections.Generic;
using System.Windows.Forms;

namespace WindowsApplication10
{
static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
}
}
}



i m drawing using mouse click and display in on paint using Bitmap(bmp)..but my issuse is on clarity please help me....

Please help me this code or better ....i wnat bitmap clarity to be nice as image drawn in mouse click..

algates  Tuesday, April 29, 2008 9:30 AM
!!!!!!!!!!!!!!!!!!11
dear_aruns  Tuesday, May 06, 2008 9:30 PM
Respected ARUN S,
What u r trying to say......
Regards,
ALGATES.

algates  Monday, May 12, 2008 7:30 AM

You can use google to search for other answers

Custom Search

More Threads

• Manual Scrollbar implementation in a Form
• Can't get the actual width and height of control?
• How do you find out the memory used by a recordset
• Validating parameters
• Can't have two "stretchy" controls in a TableLayoutPanel?
• Non-transparent controls on transparent form
• Create Email With Attachments Outlook 2003
• decimal calculations
• help
• Bind ComboBox to all Known Colors