system.drawing

System.Drawing.Graphics Transform() methods: use for zoom, pan?

I'm building a very simple vector graphics application using GDI+. Obviously I don't want the default measurement unit to be the pixel, so right now I'm using a complicated system that involves a variable called the "scale factor" and a point called the "offset". Every time I want to draw anything, I have to multiply by the scale factor ...

Graphic autoscaling

Hi all, I have the following codes to draw an unit circle open System open Microsoft.FSharp.Collections open Microsoft.FSharp.Math open System.Drawing open System.Windows.Forms let make_point (x:float) (y:float) = (fun bit -> if bit = 0.0 then x else y) let x_of (point:float->float) = point 0.0 let y_of (point:float->float) = point 1....

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 System.Drawing namespace? Is there any other reason? ...

Avoiding disposing system-defined Pen and Brush instances

I understand it is best practise to call Dispose() on instances of Pen and Brush, except if they've been set to the system-predefined values (eg. System.Drawing.Brushes, System.Drawing.Pens or System.Drawing.SystemBrushes) Trying to dispose a system-defined resource results in an exception being thrown. It doesn't appear to be obvious...

How to Create Subset Fonts in .NET?

I have a Silverlight application that I need to embed some less-than-common fonts in. It's simple enough for me to just copy over the TTF/OTF and compile that with my app. However, in many cases, only like 5-10 of the characters are actually used. In other cases, some font files are incredibly large (Arial Unicode MS Regular is 22.1 MB, ...

What is the best way to adjust Contrast level on an Image as found in Photoshop

Do you think the following one is best for adjusting Contrast level? In fact, I would like to get the same/close perfromance for adjusting contrast as found in Photoshop. public static Bitmap AdjustContrast(Bitmap Image, float Value) { Value = (100.0f + Value) / 100.0f; Value *= Value; System.Drawing.Bitmap NewBitmap = Image...

.NET Tiff Issues C#

I'm having issues with TIFFs Here is what I have to do, we have tiff images saved into the database, these images are CCITT4 compressed with a number of required tags, these include: RowsPerStrip must be the ImageLength Photometric Interpreation must be MinIsWhite Multi-strip image format is not allowed My problem is, I'm using the ...

Write metadata to PNG image in .NET

I see more than a few questions asking how to read metadata from an image, but I haven't seen as many asking how to write metadata. Basically, I need to add one item of metadata ("ImageDescription") to a PNG image I'm generating dynamically (creating a Bitmap object and procedurally generating all the content in it). What would be the ...

Loading a file to a Bitmap but leaving the original file intact.

How to do this in C#? If I use Bitmap.FromFile(), the original file is locked. If I use Bitmap.FromStream(), the original file is not locked, but the documentation says "You must keep the stream open for the lifetime of the Image." This probably means that the file is still linked to the image object, (for example, perhaps if the file ...

NotImplementedException from .NET's CustomLineCap constructor

Hi. I want to draw a custom line cap - a equilateral triangle with the radius r. Apparently I can't: Dim triangleSide As Single = CSng(3 * r / Math.Sqrt(3)) Dim triangleHeight As Single = CSng(3 * r / 2) path = New GraphicsPath() Dim points() As PointF = New PointF() { _ New PointF(-triangleSide / 2, 0), _ New Po...

C# Scroll text using DrawString

Hey, I'm quite new to C# so excuse me if this is a stupid question. I would like to scroll some text from the bottom of the screen to the top of the screen line-by-line. What is the easiest way to achieve this? Cheers, Pete ...

spring like drawing in c#

How to draw the spring like shape using c# drawing class ...

Repeating the image in horizontal position ( C# Drawing )

am using c# am having a bitmap image like below i want create a repeated image like below in horizontal position to get repeted continous image for some given width. i meant i like to draw repeated image like below from the above single bitmap (In simple words,in html we can have a image and set repeat X to get the repeated image.li...

GraphicsExtension for Drawing?

Is there for System.Drawing an equalivant of GraphicsExtension? ...

.net DrawString / StringFormat problem

Hi, I'm developing a .net 3.5 Win Forms program and I've run into an "interesting" problem with text drawing. I'm implementing a text editing control and it draws text with DrawString() and StringFormat.GenericTypographic (henceforth, GT). As the user types, whole words (or groups of words) earlier in the line are moving subtly left an...

"Parameter is not valid" exception from System.Drawing.Image.FromStream() method

Hi I got a hard time with the Image.FromStream method in my website. The code below works perfect on my computer. But when I uploaded it to the test server, it always gives me "Parameter not valid" exception. if (!afuImageFile.IsUploading && afuImageFile.HasFile) { System.Drawing.Image imgFile = System.Drawing.Image.FromStream(afuI...

How can I tell if two polygons intersect?

Hello, Imagine I have the coordinate of 4 points that form a polygon. These points are represented using PointF in C#. If I have 2 polygons (using 8 points), how can I tell if they intersect? Rectangle class has a method called IntersectsWith but I couldn't find something similar for GraphicsPath or Region. Any advice would be grea...

How to loop through points in a system.drawing.rectangle in vb.net

Looking for something like: dim rect as system.drawing.rectangle For each point in rect Debug.print(point.name, point.value) Next ...

File.Delete failing when Image.FromFile was called prior it, despite making copy of loaded image and destroying original one

UPDATED I used below solutions (loading Image from stream), but get new problem. img object is absolutely correct Image class instance with all field filled with correct values. But calling img.Save("path/to/new/image.bmp"); on it results in new exception for GDI+ (System.Runtime.InteropServices.ExternalException, in GDI+ interface) ...

Where does a user-control go when the visibility of it is set to false?

Curiosity is kicking out again. I've been using the user control .Visible and .Hide() method for a long time. So where does a user-control go when the visibility of it is set to false? ...