gdi+

Saving image: A generic error occurred in GDI+. (vb.net)

I need to save an image after opening it in from an OFD. This is my code atm: Dim ofd As New OpenFileDialog ofd.Multiselect = True ofd.ShowDialog() For Each File In ofd.FileNames Image.FromFile(File).Save("C:\Users\Jonathan\Desktop\e\tmp.png", Imaging.ImageFormat.png) Next And on the line Image.FromFile(File).Save("C:\Users\Jonat...

Multiple ordered translate / scale transforms in GDI+

I have a number of graphics objects which I am plotting in a graphics context in a windows forms application. There is some interaction with the ui element in which the paths are rendered which allows the user to pan, zoom and set an origin for the zoom point. The question I have is, is it possible to set up a sequence of transform opera...

Fast way to draw lines using different Color using GDI+?

I have an dynamic List of Point, new Point can be added at any time. I want to draw lines to connect them using different color. Color is based on the index of those points. Here is the code: private List<Point> _points; private static Pen pen1 = new Pen(Color.Red, 10); private static Pen pen2 = new Pen(Color.Yellow, 10); ...

How to clear screen area or Redraw screen in C#

hi, I am creating a User Control in C#.Net 2.0. I have to apply drag and Drop Images in between these controls. I have done drag and drop effect. But the problem is that i have to show the control movement while mouse dragging. For that i am drawing a rectangle on screen with the help of ControlDraw.DrawReversibleFrame() Problem is th...

How can you draw 32bppargb images with the Win32 AlphaBlend function?

I've been fussing with this for the better part of the night, so maybe one of you can give me a hand. I have found GDI+ DrawImage in C# to be far too slow for what I'm trying to render, and from the looks of forums, it's the same for other people as well. I decided I would try using AlphaBlend or BitBlt from the Win32 API to get better...

Windows forms: How to handle redrawing efficiently?

I have a form with a picturebox which displays a picture and some overlay drawn in the Paint event handler of the picturebox. The overlay updates itslef (basically changes opacity of different parts of the overlay) based on mouse movement. Currently, I am calling pictureBox.Invalidate() from mouse moved handler to ensure that the overla...

Win32: Does a window have the same HDC for its entire lifetime?

Am i allowed to use a DC outside of a paint cycle? Is my window's DC guaranteed to be valid forever? i'm trying to figure out how long my control's Device Context (DC) is valid. i know that i can call: GetDC(hWnd); to get the device context of my control's window, but is that allowed? When Windows sends me a WM_PAINT message, i am ...

XNA rendering on GDI HDC

I am integrating with an application that uses plugins. I have my own plugin that is provided an HDC to draw on, this works fine using C# Graphics gfx = Graphics.FromHdc(hdc); I can then draw using GDI without issue. I would like to start experimenting with XNA, I've loaded a few sample projects and had a look through the code. It...

Creating a jpeg from several overlapping png's

So on my site, a user has the ability to create an avatar. It's created by the user selecting from several images; there is a base "skin" image, and png's that overlap that image that depict hair, eyes, mouth, etc. I cannot save the user's avatar to the project's files, so the user's avatar data is stored in the database, and the png's...

WxWidgets draw a bitmap with opacity

How can I draw a wxImage, or wxBitmap to a DC with opacity? It looks like its not possible with the standard DC or with wxGraphicsContext. BeginLayer/EndLayer is not yet implemented in wxGraphicsContext which would have been one solution. GDI+ doesn't seem to support layers, so it would be non-trivial to add this. The only solution se...

problem with TextRenderer.MeasureText

Hi I am using TextRenderer.MeasureText() method to measure the text width for a given font. I use Arial Unicode MS font for measuring the width, which is a Unicode font containing characters for all languages. The method returns different widths on different servers. Both machines have Windows 2003, and .net 3.5 SP1 installed. Here is t...

Generating a multipage tiff is not working

I'm trying to generate a multipage tiff file from an existing picture using following code: (according to this link:http://www.bobpowell.net/generating_multipage_tiffs.htm) picture.SelectActiveFrame(FrameDimension.Page, 0); var image = new Bitmap(picture); using (var stream = new MemoryStream()) { Ima...

.NET graphical text entry

Suppose I am displaying a bitmap and want to allow text to be placed on that bitmap. I can display a RichEdit or TextBox control at the location and allow the text to be typed in at a certain font/size etc... but then the user can "see" the rectangular text entry control appear and disappear upon entry/edit and the edit cancel. It also...

Using GDI+, what's the easiest approach to align text (drawn in several different fonts) along a common baseline?

My problem: I'm currently working on a custom user control which displays pieces of text (each with a potentially different font) on one line. I'd like to align all those bits of text exactly along a common baseline. For example: Hello, I am George. ------------------------------ <- all text aligns to a common baseline ...

Does drawing over an hdc using gdi+ results in a premultiplied by alpha bitmap ?

I'm trying to draw some bitmap on a CImage object using GDI+ DrawImage. The resulting CImage bitmap seems to be premultiplied by alpha but I can't find any mention of that in the msdn documentation. What happens when I draw using DrawImage over an CImage HDC ? ...

Drawing.Graphics Line intersection add color in c#

Hello, I'm actually developing a 2d graphic application that consist on drawing lines based on a specific hardware readings. Actually, using System.Drawing.Graphics.DrawLine i'm able to draw the lines (this is the easy part). But also, I need the intersection between two lines (the common pixel in both lines) to be identified, and als...

Draw Image with GDI functions.

I have a downloaded images app in mobile. Every times an image is download successful, it auto draw on to a temp bitmap and then onPaint method draw the whole temp bitmap. It caused the flikering happened to much. My instructor advised me to use GDI functions to draw the temp bitmap onto the screen every times one image loaded. But his ...

How to convert a shape from Directx to gdi+ using c#

i draw the circle in c# using directx.i like to draw the circle with same dimensions in c# using GDI.It means i like to convert that circle from directx to GDI. Is any body help for me.plz provide the answer for me.how can i do it.Is any algorithm available for that........ And also i give the input for center of the circle is (x,y)in th...

Creating a Dib by only specifying the size with GDI+ and DotNet...

I have just recently discovered the difference between different constructors in GDI+. Going: var bmp = new Bitmap(width, height, pixelFormat); creates a DDB (Device Dependent Bitmap) whereas: var bmp = new Bitmap(someFile); creates a DIB (Device Independent Bitmap). This is really not usually important, except when handling very l...

GDI+:How to overlay an image on top of another one?(without using Graphics object)

I'm working on a solution that enables our users to draw annotations over images.So far I'm using graphics object to draw an image(annotations) over another one. The problem is that we can't always get a Graphics object from an image(GDI+ throws an exception if we try to get a graphics object of an indexed formatted image) So the questi...