system.drawing

.NET Point.IsEmpty vs IsDefined

我的梦境 提交于 2019-12-23 19:43:11
问题 In my UI class, a developer has the option to define a location property (type of System.Drawing.Point). By default this property is initialized to Point.Empty. The internal code that is encapsulated by the class uses the .IsEmpty of the Point property to determine if a location has been set. If the property is not empty, the x/y value will be used. If empty, the code will attempt to place it with a row/column algorythm. My Issue: I am using the .IsEmpty of the property to determine if it was

Server-side graphics in ASP.NET Core

空扰寡人 提交于 2019-12-23 15:16:25
问题 I've recently upgraded an ASP.NET MVC application from ASP.NET to ASP.NET Core. In my controller action, I had a piece of code that relied on System.Drawing to create a profile picture using (FileStream stream = new FileStream(HttpContext.Server.MapPath($"~/Content/UserFiles/{AuthenticatedUser.Id.ToString()}.jpg"), FileMode.OpenOrCreate)) { Image image = Image.FromStream(model.DisplayPicture.InputStream); image.Save(stream, System.Drawing.Imaging.ImageFormat.Jpeg); } The image data is posted

Resolve 'Out of memory' exception when calling DrawImage

旧城冷巷雨未停 提交于 2019-12-23 08:51:40
问题 About one percent of our users experience sudden crash while using our application. The logs show below exception, the only thing in common that I've seen so far is that, they all have XP SP3. Thanks in advance Out of memory. at System.Drawing.Graphics.CheckErrorStatus(Int32 status) at System.Drawing.Graphics.DrawImage(Image image, Rectangle destRect, Int32 srcX, Int32 srcY, Int32 srcWidth, Int32 srcHeight, GraphicsUnit srcUnit, ImageAttributes imageAttrs, DrawImageAbort callback, IntPtr

C# Get text from a textbox that is made at runtime

人盡茶涼 提交于 2019-12-23 05:05:29
问题 Hello I am making a program that has 2 textboxes and 2 buttons When I press the add button then it will make 2 new textboxes using this code : private void ADD_ROW_Click(object sender, EventArgs e) { //Make the NEW_TEXTBOX_1 HOW_FAR += 1; TextBox NEW_TEXTBOX_1 = new TextBox(); NEW_TEXTBOX_1.Name = "NAME_TEXTBOX_" + HOW_FAR.ToString(); //Set NEW_TEXTBOX_1 font NEW_TEXTBOX_1.Font = new Font("Segoe Print", 9); NEW_TEXTBOX_1.Font = new Font(NEW_TEXTBOX_1.Font, FontStyle.Bold); //Set pos and size

How to query the bit depth of a PNG?

梦想的初衷 提交于 2019-12-22 23:42:29
问题 I have a PNG file which has 8-bit color depth as evidenced by file properties: Yes, when I open the file var filePath = "00050-w600.png"; var bitmap = new Bitmap(filePath); Console.WriteLine(bitmap.PixelFormat); I get Format32bppArgb . I also looked in the PropertyIdList and PropertyItems properties but didn't see anything obvious. So how do I extract the Bit Depth from the PNG? P.S. None of the framework methods seem to work. System.Windows.Media.Imaging.BitmapSource might work but it's only

GDI Antialiasing not working well on Server 2008

谁说我不能喝 提交于 2019-12-22 17:46:13
问题 I'm using System.Drawing to generate some images on the fly that include a base image plus some stretched / scaled text. Everything is nice and neat on my LOCALHOST environment, but when I publish to my server (Server 2008), I lose some of the antialiasing and the image quality gets grainy. Here is an example copied from my local environment (Windows 7), and then from my server (Server 2008) Windows 7: Windows 2008: As you can see, the images are the same size, and the fonts are scaled the

GDI Antialiasing not working well on Server 2008

给你一囗甜甜゛ 提交于 2019-12-22 17:46:10
问题 I'm using System.Drawing to generate some images on the fly that include a base image plus some stretched / scaled text. Everything is nice and neat on my LOCALHOST environment, but when I publish to my server (Server 2008), I lose some of the antialiasing and the image quality gets grainy. Here is an example copied from my local environment (Windows 7), and then from my server (Server 2008) Windows 7: Windows 2008: As you can see, the images are the same size, and the fonts are scaled the

Three System.Drawing methods manifest slow drawing or flickery: Solutions? or Other Options?

坚强是说给别人听的谎言 提交于 2019-12-22 11:25:03
问题 I am doing a little graphing via the System.Drawing and im having a few problems. I'm holding data in a Queue and i'm drawing(graphing) out that data onto three picture boxes this method fills the picture box then scrolls the graph across. so not to draw on top of the previous drawings (and graduly looking messier) i found 2 solutions to draw the graph. Call plot.Clear(BACKGOUNDCOLOR) before the draw loop [block commented] although this causes a flicker to appear from the time it takes to do

System.Drawing.Icon constructor throwing “Operation completed successfully” exception

。_饼干妹妹 提交于 2019-12-22 06:31:54
问题 On a Windows XP machine, the following code is throwing a System.ComponentModel.Win32Exception with the message "The operation completed successfully" System.Drawing.Icon icon = new System.Drawing.Icon("icon.ico"); I can stop the program crashing with try { System.Drawing.Icon icon = new System.Drawing.Icon("icon.ico"); } catch(System.ComponentModel.Win32Exception ex) { if (ex.NativeErrorCode != 0) { throw; } } but of course the icon is not set. The full stack trace is at System.Drawing.Icon

Creating Visio look-a-like diagrams programmatically [closed]

南楼画角 提交于 2019-12-21 20:25:19
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed last month . I need to programmatically create Visio look-a-like diagrams as a drawing. Mostly we are going to create network layout diagrams similar to this one. Is there a component that could speed-up the development or some technique we could use? Generally we could do this on our own via System.Drawing, but this might