system.drawing

Does System.Windows.Media.Imaging use DirectX (like WPF) or GDI+?

First I used SSRS to render a TIFF document and found out although it is possible to pass colour depth parameter to SSRS 2005 or 2008, it discards it and always generates a 24bpp file. Without luck, got this 24bpp file generated by SSRS render method, loaded it on a System.Drawing.Bitmap object and successfully scaled it to 1728 pixels b...

Graphics object to image file

I would like to crop and resize my image. Here is my code: Image image = Image.FromFile(AppDomain.CurrentDomain.BaseDirectory + "Cropper/tests/castle.jpg"); // Crop and resize the image. Rectangle destination = new Rectangle(0, 0, 200, 120); Graphics graphic = Graphics.FromImage(image); graphic.DrawImage(image, dest...

PrintDocument Spooling to Printer is way to large

When i am trying to print an image to a printer for a 700kb file it is sending 120MB of data over to the printer. I can see this because I see the printer spooling 120MB. why would this happend? Here is the code for the PrintDocument.PrintPage private void PrintPage(object sender, PrintPageEventArgs ev) { sw.WriteLine("...

Drawing a contrasted string on an image

Hey, So, I have a snapshot of a video source, which I get into an Image, grab a Graphics object for it, and then draw a timestamp in the bottom right of the image. No problem thus far. However, I cannot guarantee what colour is going to be behind the text, so no matter what brush I use, it will almost certainly clash with some of the ...

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

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.) ...

C#: Drawing a timestamp onto an image

Hi! I was just browsing some questions when I stumbled upon this one. I am not experienced in System.Drawing, so I'm just wondering, how would you draw a timestamp onto an image? Also, as I'm very interested in System.Drawing, what are the best resources for learning how to use it well, and its application in various situations? Thank yo...

System.Drawing.Matrix, I understand what it does, but how does it work?

I've used the Matrix class a thousand times. I have an elementary grasp of matrix mathematics, it's been years since I've had a class on the subject. But I don't fully understand what this class is doing under the hood to manipulate the points in a GraphicsPath. What, specifically, is it doing in there as it pertains to GraphicsPaths i...

Simple graphics in C# with default System.Drawing

Hello all, I would like to develop a simple point&click game in C# with the default drawing libraries...no openGL/SDL/Tao for this project. Suffice to say, I am curious as to the best ways to draw clickable images in layers on a form. Ideally, I would have 1) Environment layer (pathways, doors, etc) 2) Object layer (items) 3) Char...

Edit multipage TIFF image using System.Drawing

I'mt tring to edit multipage tiff by creating Graphics from the image, but i encountered the error message: “A Graphics object cannot be created from an image that has an indexed pixel format.” How can i edit multipage tiff? ...

disposing of brushes

I am having a few memory problems with my long running application and I have been inspecting the paint methods to insure that brushes were properly disposed. In the case where the Brush is created in the argument to the functio will the brush be disposed of? such as the case below g.DrawString(valueText, Font, new SolidBrush(Colo...

How can I prevent the Print Progress dialog appearing when performing a print preview

In my C# application, I'm attempting to generate a print preview without the progress dialog appearing on screen. I believe you can use PrintDocument.PrintController to prevent this when printing for real (i.e. not a print preview), however it doesn't seem to work when performing a print preview. My code is as follows: public FrmDeliv...

C# Draw Quadratic Curve

How can I draw Quadratic Curve through 3 points by using C# System.Drawing namespace? ...

"Colourizing" a Bitmap in .NET

If you have a System.Drawing.Bitmap instance that contains a greyscale image, is there a built in way to "colourize" it with the influence of another colour? For example, if you had a black and white (greyscale) picture of a coffee mug and you wanted to create separate images of red, green and purple versions programmatically. ...

Drawing vertically stacked text in WinForms

Preferably using a Graphics object, how do you draw a string so that the characters are still oriented normally, but are stacked vertically? Hopefully this rough picture conveys what I mean: ...

Alternatives to System.Drawing for use with ASP.NET?

After several days of tracking down bizarre GDI+ errors, I've stumbled across this little gem on MSDN: 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 diminishe...

Changing System.Drawing.Bitmap.Palette

I have a TIFF file in memory, which I obtained by a variant of the following code: Image myImage = Image.FromFile("somefile.tiff"); Currently, myImage.Palette only returns two colors, black and white. I would like to expand this to include the entire color spectrum. However, myImage.Palette does not have a function to add additional ...

how drag a shape in picture box ?

hi friends, I have a project that in those i draw some shape from some layer. For example I have two circle in circle Layer and three rectangle in rectangle Layer and so on.I draw the result with call Layer.Draw and marge the layers result with a Graphics object. I can select one shape in picture box and specify it on layer. and i can d...

Image drawn on panel does not cover the whole panel (c# - winforms)

I'm drawing images on panel controls. Changing zoom factor changes the size of panel control (which should stretch the image accordingly). With zoom factors greater then 1 (ie, 2,4,8) a small part of panel begins to show (testing shows that it is the background color of the panel) and grows along with the zoom factor. Panel control bor...

C# Console App System.Drawing Background Transparency Question

Hi All, Should be a quick and easy question. Does System.Drawing.Graphics.DrawImage() or Image.Save() by default make an image background transparent? I had to use System.Drawing.Bitmap to adjust image resolutions and now all of the converted images have a transparent background. Futher details: We are using ImageMagick to do the bas...

Behaviour of .NET's System.Drawing.Pen with fractional Width

I've been seeing some odd behaviour with fractional pen widths, and I wonder if anyone can explain what's going on. Drawing a rectangle on a form in response to a Paint event: private void Form1_Paint(object sender, PaintEventArgs e) { const float width = 1.996093F; Rectangle rectangle = new Rectangle(10, 10, 20, 20); using (Pen ...