system.drawing

Get a Bitmap from a WPF application window?

The Winforms System.Windows.Forms.Control class has an instance method "DrawToBitmap" which I think is very useful in a variety of circumstances. I'm wondering if there's an equivalent way of getting a System.Drawing.Bitmap from a WPF application? I realize I could do some P/Invoke stuff to just get the application window, however I ...

Smallcaps / multiple fonts and bolding using 'DrawString' in GDI+

I want to write out some text using smallcaps in combination with different fonts for different words. To clarify I might want the message 'Welcome to our New Website' which is generated into a PNG file for the header of a page. The text will be smallcaps - everything is capitalized but the 'W', 'N' and 'W' are slightly larger. The 'N...

Path to Triangle List (.NET/C#)

Given a path expressed as an array of 2d points: Point[] path = new Point[4] { new Point(0,0), new Point(10,0), new Point(10,10), new Point(0,10), }; ... Here, a box. What is the best way to convert this to a list of triangles (which fill the path) to be used in a 3D application? Given that this is only a simple examp...

Question regarding images and winforms

I am creating a Kiosk application. I have it full screen and I am drawing directly on the form: Private Function CreateHeader(ByVal headerText As String) As Boolean Try Dim oGFX As Graphics = Graphics.FromHwnd(hwnd:=_oP.Handle) Dim oRect As Rectangle = New Rectangle(x:=0, y:=0, Width:=_screenSize.X, Height:=150) ...

Convert a 24 bit in memory image to indexed color

I have an image that I have created in memory as Format24bppRgb. I save this as a PNG and it is 24kb. If I save the same image with photoshop as a 24bit PNG it comes to about the same size, but if i save it as an 8bit PNG with only 32 colors it goes down to 5kb. How can I create an indexed version of a PNG file using C# / GDI+ / Syste...

How to disable subsampling with .NET / GDI+ ?

I am trying to save a JPEG image using the Bitmap class. I noticed that sharp edges were always blury regardless of the quality level that I specify. I figured out that it is due to subsampling of one or more of the channels. How do I disable subsampling when saving the image? I am currently using this code: EncoderParameters parameter...

Reliable .wmf/wmf to Pixel based image conversion

Good afternoon, I am having a little trouble with .net's internal (System.Drawing) based MetaFile / Image handling of .wmf files that containt transparent areas. Basically whenever I do a MetaFile.LoadFile(...) and take that to save it as a tiff/png etc, some areas of that source files are missing. I can't really pin it down, but it -se...

Why are JPEG images created with System.Drawing larger than original Bitmaps?

I'm having a strange problem - I have about 14.5 million bitmap images, that are supposedly uncompressed. I need to convert these bitmaps to JPG and store them in a database. When I use the classes provided in the .NET System.Drawing library to save the bitmap as a ImageFormat.Jpeg, the resulting JPEG is about twice the size of the ori...

System.Drawing.Imaging.ColorMap equivalent on .NET Compact Framework

I have a need to use a ColorMap object in .NET Compact Framework but from what I can tell it is not available. Need some ideas on how to best workaround this limitation. ...

How to create Bitmap from System.Window.media.PixelFormats.Gray16

Hi, I am successfully drawn images from their raw pixel data.(only 8 bit images). here is the code for doing the same thing. PixelFormat format = PixelFormat.Format8bppIndexed; Bitmap bmp = new Bitmap(Img_Width, Img_Height, format); Rectangle rect = new Rectangle(0, 0, Img_Width, Img_Height); BitmapData bmpData = bm...

Create a thumbnail and then convert to byte array

I'm having a heck of a time with creating thumbnails and then converting them into a byte array. I've tried three methods, and all 3 times I get an error. The first was using Bitmap.GetThumbnailImage, which I have used in the past and then saved directly into Response.OutputStream The second was using System.Drawing.Graphics with Draw...

C# Displaying a image in a form that is non-blocking to the rest of my code

Hi, I know this is a rather broad question, but have a class that has a method to display an image and would like to use that method in a different piece of code to open up the image, but not have that method call be blocking. So if I had the following snippet somewhere in a piece of code: ImageClass MyImage = new ImageClass(); MyImag...

(C#) How to draw an "a" with Tahoma with height = 6

Hello I've been trying to do this, but for some reason this is just giving me weird results: int bpp = Screen.PrimaryScreen.BitsPerPixel; string fontName = "Tahoma"; Font font = new Font(fontName, 10 * bpp, GraphicsUnit.Point); Bitmap bm = new Bitmap(20 * bpp, 20 * bpp); Graphics g = Graphics.FromImage(bm); TextRenderer.DrawText(g, "a"...

Make +y UP, Move Origin C# System.Drawing.Graphics

I want the origin to be at the center of my window. ______________ | ^ | | | | | o----->| | | |____________| .NET wants it to be in the top left hand corner. _____________> | | | | | | | | V____________| Dot net and I are trying to get along.. Does an...

help me convert Processing code to C#

I am trying to convert this code from java to C# (located here) I have some winform experience but not a lot with the drawing of pixels on a winform applications. I feel fairly confident I can convert over most of the sub methods im just unclear on how i would draw indiviual pixels on the screen any help or tools for converting over j...

How do I use the GDI+ blur effect on a .NET Bitmap?

I need to apply a blur to a System.Drawing.Bitmap. The classes in System.Drawing are supposed to be wrappers around GDI+, so I'd I use the GDI+ Blur effect. Is this possible, and if so, how? Edit: I don't want to know how to write my own Blur effect, I want to know how to use the built-in GDI+ one. ...

How do I draw a drop shadow in the shape of a System.Drawing.Bitmap?

Our app has a very large number of System.Drawing.Bitmaps that are to be displayed with drop shadows. What's a quick way of drawing drop shadows, with a given blur radius and colour? It's a winforms app, no WPF. p/invoke preferred to unsafe code, but ideally neither; third-party libraries not allowed. I've seen the 'Image Processing ...

How to determine the disabled color for a given color in winforms?

Windows forms has the handy ControlPaint.DrawImageDisabled to paint a color image in a grayed-out, disabled state. Is there a way to determine, for a given color, what the disabled color would be (as if it were drawn by DrawImageDisabled)? ...

Drawing a line in Winforms

Hi, I am having trouble drawing a line within a group box in a simple windows form. here is my code: ==================================================================================== public partial class Form1 : Form { public Form1() { InitializeComponent(); } ...

System.Drawing Error: Can or Cannot it be used in an ASP.Net application

We are using System.Drawing in and application to manipulate images in a web application (rotate, flip, etc). For the last month we have been getting the following error very sporadically. "Attempted to read or write protected memory. This is often an indication that other memory is corrupt." Based on the MSDN Library it appears that ...