Questions tagged [system.drawing.imaging]

80 questions
36
votes
3 answers

What quality level does Image.Save() use for jpeg files?

I just got a real surprise when I loaded a jpg file and turned around and saved it with a quality of 100 and the size was almost 4x the original. To further investigate I open and saved without explicitly setting the quality and the file size was…
scubasteve
  • 2,718
  • 4
  • 38
  • 49
35
votes
8 answers

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…
Dylan Beattie
  • 53,688
  • 35
  • 128
  • 197
22
votes
1 answer

Why does EnumerateMetafile only work with Aero enabled

My code enumerates a metafile: private void Parse() { Graphics graphics = Graphics.FromHwnd(IntPtr.Zero); PointF pointf = new PointF(); graphics.EnumerateMetafile(_metafile, pointf, ParseCallback); } private bool…
bovender
  • 1,838
  • 15
  • 31
18
votes
5 answers

get extension from System.Drawing.Imaging.ImageFormat (C#)

Is it possible to get the extension, for any given System.Drawing.Imaging.ImageFormat? (C#) Example: System.Drawing.Imaging.ImageFormat.Tiff -> .tif System.Drawing.Imaging.ImageFormat.Jpeg -> .jpg ... This can easily be done as a lookup table, but…
Karl Cassar
  • 6,043
  • 10
  • 47
  • 84
15
votes
7 answers

Determine if Alpha Channel is Used in an Image

As I'm bringing in images into my program, I want to determine if: they have an alpha-channel if that alpha-channel is used #1 is simple enough with using Image.IsAlphaPixelFormat. For #2 though, other than looping through every single pixel, is…
Todd Main
  • 28,951
  • 11
  • 82
  • 146
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
12
votes
2 answers

Difference between Quality and Compression with system.drawing.imaging?

I'm completely new to image processing in ASP.NET. I am very familiar with Photoshop, and image magick to some degree. I am trying to figure out what the difference is between Quality and Compression as other apps tend to treat them as the same.…
8
votes
1 answer

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…
Brian David Berman
  • 7,514
  • 26
  • 77
  • 144
5
votes
1 answer

Set software name in image metadata while saving in C#

While trying to save an image with my software name set in metadata I get exception "The designated BitmapEncoder does not support global metadata." How can I achieve this? using (Stream stream = File.Create(@"D:\Yourfile.png")) { …
AmaltasCoder
  • 1,123
  • 3
  • 17
  • 35
4
votes
0 answers

System.Drawing.Imaging BitmapData color components order

From the docs: ...The format also defines the order of the color components within a single pixel of data. Where is the order documented? I know that, for example,locking the bitmap with format 24bppRgb gives me a region in memory filled with…
4
votes
2 answers

System.Drawing.Image EntityType 'Image' has no key defined. Define the key for this EntityType

I'm using EF Code First and Data Scaffolding and have an entity that contains a property of type public System.Drawing.Image Image { get; set; } When initialsing the DB context to create the DB i get the following…
4
votes
1 answer

Any good source of explanatory documentation on ColorMatrix?

I'd like to try using ColorMatrix, but am only able to find examples that convert an image to grayscale. And even then, they tend to be presented as a chunk of 'magic numbers' code with no explanation. Does anyone know of a 'tutorial' on how to use…
mackenir
  • 10,801
  • 16
  • 68
  • 100
4
votes
3 answers

Converting a GUID to System.Drawing.Imaging.ImageFormat

I store information about images in a database - also their ImageFormat (jpeg, png etc). Console.WriteLine(System.Drawing.Imaging.ImageFormat.Jpeg.Guid); Outputs: b96b3cae-0728-11d3-9d7b-0000f81ef32e I want to store this in the database as a…
Kjensen
  • 12,447
  • 36
  • 109
  • 171
4
votes
3 answers

System.Drawing.Bitmap GetBounds GraphicsUnit.Inch

Can anybody tell me how to get a rectangle back from GetBounds in any units OTHER than pixels? The following code - lifted directly off the MSDN documentation for this function - returns a rectangle that is pretty obviously in pixels rather than…
B H
  • 1,730
  • 18
  • 24
3
votes
1 answer

Grey borders in DrawImage (.NET system.drawing.drawing2D)

I'm trying to create an image on a bitmap using C#. Somehow it always adds grey border on all sides of the image. Many questions have been posted with the solution and I have tried almost all of them but none of them worked. Code that I'm…
Salman
  • 1,266
  • 5
  • 21
  • 41
1
2 3 4 5 6