473,394 Members | 1,679 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

C# panel onpaint event paint event args e.drawImage

Hi,

I have a panel control in windows form. And I want an Image on the background of the panel. But I dont want to loop through it to draw images to it.

Expand|Select|Wrap|Line Numbers
  1. for (int i = 1; i <= 5; i++)
  2.             {
  3.                 int height = Resource1.owners_icon.Height * i;
  4.                 int width = Resource1.owners_icon.Width;
  5.                 for (int j = 1; j <= 5; j++)
  6.                 {
  7.                     e.Graphics.DrawImage(Resource1.owners_icon, j * width, height);
  8.                 }
  9.  
My code actually draws an image multiple times. and I need it to do the same thing but I dont want loops.

Do any one have the solution?
Regards,
Syed Ahmed Hussain
Oct 1 '10 #1
3 5695
GaryTexmo
1,501 Expert 1GB
I'm not sure I understand the question. Is it that you have a sequence of images and want to merge them all into one, then draw that as a single background image?

If this is the case, why not just draw all the images to another image first (ie, whenever you read the images), then in the paint method just draw the merged image?

If I've misunderstood, can you please clarify your question?
Oct 1 '10 #2
Hi Gary,
I'm not sure I understand the question. Is it that you have a sequence of images and want to merge them all into one, then draw that as a single background image?
I am actually having a single image of size 11 X 11 px name it abc.jpg. I want this Image to multiply on the background, i.e, when it prints on the background it wont be a single image it will be the set of this image.

Let me put it this way. My code actually prints this image in a panel background multiple times, in a sequence, merged as a single image. Yes Gary you're thinking in the right direction.

If this is the case, why not just draw all the images to another image first (ie, whenever you read the images), then in the paint method just draw the merged image?
Can you please provide me a code snippet which actually you have tried or that you think might work?

Thank you,

Regards,

Syed Ahmed Hussain
Oct 2 '10 #3
GaryTexmo
1,501 Expert 1GB
I'd be happy to help you get started :)

The Graphics class provides a way to get a graphics handle to an image. Here's an example...

Expand|Select|Wrap|Line Numbers
  1. Image destImage = new Bitmap(500, 500);
  2. Graphics g = Graphics.FromImage(destImage);
Now you can draw to that image... for example, another image.

Expand|Select|Wrap|Line Numbers
  1. g.DrawImage(srcImage, new Point(0, 0));
In this way, you can do your tiling in, say, your constructor (or wherever you need to generate the image) using a loop but simply draw the final image.
Oct 4 '10 #4

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

Similar topics

7
by: Schorschi | last post by:
I know there is a way to do this, but I don't know how. Via a custom event? I have some code that I only want to run during a paint event. I could build a form instance that has the code and...
5
by: active | last post by:
This is what I do in a PictureBox New: b1 = New Drawing.Bitmap(Width, Height, Me.CreateGraphics()) g1 = Graphics.FromImage(b1) Someplace I do g1.DrawString.........
2
by: Simon Jefferies | last post by:
Hello, How can i perform double buffering on the Paint Event of a panel control. TIA Simon
4
by: Aaron Smith | last post by:
I have a panel that I have in the paint event to draw a Raised 3d border around it.. The problem is, if a msgbox is popped up or a tooltip is displayed, it leaves lines on the panel. I've tried...
7
by: Dennis | last post by:
I am trying to implement drawing on a bitmap and using bitblt to transfer it to the control graphics object in the paint event. It seems to draw on the bitmap ok but doesn't get transferred to the...
7
by: hamil | last post by:
The following code will display a tif file on a form. When another form is moved over the tif image, the tif image is erased where the form was moved. A paint event occurs when this happens. My...
1
by: edi sol | last post by:
Hi, I have a user control and panel in this control. I write a paint event of the panel control. When I strat the application (windows form with this control only) the paint event executes twice....
13
by: Frank Rizzo | last post by:
I am creating a User Control that does a lot of it own painting from the UserControl_Paint event mostly using the e.Graphics object that's passed into Paint event. It works pretty good. ...
12
by: Matt Bitten | last post by:
I've got a wxPython program that needs to do some drawing on a DC on a regular basis, whether or not a paint event happens. I know how to make a ClientDC to do the drawing in, and I know what...
2
tranc3d
by: tranc3d | last post by:
Hello, I have a custom panel in my project (this one: http://www.codeproject.com/KB/graphics/fastimagedrawing.aspx) with a custom paint event ( protected override void OnPaint(PaintEventArgs pe)...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.