Questions tagged [system.drawing]

System.Drawing is a namespace of the .NET framework. It provides access to GDI+ basic graphics functionality.

System.Drawing is a namespace of the .NET framework. It provides access to GDI+ basic graphics functionality.

Classes within the System.Drawing namespace are not supported for use within a Windows or ASP.NET service. Attempting to use these classes from within one of these application types may produce unexpected problems, such as diminished service performance and run-time exceptions. For a supported alternative, see Windows Imaging Components.

References

1129 questions
15
votes
1 answer

.NET: What does Graphics.DrawImageUnscaled do?

It is not well known, that if you draw an image, e.g.: graphics.DrawImage(image, top, left); the image will be scaled. This is because DrawImage looks at the dpi setting of the image (e.g. 72dpi from photoshop), and scales the image to match the…
Ian Boyd
  • 246,734
  • 253
  • 869
  • 1,219
15
votes
1 answer

How to access System.Drawing ie System.Drawing.Common in Asp.Net Core 3

I'm in the process of converting an Asp.Net Core 2.2 Website that targeted the Full Framework to an Asp.Net Core 3.1 App that targets .Net Core 3.1. I'm a bit unclear about dependencies related to System.Drawing and how to fulfill them. My project…
RonC
  • 31,330
  • 19
  • 94
  • 139
15
votes
4 answers

How to resize image after being uploaded in ASP.NET Core 2.0

I want to resize an image and save this image multiple times with different sizes into a folder. I have tried ImageResizer or CoreCompat.System.Drawing but these libraries not compatible with .Net core 2. I have searched a lot of about this but i…
Rana Mujahid
  • 236
  • 1
  • 2
  • 8
15
votes
4 answers

Set color through color code in c#

I am trying to add color in c# code, with the following color code for example. ListTreeView.Background = new SolidColorBrush(Colors.White); This is working..but I want to add this color as color code so I am add as System.Windows.Media Could…
Jitendra Jadav
  • 603
  • 3
  • 10
  • 20
15
votes
3 answers

How can I iterate through each pixel in a .gif image?

I need to step through a .gif image and determine the RGB value of each pixel, x and y coordinates. Can someone give me an overview of how I can accomplish this? (methodology, which namespaces to use, etc.)
NoCarrier
  • 2,558
  • 4
  • 33
  • 44
15
votes
2 answers

How to select an area on a PictureBox.Image with mouse in C#

i just wanted to put a selection on my picturebox.image but this has just become worse than some little annoying situation. I thought on another picture box over the main picturebox but it seemed so lazy work to me. I need to know if there is a way…
Berker Yüceer
  • 7,026
  • 18
  • 68
  • 102
14
votes
2 answers

.net2.0 vs .net 4.0 gdi+ difference?

I have a really weird problem where I have an application that does a lot of involved GDI+ manipulation of pictures. Such as cropping zooming etc. My application works fine in .net 2.0, but in .net 4.0 I am getting reports from my users that it is…
Bryan Wilkins
  • 169
  • 11
14
votes
4 answers

C# Drawstring Letter Spacing

Is is somehow possible to control letter spacing when using Graphics.DrawString? I cannot find any overload to DrawString or Font that would allow me to do so. g.DrawString("MyString", new Font("Courier", 44, GraphicsUnit.Pixel), …
beckelmw
  • 1,722
  • 2
  • 16
  • 23
13
votes
2 answers

Caching GDI+ objects in a winforms application: is it worth it and how to do it right?

For some of my winforms applications I need to create a whole bunch of GDI+ objects (brushes, pens, fonts, etc) and use them over and over again. I created a ghetto caching singleton to accomplish what I need, but the code smell is…
Jacobs Data Solutions
  • 4,850
  • 4
  • 33
  • 38
13
votes
4 answers

Bitmap class doesn't dispose stream?

So, after discovering that the Bitmap class expects the original stream to stay open for the life of the image or bitmap, I decided to find out if the Bitmap class actually closes the stream when it is disposed. Looking at the source code, the…
Lilith River
  • 16,204
  • 2
  • 44
  • 76
13
votes
1 answer

How to use the projection/camera technique in c#

I drew the following grid: The above grid is drawn using the following two methods, one to calculate the grid and the other to calculate the centers for each cell: //makes grid in picture box private void drawGrid(int numOfCells, int cellSize,…
Rose
  • 349
  • 3
  • 17
13
votes
8 answers

Get ImageFormat from System.Drawing.Image.RawFormat

This code fails when trying to call Image.Save(MemoryStream, ImageFormat). I get the exception: a Value cannot be null.Parameter name: encoder" ImageFormat format = generatedImage.RawFormat as ImageFormat; image.ImageData =…
Ben Foster
  • 34,340
  • 40
  • 176
  • 285
13
votes
1 answer

In the .NET framework, why are there PointF (float) and no "PointD" (double)?

Can anyone explain why, in the .NET framework, there are PointF structures (using the single-precision float type) and no "PointD" (using the double-precision double type)? Did they establish that such precision would never make sense in the…
Fueled
  • 8,776
  • 9
  • 29
  • 31
13
votes
4 answers

C# graphics flickering

I am working on kind of drawing program but I have a problem with flickering while moving a mouse cursor while drawing a rubberband line. I hope you can help me to remove that flickering of line, here is the code: using System; using…
Jeff
  • 725
  • 2
  • 7
  • 11
12
votes
5 answers

How to draw a subpixel line

In the following code, I'm trying to draw two lines: One with a subpixel width (0.5) and the other with 1px width: var img = new Bitmap(256, 256); Graphics graphics = Graphics.FromImage(img); graphics.SmoothingMode =…
FredL
  • 1,035
  • 9
  • 23
1 2
3
75 76