Click here to Skip to main content
15,890,579 members
Home / Discussions / C#
   

C#

 
GeneralRe: Object to IntPtr... Pin
led mike27-Oct-06 7:31
led mike27-Oct-06 7:31 
GeneralRe: Object to IntPtr... Pin
Shy Agam27-Oct-06 7:41
Shy Agam27-Oct-06 7:41 
GeneralRe: Object to IntPtr... Pin
led mike27-Oct-06 7:46
led mike27-Oct-06 7:46 
GeneralRe: Object to IntPtr... Pin
Eric Dahlvang27-Oct-06 8:12
Eric Dahlvang27-Oct-06 8:12 
GeneralRe: Object to IntPtr... Pin
Shy Agam27-Oct-06 8:27
Shy Agam27-Oct-06 8:27 
AnswerRe: Object --> IntPtr... Pin
ednrgc27-Oct-06 7:35
ednrgc27-Oct-06 7:35 
QuestionNewbie in need of webcam/capture/video overlay help Pin
edwa582327-Oct-06 6:18
edwa582327-Oct-06 6:18 
AnswerRe: Newbie in need of webcam/capture/video overlay help [modified] Pin
Larantz27-Oct-06 9:52
Larantz27-Oct-06 9:52 
You could let the control draw a rectangle as the user selects area for stillimage, and then use the 'control to bitmap' function to capture that exact rectangle.

Bitmap _capturedImage = null;
Brush _redbrush = new SolidBrush(Color.Red);
Brush _blackbrush = new SolidBrush(Color.Black);
Pen _pen = new Pen(_blackbrush);
Point _mousedown = new Point(-1,-1);
Rectangle _captureRect = new Rectangle(_mousedown, 0, 0);
bool _mouseheld = false;
</p>
private void videopanel_MouseDown(object sender, MouseEventArgs e)
{
   _mouseheld = true;
  _mouseDown = e.Location;
}
</p>
private void videopanel_MouseMove(object sender, MouseEventArgs e)
{
   if(_mouseheld)
   {
      videopanel.Refresh();

      Graphics g = videopanel.CreateGraphics();
      Point _mousemove = e.Location;
      g.DrawRectangle(
            _pen,
            _mouseDown.X,
            _mouseDown.Y,
            _mousemove.X - _mouseDown.X,
            _mousemove.Y - _mouseDown.Y);
   }
}
</p>
private void videopanel_MouseUp(object sender, MouseEventArgs e)
{
   _mouseheld = false;
   Graphics g = videopanel.CreateGraphics();
   Point _mouseup = e.Location;

   _captureRect = new Rectangle(
         _mousedown,
         _mouseup .X - _mouseDown.X,
         _mouseup .Y - _mouseDown.Y);

   _pen = new Pen(_redbrush);
   g.DrawRectangle(_pen, _captureRect);
}
</p>
private void CaptureButton_Click(object sender, EventArgs e)
{
   Graphics g = videopanel.CreateGraphics();

   Bitmap _bitmapComplete = new Bitmap(videopanel.Width, videopanel.Height);

   Rectangle _bitmapRect = new Rectangle(
         0,
         0,
         videopanel.Width,
         videopanel.Height);
   
   videopanel.DrawToBitmap(_capturedImage, _bitmapRect);

   _capturedImage = new Bitmap(
          _captureRect.Width,
          _captureRect.Height,
          g);

   g.DrawImage(_bitmapComplete, _bitmapRect,
          _captureRect, GraphicsUnit.Pixel);
}


NB!
Untested code though. Just something that popped into my head. Might have to refresh between each call to MouseMove to avoid multiple rectangles for instance.

Hope it might be of some help.

-Larantz-


-- modified at 18:56 Friday 27th October, 2006
Forgot to only draw while moving if mousebutton is held Wink | ;)
Tested it now on .net 1.1. The storing and drawing of rectangle works like a charm, though I don't have 2.0 for Control.DrawToBitmap() method.

for those about to code, we salute you
http://www.tellus-software.com

GeneralRe: Newbie in need of webcam/capture/video overlay help Pin
Larantz27-Oct-06 14:00
Larantz27-Oct-06 14:00 
QuestionDisplay Asian Characters in a Rich Text Box [modified] Pin
PowerRack27-Oct-06 5:58
PowerRack27-Oct-06 5:58 
QuestionC# MarshalAs problem Pin
cpshadle27-Oct-06 5:56
cpshadle27-Oct-06 5:56 
Question[Message Deleted] Pin
Rahithi27-Oct-06 5:22
Rahithi27-Oct-06 5:22 
AnswerRe: C# basic Exercise Help Pin
albCode27-Oct-06 5:29
albCode27-Oct-06 5:29 
General[Message Deleted] Pin
Rahithi27-Oct-06 6:06
Rahithi27-Oct-06 6:06 
GeneralRe: C# basic Exercise Help Pin
Kevin McFarlane27-Oct-06 6:26
Kevin McFarlane27-Oct-06 6:26 
AnswerRe: C# basic Exercise Help Pin
Kevin McFarlane27-Oct-06 5:47
Kevin McFarlane27-Oct-06 5:47 
General[Message Deleted] Pin
Rahithi27-Oct-06 6:47
Rahithi27-Oct-06 6:47 
GeneralRe: C# basic Exercise Help Pin
Guffa27-Oct-06 7:23
Guffa27-Oct-06 7:23 
GeneralRe: C# basic Exercise Help Pin
ednrgc27-Oct-06 7:37
ednrgc27-Oct-06 7:37 
GeneralRe: C# basic Exercise Help Pin
led mike27-Oct-06 7:50
led mike27-Oct-06 7:50 
General[Message Deleted] Pin
Rahithi27-Oct-06 6:56
Rahithi27-Oct-06 6:56 
GeneralRe: C# basic Exercise Help Pin
Dave Kreskowiak27-Oct-06 7:38
mveDave Kreskowiak27-Oct-06 7:38 
GeneralRe: C# basic Exercise Help Pin
ednrgc27-Oct-06 7:39
ednrgc27-Oct-06 7:39 
GeneralRe: C# basic Exercise Help Pin
BoneSoft27-Oct-06 10:17
BoneSoft27-Oct-06 10:17 
AnswerRe: C# basic Exercise Help Pin
Dan Neely27-Oct-06 8:18
Dan Neely27-Oct-06 8:18 

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.