How can i color the pixels that are only in the area of the rectangle i'm drawing on the picturebox1 ?

In the form i have picturebox mouse down event:
bool DrawIt = false;
private void pictureBox1_MouseDown(object sender, MouseEventArgs e)
timer1.Stop();
LoadPictureAt(trackBar1.Value, sender);
pictureBox1.Refresh();
if (e.Button == MouseButtons.Left)
rect = new Rectangle(e.X, e.Y, 0, 0);
DrawIt = true;
pictureBox1.Refresh();
rect is a global Rectangle variable.
The the picturebox mouse move event:
List<Point> NewPoints = new List<Point>();
private void pictureBox1_MouseMove(object sender, MouseEventArgs e)
if (e.Button == System.Windows.Forms.MouseButtons.Left)
if (DrawIt == true)
rect = new Rectangle(rect.Left, rect.Top, Math.Min(e.X - rect.Left, pictureBox1.ClientRectangle.Width - rect.Left), Math.Min(e.Y - rect.Top, pictureBox1.ClientRectangle.Height - rect.Top));
NewPoints.Add(e.Location);
pictureBox1.Refresh();
In the mouse move event i'm drawing the rectangle i didn't check it yet but in the move event i want to draw the rectangle in real time on the picturebox1.
Then the paint event:
private void pictureBox1_Paint(object sender, PaintEventArgs e)
if (cloudPoints != null)
if (DrawIt)
CloudEnteringAlert.pointtocolorinrectangle = cloudPoints;
Bitmap bmp = new Bitmap(pictureBox1.Width, pictureBox1.Height, PixelFormat.Format32bppArgb);
CloudEnteringAlert.Paint(e.Graphics, 1, 200, bmp);
First in the paint event how do i use the rect to draw the rectangle ?
Second cloudPoints contain all the pixels in the pictureBox1 Image. Could be 44000 or 400.
cloudPoints is a List<Point>  For example in cloudPoints index 0 i have a coordinate x = 100 y = 200 of a pixel.
Then i send the pixels coordinates to another class with Paint method and color the pixels in yellow.
But instead sending all the pixels coordinates in ccloudPoints i want to send to the paint event only the pixels coordinates from cloudPoints that exist inside the rectangle i was drawing. Only the pixels in the rectangle i was drawing.
So in the end the List<Point> pointtocolorinrectangle will contain only the pixels coordinates exist in the rectangle i was drawing.
1. How to fix the code in the move event ?
2. How to change the code in the paint event so it will send coordinates of pixels only that exist in the drawn rectangle.

I did it this way:
bool DrawIt = false;
private void pictureBox1_MouseDown(object sender, MouseEventArgs e)
timer1.Stop();
LoadPictureAt(trackBar1.Value, sender);
pictureBox1.Refresh();
if (e.Button == MouseButtons.Left)
rect = new Rectangle(e.X, e.Y, 0, 0);
DrawIt = true;
pictureBox1.Refresh();
List<Point> NewPoints = new List<Point>();
private void pictureBox1_MouseMove(object sender, MouseEventArgs e)
if (e.Button == System.Windows.Forms.MouseButtons.Left)
if (DrawIt == true)
rect = new Rectangle(rect.Left, rect.Top, Math.Min(e.X - rect.Left, pictureBox1.ClientRectangle.Width - rect.Left), Math.Min(e.Y - rect.Top, pictureBox1.ClientRectangle.Height - rect.Top));
NewPoints.Add(e.Location);
pictureBox1.Refresh();
private void pictureBox1_Paint(object sender, PaintEventArgs e)
if (cloudPoints != null)
if (DrawIt)
e.Graphics.DrawRectangle(pen, rect);
var pointsAffected = cloudPoints.Where(pt => rect.Contains(pt));
CloudEnteringAlert.pointtocolorinrectangle = pointsAffected.ToList();
Bitmap bmp = new Bitmap(pictureBox1.Width, pictureBox1.Height, PixelFormat.Format32bppArgb);
CloudEnteringAlert.Paint(e.Graphics, 1, 200, bmp);
Working perfect just what i needed.

