system.drawing

How to display a PictureBox from behind code in C#

 ̄綄美尐妖づ 提交于 2019-12-21 17:38:06
问题 I know my question sounds basic, but i searched all over the place and found nothing.. this is my code : public MainWindow() { InitializeComponent(); Map newMap = new Map(); newMap.setMapStrategy(new SmallMapStrategy()); newMap.createMap(); System.Windows.Forms.PictureBox pictureBox1 = new System.Windows.Forms.PictureBox(); pictureBox1.Paint += new System.Windows.Forms.PaintEventHandler(newMap.grid[3].afficher); } this is the afficher function : public override void afficher(object sender,

C# WinForms: Drawing with one or more additional threads. How?

青春壹個敷衍的年華 提交于 2019-12-21 12:28:46
问题 In case I have a big drawing with all kinds of geometric forms (lines, rectangles, circles, e.t.c.) it takes a lot of time for the thread to draw everything. But in real life, one building is built by more than one workers. So if the drawing is the building and the threads are the builders, it will get drawn a lot faster. But I want to know how. Can you tell me how? Is it even possible (though I have already asked and the answer was "Yes")? Is it worth it to be used? What are the risks? If

how can I convert System.Drawing.Icon to System.Drawing.Image?

痞子三分冷 提交于 2019-12-20 11:48:07
问题 I'm getting icon from another application using this: Icon IEIcon = Icon.ExtractAssociatedIcon(@"C:\Program Files\Internet Explorer\iexplore.exe"); how to convert it to System.Drawing.Image? 回答1: Description The Bitmap is derived from Image so you can use Icon's .ToBitmap() method. Sample Icon IEIcon = Icon.ExtractAssociatedIcon(@"C:\Program Files\Internet Explorer\iexplore.exe"); Image im = IEIcon.ToBitmap(); More Information MSDN - Bitmap Class MSDN - Image Class 回答2: Could you use the

Drawing text on image

可紊 提交于 2019-12-19 19:56:41
问题 I have never worked with drawing before and im having a little issue. I cant seem to get the output of this code to work. The file is saving but it is not drawing on the text. Can anyone see what i may have done wrong? EDIT: A silly mistake - the backgrond of the image was white (and the brush colour was!). The text is not centered however as i would have expected. Any ideas why SO? :) EDIT: Image is below. Thanks Bitmap myBitmap = new Bitmap(@"C:\Users\Scott\desktop\blank.bmp"); Graphics g =

how to clear the graphics(rectangle shape) in picturebox

别说谁变了你拦得住时间么 提交于 2019-12-19 09:24:19
问题 i created rectangle shape user control and i am using this user control in my application.In my application i am processing a image for different operations such as reading barcode from images etc.Here i have two possibility of processing a image, one is processing entire image and another is processing selected part of the image,i am selecting the specific part of the image using rectangle shape(this is user-control).so i have given two option in my GUI for this purpose one is Entire image

Create a thumbnail and then convert to byte array

谁都会走 提交于 2019-12-19 06:37:30
问题 I'm having a heck of a time with creating thumbnails and then converting them into a byte array. I've tried three methods, and all 3 times I get an error. The first was using Bitmap.GetThumbnailImage, which I have used in the past and then saved directly into Response.OutputStream The second was using System.Drawing.Graphics with DrawImage(). Still no go. The third was just to create a new bitmap, pass in the old bitmap, and set the new size. Same error. Value cannot be null. Parameter name:

How to know if a GraphicsPath contains a point in C#

泪湿孤枕 提交于 2019-12-19 05:54:33
问题 I'm using .NET to draw a diagram, and I want to highlight objects when the user performs a click on them. It is easy when a figure is fully contained in a rectangle: if (figure.Bounds.Contains(p)) // bounds is a rectangle But I don't know how to manage it if the figure is a complex GraphicsPath . I have defined the following GraphicsPath for the figure (the green circle). I want to highlight the figure when the user click on it. I would like to know if a Point is contained in that

Image Resize in C# - Algorith to determine resize dimensions (height and width)

痴心易碎 提交于 2019-12-18 12:16:13
问题 I need to scale down an image that has a height or width greater than a predefined pixel value. I wrote some code that takes a look at the original image, checks to see if either the width, the height, or the height and width are greater than the Max Width/Max Height settings. I now need to figure out what dimensions to resize to based on the max of the latter value. For example: If the image is 900h x 300w and the MAX Height is 700h I will need to resize the height to 700 and the width to ??

Possible to have anti-aliasing when drawing a clipped image?

荒凉一梦 提交于 2019-12-18 05:55:22
问题 Currently, I'm successfully using the Graphics class to draw a non-rectangular clipped image (the turtle inside): My code looks something like: using (var g = Graphics.FromImage(image)) { g.InterpolationMode = InterpolationMode.HighQualityBicubic; using (var gfxPath = new GraphicsPath()) { gfxPath.AddEllipse(r); using (var region = new Region(r)) { region.Exclude(gfxPath); g.ExcludeClip(region); g.DrawImage(turtleImage, r, r2, GraphicsUnit.Pixel); } } } This all works just as expected. What I

Convert System.Drawing.Color to System.Windows.Media.Color [duplicate]

我是研究僧i 提交于 2019-12-18 01:32:21
问题 This question already has answers here : How to convert from System.Drawing.Color to System.Windows.Media.Color? (3 answers) Closed 3 years ago . System.Drawing.Color drawRedColor = System.Drawing.Color.Red; System.Windows.Media.Color mediaColor = ?drawRedColor.ToMediaColor();? 回答1: How about: using MColor = System.Windows.Media.Color; using DColor = System.Drawing.Color; ... public static MColor ToMediaColor(this DColor color) { return MColor.FromArgb(color.A, color.R, color.G, color.B); }