473,804 Members | 2,140 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

PictureBox Painting

15 New Member
I am working in C# and have a windows form containing a picturebox. The picture box is loaded with a bitmap by the user. The bitmaps are larger then the window and require scrolling. There is an option to overlay a grid on the bitmap. If the grid has been selected it appears over the image. If the scroll bar buttons are used to view the rest of the image the grid remains visible. If the mouse is clicked in the scroll bar to move to a different part of the image, the grid appears for a split second before being replaced by the image. If the scroll bar buttons are now used the grid reappears. I have been using the event paint in picturebox to draw/redraw the grid. I don't want to add the grid to the image. The code for I am using for the paint event is:
Expand|Select|Wrap|Line Numbers
  1.         private void pictureBox_Paint(object sender, PaintEventArgs e)
  2.         {
  3.                 if (grid)
  4.                 {
  5.                     griddraw();
  6.                 }
  7.         }
  8.  
Where grid is a bool to show if the user wants the grid on and griddraw is a function which draws the grid over the image. In griddraw I am using Graphics and CreateGraphic.

Any help would be appericated.
Jim
Jan 31 '07 #1
1 6552
jimwawar
15 New Member
It seems I have solved my problem. DO NOT use the PictureBox controls to work the image. Use PaintEventArgs and pass the event to the method. My PictureBox paint event now looks like
Expand|Select|Wrap|Line Numbers
  1.         private void pictureBox_Paint(object sender, PaintEventArgs e)
  2.         {
  3.                 if (grid)
  4.                 {
  5.                     griddraw(e);
  6.                 }
  7.         }
  8.  
Also if you are working with graphics I would recommend the following site
http://www.bobpowell.n et/faqmain.htm

I am working in C# and have a windows form containing a picturebox. The picture box is loaded with a bitmap by the user. The bitmaps are larger then the window and require scrolling. There is an option to overlay a grid on the bitmap. If the grid has been selected it appears over the image. If the scroll bar buttons are used to view the rest of the image the grid remains visible. If the mouse is clicked in the scroll bar to move to a different part of the image, the grid appears for a split second before being replaced by the image. If the scroll bar buttons are now used the grid reappears. I have been using the event paint in picturebox to draw/redraw the grid. I don't want to add the grid to the image. The code for I am using for the paint event is:
Expand|Select|Wrap|Line Numbers
  1.         private void pictureBox_Paint(object sender, PaintEventArgs e)
  2.         {
  3.                 if (grid)
  4.                 {
  5.                     griddraw();
  6.                 }
  7.         }
  8.  
Where grid is a bool to show if the user wants the grid on and griddraw is a function which draws the grid over the image. In griddraw I am using Graphics and CreateGraphic.

Any help would be appericated.
Jim
Jan 31 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
4775
by: Calan | last post by:
I have a form with some picture boxes as buttons. I'm setting the picture property to a gif file for "normal", and to a different gif for the "pressed" state. This works fine. I get into trouble with the fact that the gif files have a transperent region in the middle (the button icon) that lets the back color of the picture box show through. This lets me change the button highlight to any user-specified color when I mouseover the picbox...
12
57342
by: yaya via DotNetMonster.com | last post by:
Hi, I have a picture box with circles and rectangles, and I wana save all the images into a jpg file, i tried pictureBox1.Image.Save(@"c:\1.jpg"); but I got and error "System.NullReferenceException: Object reference not set to an instance of an object." Can anyone help? Thanks... --
2
3208
by: Crirus | last post by:
hello I have apicturebox painted in it's paint event. I need a way to save the image created. Image obj of my picturebox is Nothing. How to output to a jpg my image? Crirus
0
3886
by: akh | last post by:
I want to use de Drag and Drop ´s event to move a picture box from a form and within a Picture Box. But I have behaviour if the MyPBox As PictureBox as the Globale varible or not Thanks for your help, Here is the code.
2
1371
by: Jarod | last post by:
Hell I tried to make a watermark... So . I have a picturebox1.. Picturebox1.creategraphic.drawString("Jarod Ltd.",... and it works.. But when I do dim img as imag img = picturebox1.image img.save("c:\test.jpg"
3
63450
by: Tom | last post by:
I have a picturebox on my VB.NET form. The picturebox size mode is set to stretched. I then load an image into that form and display it. As the user moves the mouse over the form, I want to get and display (in the status bar) the image coordinates of the mouse location. However, if I use the picturebox's MouseMove event, I am getting the coordinates of the mouse over the PICTUREBOX, not the actual image underneath that (which is stretched)....
1
1610
by: John | last post by:
I have a picturebox that displays images from a camera through a third party dll. When the image is displayed, MyPicturebox.Image is nothing. So I want to know in situation like this, how to copy the content of MyPicturebox into a bitmap object. Thanks.
3
2024
by: ktcute | last post by:
I'm trying to write a simple drawing tool that saves images out as jpgs. I've been using the paint event on the Panel control to draw the objects, however I couldn't get the same drawing functionality when I switched to use a Picturebox control. I found that after all the objects had been painted on the control, they "disappeared". I'm wondering if this is deliberate, and if someone can suggest another way I can go about saving my...
1
2571
by: The Confessor | last post by:
I'm trying to develop a graphically-simple, gameplay-complex RPG, and I decided to create a graphical Proof of Concept just to confirm that graphics would be... well, simple. Predictably, they've proven otherwise. This is my PictureBoxMap_Paint() Sub, which a tiles a PictureBox with 19* 17 40*40-pixel images, two rows and two columns of which are painted beyond the current bounds of the picturebox to facilitate scrolling. The If/Else...
0
9715
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10353
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10356
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7643
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6869
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5536
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5675
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3836
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3003
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.