system.drawing

What is the difference between System.Drawing.Point and System.Drawing.PointF

What is the difference between System.Drawing.Point and System.Drawing.PointF. Can you give an example between this two. Thanks in advance. ...

How to convert a System.Drawing.Drawing2D.LinearGradientBrush to a System.Windows.Media.LinearGradientBrush ?

I trying to port System.Drawing: public LinearGradientBrush( Rectangle rect, Color color1, Color color2, float angle ) to System.Windows.Media . I can get the angle to be correct but I can't get the start and end to be at the corners. I have tried scaling the brush's transform but that ends up messing the angle. Syste...

System.Drawing.Image.FromFile does not close the file stream

If i create an image with this method and then try to delete/modify the image file I get an error because there is a stream still using the file. How can I delete or dispose of this stream so that I can work on the file? ...

Drawing within C# within a Picturebox

Hi, I want to be able to allow users of my program to click on a button, for example, a button for freehand rectangles to be drawn onto a picturebox. I need code for allowing me to first draw on the picturebox, and secondly for all the shapes that can possibly be drawn free hand in c#, e.g. line, ellipse, freehand drawing, text. Thanks...

Why is DarkGray lighter than Gray?

Simple curiosity here, tinged with some practical concerns because I get caught out by this occasionally. How come Color.DarkGray is lighter than Color.Gray? ...

MSChart Unhandled Overflow exception after zooming

This Question has been languishing un-answered on the MSChart forum for over a year. I'm continually getting an overflow exception on a chart. I'm setting up my chart as follows: InstrChart.Legends.Clear(); dataArea = InstrChart.ChartAreas.Add("Instr1"); dataArea.AxisX.MajorGrid.Enabled = false; dataArea.AxisY.MajorGrid.Enabled = fa...

VB.NET DrawRectangle For A Table

I want to draw a table in my print output using the System.Drawing.Printing's Graphics object. I'm trying to use the DrawRectangle to draw my table cells. This requires drawing several rectangles in a row. It should be pretty easy, right? Well it appears that DrawRectangle four parameters are x, y, width, and height. However x and y are...

open multi image pages to different Bitmap objects in .net

I am developing an image editor and the structure needs a different Bitmap object for each page. But in .net i couldnt find a fine way. When i use Bitmap.Clone() it gives the same bitmap (not only one page) The code below works fine but its dirty and slow. So what would be the best way of opening a multi-image to separate Bitmap objec...

How to draw text onto a jpg and resave it using system.drawing in c#

Anyone have good example of how to write text onto a jpg image and resave it using System.Drawing in .NET? ...

How to draw centered text onto a jpg using system.drawing in c#

I am using the following code to draw text onto a jpg image but it requires x/y coordinate percision on where to place the text. var bmp = new Bitmap("C:\\testing\\Given.jpg"); var gra = Graphics.FromImage(bmp); var text = "The Berman's"; var font = new Font("Segoe Script", 24); var brush = Brushes.Orange; var point = new PointF(130, 2...

How to manage custom fonts in web application (system.drawing)

I have an application that writes text onto images using system.drawing (C#). I am using specific fonts to do this. Since I can't rely on my shared hosting servers to have all the custom fonts I may need (and since the list of fonts is likely to grow), how can I manage the fonts used for my application? Could I include .ttf files in m...

How to serve up image from type System.Drawing.Bitmap (<img> tag?)

I am sending a bitmap to a View in ASP.NET MVC. I have a property in my ViewModel: public Bitmap TemplateImage { get; set; } In my View, I want to be able to render that Bitmap image but I can't figure out how to do it. ...

please help me with image.GetThumbnailImage (it create very low quality image)

i use this code to create thumbnails System.Drawing.Image.GetThumbnailImageAbort abort = new System.Drawing.Image.GetThumbnailImageAbort(this.ThumbnailCallback); System.Drawing.Image image2 = image.GetThumbnailImage((int)Math.Round((double)wid / difference), (int)Math.Round((double)hei / difference), abort, IntPtr.Zero); image2.Save(str...

System.Drawing.Pen - CompoundArray problem

Hello. Im trying to draw objects (in this case lines) that have same geometry. Since they would appear on top of each other i have found that using CompoundArray property i can visualize the offset as desired. The code is just a test code, so if some one wants to have a look let me know. Can some1 explain why im getting this weird glitc...

Sizing image to text in the image with C# System.Drawing / Drawstring

I want to take a string, and a specified font, and create a graphic image that contains that text in box, where the box resizes to the text. I got the code below working, but it sizes the box before doing anything else. Is there some way to resize the image to fit the text (I probably need to add a small border of a few pixels). A...

save jpg with lower bit depth (24 to 16 for instance) (C#)

Hello, I need to convert 24- and 32-bits jpeg and png-files to a lower bit depth (16). I found some code to do this, but the resulting images keep the bit depth of the original file although there file size is lower. Image img = Image.FromFile(filePathOriginal); Bitmap bmp = ConvertTo16bpp(img); EncoderParameters parameters = new Enc...