onpaint

How to effectively draw on desktop in C#?

前提是你 提交于 2020-01-26 11:35:31
问题 I want to draw directly on the desktop in C#. From searching a bit, I ended up using a Graphics object from the Desktop HDC (null). Then, I painted normally using this Graphics object. The problem is that my shapes get lost when any part of the screen is redrawn. I tried a While loop, but it actually ends up drawing as fast as the application can, which is not the update rate of the desktop. Normally, I would need to put my drawing code in a "OnPaint" event, but such thing does not exist for

How to create inverse png image?

*爱你&永不变心* 提交于 2020-01-03 17:46:51
问题 i am creating png image which painted on my base, from the base i can save a png image, for your reference Graphics g = e.Graphics; .... g.DrawLine(pen, new Point(x, y), new Point(x1, y1)); ..... base.OnPaint(e); using (var bmp = new Bitmap(500, 50)) { base.DrawToBitmap(bmp, new Rectangle(0, 0, 500, 50)); bmp.Save(outPath); } this is single color transparency image, now how do i can inverse this image like png filled with any color and the real image portion should be transparent, is there

How to effectively draw on desktop in C#?

落爺英雄遲暮 提交于 2020-01-01 09:07:09
问题 I want to draw directly on the desktop in C#. From searching a bit, I ended up using a Graphics object from the Desktop HDC (null). Then, I painted normally using this Graphics object. The problem is that my shapes get lost when any part of the screen is redrawn. I tried a While loop, but it actually ends up drawing as fast as the application can, which is not the update rate of the desktop. Normally, I would need to put my drawing code in a "OnPaint" event, but such thing does not exist for

What is the right way to use OnPaint in .Net applications?

坚强是说给别人听的谎言 提交于 2019-12-30 07:06:35
问题 Sometimes I need a custom appearence of a control. Or do alot of custom painting. I know I can do so with OnPaint (see: http://msdn.microsoft.com/en-us/library/system.windows.forms.control.onpaint.aspx) What is the right way to custom paint stuff on your .net application using OnPaint ? Are there any rules I have to keep in mind to keep my application optimized, and keep render time to a minimum? Note: I have seen, and experienced, a lot of inefficient uses of OnPaint from time to time,

What is the optimal way to display images fast (C#)

天涯浪子 提交于 2019-12-25 07:39:28
问题 I am trying to create an application to display 8/16bit grayscale video. Currently, I create a BMP bitmap as RGB48 from frames, and simply assign pictureBox.Image = bmp This requires to create three redundant channels to make an RGB image look like grayscale (the grayscale image formats do not seem to work). This approach works on my fast computer, but slower computers can not keep up. So, I was hoping that someone could advise a better way of how to display images fast and efficient. In my

How to correctly get a WinForms Button control to draw custom text

旧巷老猫 提交于 2019-12-24 03:42:13
问题 I'm trying to create a custom winforms button control that will allow rotation of the button text through a rotation property. I've mostly got it working, but it's very kludgy and I would like to know the proper way to do this. Particularly right now the text redrawing is behaving strangely. If the control is moved off screen, and then moved slowly back on the text either becomes very messed up (such as only half drawn), or disappears entirely, until moused over. Obviously I'm doing something

Drawing an image onto a Panel control gives artefacts when resizing

。_饼干妹妹 提交于 2019-12-19 17:46:30
问题 Currently I'm trying to do what I thought would be a simple task: Draw an image onto the full area of a Panel control in Windows Forms. (Please ignore for the moment that I could use the BackgroundImage property) The image to draw looks like this: I.e. a yellow box with an 1 pixel blue frame around. To draw, I'm using the Paint event of the Panel control: private void panel1_Paint(object sender, PaintEventArgs e) { e.Graphics.DrawImage(Resources.MyImage, panel1.ClientRectangle); } This looks

Drawing an image onto a Panel control gives artefacts when resizing

て烟熏妆下的殇ゞ 提交于 2019-12-19 17:46:20
问题 Currently I'm trying to do what I thought would be a simple task: Draw an image onto the full area of a Panel control in Windows Forms. (Please ignore for the moment that I could use the BackgroundImage property) The image to draw looks like this: I.e. a yellow box with an 1 pixel blue frame around. To draw, I'm using the Paint event of the Panel control: private void panel1_Paint(object sender, PaintEventArgs e) { e.Graphics.DrawImage(Resources.MyImage, panel1.ClientRectangle); } This looks

How to use the OnPaint event in C#?

蓝咒 提交于 2019-12-18 04:20:10
问题 i saw some similar questions on the site but none of them really helped me. I have a function that draws a few lines on the form when a button is clicked that vary in shape depending on the values the user enters in some textboxes. My problem is that when i minimize the form, the lines disappear and i understood that this can be resolved by using the OnPaint event, but i don't really understand how. Can anyone give me a simple example of using a function to draw something at the push of a

can't invoke paint

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-13 02:58:42
问题 I created my own control and overwritten the onpaint event, the problem is that the paint event stopped working Any ideas why? And how to restore it? 回答1: Let's have a telepathic guess here: You forgot to call base.OnPaint(...) inside your override. Meaning that the base functionality is no longer invoked. 回答2: Maybe the control is obscured. I had a similar problem, and the problem was that the form in the Designer view was bigger than the actual form when the application was run. My custom