Similar Messages

  • How can I create a slideshow that depicts only a version of a photo rather than the original? Since the original and new versions are saved together, the aperture slideshow often choices the original rather than the desired version to display/

    How can I create a slideshow that depicts only a version of a photo rather than the original?   Since the original and new versions are saved together, the aperture slideshow often choices the original rather than the desired version to display.

    There are two things we use the name "Slideshow" for in Aperture:  a Slideshow Album, used for making Slideshows, and the Slideshow that is made.  (Imho, it is a design mistake to not call the containers used to create Slideshows, Books, etc., "Albums".)
    The Slideshow will use the Album Pick from any Stack.  A good way to use Aperture is to promote the Image you want to regularly use (such as, for example, a Version with adjustments) to the top of the Stack.  This makes it the Stack Pick, and will be the default Album Pick.  If you haven't done that, you can still change the Album Pick for any Stack in a Slideshow Album.  Expand your Stack(s), select the Image in each Stack that you want to be the Album Pick (and thus shown in the Slideshow), and "Stacks➞Set Album Pick".  (Note the keyboard shortcut; there is also a Toolbar icon for this.)  The change is immediate.  The Slideshow will always show the Album Pick (or, if there is not one, the Stack Pick) for every Stack in your Slideshow Album.

  • HT1727 How can i retrieve purchased audiobooks that were not synced (problem encountered during sync process).  My account shows the purchase history, but the apps are no longer displayed in itunes or on my ipad or iphone

    How can i retrieve purchased audiobooks that were not synced (problem encountered during sync process)?  My account shows the purchase history, but the apps are no longer displayed in itunes or on my ipad or iphone.  I'm not very savvy with using iTunes - I don't think is very intuitive (unlike me:)).  Any help would be appreciated.
    Thanks

    Hello mcegirl4,
    Thanks for using Apple Support Communities.
    Please refer to the instructions in the following article to assist in downloading those previous purchases from iTunes and the App Store:
    Download past purchases
    http://support.apple.com/kb/HT2519
    Take care,
    Alex H.

  • How can I delete old movies that I already purchased, which are saved in my account? Actually I don't want them to be viewed by others who use same account, so is there any solution to delete them? Please advise. Thank you

    How can I delete old movies that I already purchased, which are saved in my account? Actually I don’t want them to be viewed by others who use same account, so is there any solution to delete them? Please advise.

    Delete Purchases = No.
    But there is this...Hiding and unhiding purchases
    iTunes Store  >   http://support.apple.com/kb/HT4919

  • How can I set a passcode that is only required at certain times of the day. Ie: my child needs access for school use, but don't want her playing iPad in the middle of the night. I cannot identify a way to have the iPad turn off or require a password

    I cannot find a way to enable my child's iPad to require a passcode only at certain times of the day.
    Yes I have used the clock/timer/ countdown - great to restrict how many minutes of iPad usage they get a day.
    But as my child requires the iPad in school for class lessons the usage at school varies maybe 30 mins 1 day and a few hrs on other days
    I want the ability to say set the iPad to not work between say 7pm and 7am, ( unless a passcode is entered) so my child isn't playing games on it in the middle of the night...
    Apple I cannot see anything in the settings that performs this function
    Help

    You can Remote Lock his iPad with Find My iPad using a computer at whatever time you like.
    http://support.apple.com/kb/PH2700
    Note: The iPad may be disabled if he tries the passcode too many times.

  • How can I purchase an album that is only available in the US and not Australia? HELP!

    I wish to purchase an artist album that is only available in the US iTunes store. Is it possible to get my hands on?

    Not from itunes.
    You can buy it from Amazon or some other music retailer.

  • HOW can i buy an album that is only available in my country?

    I recently bumped into this awesome album
    http://itunes.apple.com/ie/album/need-to-feel-loved-feat.-delline/id329722641
    Unfortuneately, it says that my "apple id is only valid for purchases in sweden".
    Now - how can we get past that? Is there ANY way of solving this problem?

    Not from itunes.
    You can buy it from Amazon or some other music retailer.

  • How can I order a calendar that I created in iPhoto 7.1.5, now incompatible with Apple Store.

    How can I order a calendar that I created in iPhoto 7.1.5 which is now incompatible with the Apple Store?  I am using a mac pro 1,1 which cannot upgrade to the new version of iPhoto.

    You could try to upgrade to an earlier iPhoto '11 version, since you are running Snowleopard.
    iPhoto '11 should still be available as part of the boxed retail version of iLife '11.
    Try to buy one at Amazon, then upgrade to iPhoto 9.2.x from the Support page:  http://support.apple.com/downloads/#iphoto%209.2

  • How can i reuse same variables that i create using c:set var="index" /

    hi all,
    please some one helpme!!!!!!
    how can i reuse same variable that i create using
    <c:set var="index" value="${0}"/>
    cause later in the program i use index to do some condition and based on that i increment ...
    so for example if i say...
    <c:if test="${index==0}">
    <c:set var="index" value="${index+1}"/>
    </c:if>
    will it be like
    if(index==0)
    index++;
    can i do like i did be4. if not what do i need to do to reuse. cause i use the variable atleast 5 time and its keep changing on diff condition level.

    Have you tried it?
    It should work, provided you are on the same page.
    The c:set tag creates the variable in pageScope by default.
    If you forward to another JSP you need to set the scope to be "request" so that it is still available.

  • How can I delete plug-ins that I do not want then anymore?

    how can I delete plug-ins that I do not use anymore?

    Uninstall them by deleting them from the Library:
    The plug-ins usually are installed in the Applications Support Folder -> Aperture -> Plug-Ins, either in your your User Library or in the System Library:
    your home folder/Library/Application Support/Aperture/Plug-Ins/
    /Library/Application Support/Aperture/Plug-Ins/

  • How can I turn a form that is open on my browser into a PDF doc if I cannot save it onto my computer

    How can I turn a form that is on my Safari browser into a PDF if I cannot save the form onto my computer?

    Acrobat XI Pro has a "create PDF from a web page" feature. If you have Acrobat XI Pro installed perhaps you can "capture" the web form as a PDF. If so then this PDF can (of course) be saved to the local machine's HDD.
    Be well...

  • How can i eject a dvd that seems to be in a reading loop

    how can i eject a dvd that seems to be in a reading loop

    A few options: restart holding down the mouse button; launch Disk Utility in Utilities folder, select the DVD on the left and click on the eject button.
    More suggestions here: http://osxdaily.com/2009/08/28/eject-a-stuck-disk-from-your-mac-dvd-super-drive/

  • How can i set a form to read only when a checkbox it checked?

    How can i set a form to read only when a checkbox it checked?

    Hi,
    If you search the forums for Paul's example LockAllFields. This contains a function in a script object that you can call from the click event of the checkbox.
    Re: Saving Fillable Form as non-fillable PDF
    Good luck,
    Niall
    Assure Dynamics

  • How can I set two different emails in only one contact form?

    How can I set two different emails in only one contact form?

    To enter multiple email address with the Contact Form Widgets:
    Click the Options icon for the selected widget, then
    In the Email to box, enter multiple emails by delimiting them with a semi-colon. For example: [email protected];[email protected]
    Cari

  • All photos in portrait format are displayed blurred in the preview mode "fill" of the library. In all other modes e.g. "fit"or "1:2" the photos are sharp. How can I change this, so that the photos are still sharp when displaying them in the mode "fill"?

    All photos in portrait format are displayed blurred in the preview mode "fill" of the library. In all other modes e.g. "fit"or "1:2" the photos are sharp. How can I change this, so that the photos are still sharp when displaying them in the mode "fill"? My Lightroom release is 5.7.1.
    Thanking you in anticipation!

    I'd like to get all these '-1 suffix' files together with their associated Develop adjustments into one folder (if they aren't already) so I can see them in Grid view in the Library module, which I use as my basic starting point for everything else at this early stage of my Lightroom 'career'.
    To see what folder these are stored in, right-click on a photo and select "Go to Folder in Library".
    Advice: if you are going to use Lightroom effectively, you probably want to stop using folders as your method to create a grouping of photos that are already in Lightroom; there are plenty of built-in tools, such as keywords, collections, color labels, etc.
    I don't understand why the search on the entire catalog picked up apparently the same two file versions but also got the Develop adjustments when going to the relevant Folder didn't show the adjustment black squares against each image in Grid view nor were they there when the images were opened in the Develop module.  Perhaps if I understood this, I'd be a bit more confident of moving forward myself.
    These are most likely different versions of the same photo, in different folders. Lightroom stores the edits in its own catalog, and so it knows that one folder's photos have edits, and the other folder's photos do not have edits. Please understand that Lightroom is a database, it knows where the photos are at the time you import them (or add them to the catalog by synchronize), and then if you move things around in your operating system, Lightroom does not know anything about that and problems begin. Thus the advice to organize using Lightroom tools and methods and not operating system tools and methods.

  • How can I get my books that I download from the Library that are WMA files into my I tunes so I can listen to them

    How can I get my books that I download from the Library that are WMA files into my I tunes so I can listen to them. They have a ton of books but I can only listen to them from my windows media player and I wouldlove to download to my I pod but I have tried everything I can think of it they won't go over.  Someone said all I had to do was copy them over and they would convert but I can't even get them to copy.  Thanks.

    Well it started happening AGAIN with my 2nd IPod. No matter what I did, it Itunes would NOT restore it!
    I finally installed Itunes on my hubby's PC at work and managed to get it restored there.
    Apparently, there must be some sort of compatibility issue with the windows version of Itunes and some other piece of software on my pc.
    And one more important thing! I had to follow the instructions in the other thread that talks about how to correctly uninstall itunes and quicktime, in order to completely eliminate ALL traces of my "first" ipod's existence so it wouldn't demand that I restore it.
    I think the software got "confused" and thought when I connected my 2nd ipod, that it was the 1st and that it still needed to be restored.
    Basically, this is just POORLY written and POORLY tested software!

