gdi+

How do I create a blurred-glass effect on a border-less Form?

安稳与你 提交于 2019-12-20 09:38:16
问题 How do I draw a smooth blurred-glass effect on a border-less Form? I have tried the code listed on Image Processing for Dummies with C and GDI+ page but I'm sure it's not what I should be using. No amount of playing around with it has yielded any kind of result that is what I'm after. This is basically what I'm trying to achieve: 回答1: I'll assume you are talking about Windows 7 / Vista, and you'd like to achieve the blurry transparent areas that some MS programs have in the same way. For the

Painting on a listview disables the redraw on listview items

三世轮回 提交于 2019-12-20 06:48:55
问题 What's the reason for this? I override OnPaintBackground and draw a string. It doesn't show up until I call this in the constructor: this.SetStyle ( ControlStyles.UserPaint, true ); But then I don't see the items in the listview. Why and how to solve this? EDIT: code protected override void OnPaintBackground ( PaintEventArgs pevent ) { base.OnPaintBackground ( pevent ); // Create string to draw. String drawString = "76"; // Create font and brush. Font drawFont = new Font ( "Arial", 36 );

How to prevent Graphical stutter when scrolling a large zoomed out picture

六月ゝ 毕业季﹏ 提交于 2019-12-20 04:31:52
问题 I have a large tiff picture (5.9 Mb , 13k X 16k reolution) that the user loads into a scrollable panel that he then can zoom in/out of, scroll and mark points, regions etc on. for the scrollable double buffered panel I am using a modification of Bob Powell's awesome ZoomPicBox The panel displays only the part of the picture currently in view. The stutter occurs when scrolling the image when zoomed out (even if the interpolationMode is set to low) Is there anything that can be done about it

MeasureString always thinks whitespace will fit

心已入冬 提交于 2019-12-20 04:26:07
问题 I'm trying to do some hit testing on strings (I want to get the char index from the x offset), but I'm hitting issues with measure string. This is essentially the code I am using StringFormat sf = new StringFormat(StringFormatFlags.MeasureTrailingSpaces | StringFormatFlags.NoWrap | StringFormatFlags.LineLimit); e.Graphics.MeasureString("test string", this.Font, new SizeF(xHitTestPosition, this.Font.Height), sf, out charFitted, out linesFilled); The value of charFitted should be set to the

fast way to create a big bitmap from an array of bitmap?

百般思念 提交于 2019-12-20 03:15:35
问题 I have this code, copy/paste in a new winform app and this will write a file on your desktop if you run it: test123abcd.png Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load Dim SquareSize = 5 Dim GridX = 2500 Dim GridY = 2500 Dim SquareCount = GridX * GridY - 1 Dim sw As New Stopwatch Dim Rect(4) As Rectangle Rect(0) = New Rectangle(0, 3, 3, 1) Rect(1) = New Rectangle(3, 0, 1, 3) Rect(2) = New Rectangle(3, 3, 3, 1) Rect(3) = New Rectangle(0, 0, 1, 3)

Is there any way to draw an image to use 4 points rather than 3 (perspective warp)

半世苍凉 提交于 2019-12-20 02:59:10
问题 Drawing a parallelgram is nicely supported with Graphics.DrawImage: Bitmap destImage = new Bitmap(srcImage.Width, srcImage.Height); using (Graphics gr = new Graphics.FromImage(destImage)) { Point[] destPts = new Point[] { new PointF(x1, y1), new PointF(x2, y2), new PointF(x4, y4)}; gr.DrawImage(srcImage, destPts); How, do you do 4 points (obviously the following is not supported, but this is what is wanted): Bitmap destImage = new Bitmap(srcImage.Width, srcImage.Height); using (Graphics gr =

Is there a way to programmatically add text to a System.Drawing.Image?

喜夏-厌秋 提交于 2019-12-20 02:52:44
问题 I have a System.Drawing.Image that I display with System.Drawing.Graphics DrawImage function. The image is a police car, and I would like to draw a unit number on top of the police car. Is there an easy way to do this? 回答1: You can use the DrawString method to write text out onto an image. // Create string to draw. String drawString = "Sample Text"; // Create font and brush. Font drawFont = new Font("Arial", 16); SolidBrush drawBrush = new SolidBrush(Color.Black); // Create point for upper

.NET GDI+: Drawing lines with rounded corners

≡放荡痞女 提交于 2019-12-20 02:41:49
问题 Given an array of points, it is easy to draw a line based on these, e.g. using the GraphicsPath class. For instance, the following array of points... [0]: (0,0) [1]: (100,0) [2]: (0,100) [3]: (100,100) ...describes a line that resembles a Z. But here comes the challenge; I need to draw rounded corners with a radius of e.g. 10 pixels. By corners I mean the points in the line that aren't start or end points. In this case there are two corners at (0,100) and (100,0) . I've played around with

How to make my game engine faster (GDI+, C#)

廉价感情. 提交于 2019-12-20 02:38:10
问题 I'm currently building a 2D Game Engine in C#, using GDI. I do know that there are better alternatives to GDI but I'm also so deep into the project I can't turn back now. So, I currently have a graphics engine, that renders a portion of a bitmap, depending on what my cameras position and windows size is, which has given me a great performance boost. Great! However, I've noticed that if I place a bunch of game objects, in the same position, I get the same frame rate compared to if I placed the

Saving An image,A generic error occurred in GDI+

荒凉一梦 提交于 2019-12-20 01:38:41
问题 i get an A generic error occurred in GDI+ exception when I call img.Save(path, jpegCodec, encoderParams); here is all of the code : private Image img; private void button1_Click(object sender, EventArgs e) { this.img = Image.FromFile(@"path"); pictureBox1.Image = img; if (img.Height < pictureBox1.Height && img.Width < pictureBox1.Width) { this.pictureBox1.SizeMode = PictureBoxSizeMode.CenterImage; } Graphics g = Graphics.FromImage(img); Font font=new Font("Arial",16); SolidBrush brush = new