What is the fastest way to draw an on an image in .net?
I'm trying to draw an image on top of another image that have in a windows form control. I know that when I try to draw it directly using loops it takes an Eon.
Options I have heard tossed around are GDI+, Direct Draw, or DX10. I start with a bitmap of a fixed size and after apply...
I'd like to draw antialiased text on a transparent bitmap and have the antialiasing drawn as alpha blended pixels. This way, I can draw the bitmap onto any color surface (or an image, for that matter) and the antialiasing still looks fine.
Here is a simplified sample showing the problem:
protected override void OnPaint(PaintEventArgs e...
I have been working on some GDI+ code in .NET and have been learning my lessons the hard way. Simple things like:
What looks good on screen may not look nice on paper and vice versa
Caching too many objects can result in an OutOfMemoryException
Floats aren't exact
...and so on. I'm sure there is a lot more that experienced folk can a...
I'm creating a non-intrusive popup window to notify the user when processing a time-consuming operation. At the moment I'm setting its transparency by calling SetLayeredWindowAttributes which gives me a reasonable result:
However I'd like the text and close button to appear opaque (it doesn't quite look right with white text) while k...
Hello!
I am stuck trying to figure out how to alter my collision detection to work correctly, i got all my wall objects stacked inside a List and then when the player moves i loop thru each wall object and call the DetectCollision method, this returns true or false depending on if the object is inside the wall or not.
Wall detect colli...
I am trying to use System.Drawing.Drawing2D.GraphicsPath.AddArc to draw an arc of an ellipse starting at 0 degrees and sweeping to 135 degrees.
The issue I am running in to is that for an ellipse, the arc drawn does not match up with what I would expect.
For example, the following code generates the image below. The green circles are w...
After reading this blog, I want to try writing a similar program myself.
One of the subtasks is to have a source set of polygons, and use these polygons to generate the bitmap that is going to be compared with the target image.
In .NET 2005 the obvious method is to use GDI+. Simply create a bitmap, get a Graphics object that interfaces...
I need to create a pen which draws with a width of 0.5 mm regardless of the scale of the graphics transformation matrix. Here is what I am doing:
Note: The sample code is C++/CLI but answers using C# are welcome.
// assume that g is a Graphics object
int dpi = g->DpiX;
float dotsPerHalfInch = dpi * 0.5;
// to extract scale factor from...
How is Graphics.Save different from Graphics.BeginContainer?
...
Dear colleagues.
Today I came across a bit of a dilema. I have created an app that uses GDI+ to draw on a form. The drawing is triggered by a timer every second. The draw method uses a for loop to iterate through a collection of objects and if they are of a certain state, draw them.
I want to draw them using a LinearGradientBrush simpl...
What is the easiest way to convert a Rectangle to a RectangleF in .NET?
Edit: This sounds trivial and it is, but I was trying to save some typing. The best I could come up with:
RectangleF rdest(rsrc.Location, rsrc.Size); // C++/CLI
...or...
RectangleF rdest = new RectangleF(rsrc.Location, rsrc.Size) // C#
...
I need to draw a line one inch long on any device given a Graphics reference to it. I need it to be an inch long regardless of what Transform is set to. Let's assume that the scaling factor of the transform is given by scale in both horizontal and vertical directions.
Some C++/CLI code:
g->DrawLine(Pens::Black, 50.0f, 50.0f, 50.0f + on...
Hi every one.
I have the picture box in which the image may be zoomed with different values. Then I try to find out the location of cursor on picture box. I write the following code on picture box mouse move event:
int x = (2 * e.X - pictureBox1.Width + pictureBox1.Image.Width) / (2 * _scale / 100);
int y = (2 * e.Y - pictureBox1.Height...
I have written a web service to resize user uploaded images and all works correctly from a functional point of view, but it causes CPU usage to spike every time it is used. It is running on Windows Server 2008 64 bit. I have tried compiling to 32 and 64 bit and get about the same results.
The heart of the service is this function:
p...
I'd like to write a piece of code which creates images similar in style to those rendered by 'Balsamiq Mockups' or 'yUML' using the .NET framework.
Can anybody tell me how to achieve the hand-drawn pencil effect using GDI+?
The text can obviously be done using the right font - my question is how to render the lines, boxes and circles.
...
Hello,
I have a .png file, with alpha channel, that I use as the BackgroundImage on a Panel control. Under certain circumstances the control is disabled. When it is disabled I want the background image to be 50% transparent so that the user gets some sort of visual indication as to the controls state.
Does anyone know how I can make ...
How can i compress and image file(bmp,jpeg) in C#,
I have to display some images as background on my controls, i m using following code to scale my image
Bitmap orgBitmap = new Bitmap(_filePath);
Bitmap regBitmap = new Bitmap(reqSize.Width, reqSize.Height);
using (Graphics gr = Graphics.FromImage(reqBitmap))
{
gr.SmoothingMode = S...
I need to add a dependency on a specific version of GDIPlus. This is the version of GDI+ that i want:
I want to be sure that I'm using this version for a specific compatibility reason.
I've added an assembly manifest to my executable, defining my dependancy on the version of GdiPlus:
<dependency>
<dependentAssembly>
<assemb...
I'm customizing the appearance of a WinForms ToolTip control by responding to the Draw event. I just want some of the ToolTip's corners to be rounded. I've got everything working such that the first time the ToolTip is displayed, everything looks perfect. On subsequent displays, however, the unfilled areas of my rounded rectangle continu...
I'm having a problem running the following code om Windows 7 x86
when creating an Image from a lzw encoded cmyk + alpha TIFF file.
The FromStream call throws a System.ArgumentException: Parameter is not validRunning
When I run the code on Vista or Server 2008 (both x86 and x64 bit) it just works.
using System;
using System.Drawing;
us...