Maybe you are looking for

  • Usability of the new Keyboard?

    I was reading an article (a persons opinion) and in it he mentioned that touch typists would have difficulty with Apple's new keyboard as fingers wander from the home row due to a lack of a point on the f and j keys to keep them there. He also mentio

  • Reload Software:552 and then "Application loader was unable to connect with your device."

    Hi guys I'm new to this forum and looking for a help please.. My curve 8900 got the "Reload Software:552" message on the screen. I was trying to uninstall an application and after it asked me to reboot, it showed me that message. I already try to rei

  • How to print a Movie clip inside uiLoader?

    Hi, I;m making a flash application in AS3, and I've got a little problem. Which is here... Here is my code.... /* Print Button Function Here.....*/ print_btn.addEventListener(MouseEvent.CLICK,printPage); function printPage(evt:MouseEvent) {     var p

  • Wireless Died on WRT54GS

    Earlier this morning, all wireless computers on my WRT54GS v1.1 stopped communicating with the router. The SSID was no longer shown in the list of available networks. After disabling wireless on the router for a few minutes, and re-enabling it, the S

  • Captivate 7 Zoom Function

    I was making changes to a course originally produced in Captivate 5.5, updating the content using Captivate 7.  I ran across a problem where a zoom area no longer functions as it did when produced in Captivate 5.5.  When originally produced in Captiv